mutation.go 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444
  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. model *string
  133. api_base *string
  134. api_key *string
  135. _type *int
  136. add_type *int
  137. clearedFields map[string]struct{}
  138. wx_agent map[uint64]struct{}
  139. removedwx_agent map[uint64]struct{}
  140. clearedwx_agent bool
  141. token_agent map[uint64]struct{}
  142. removedtoken_agent map[uint64]struct{}
  143. clearedtoken_agent bool
  144. wa_agent map[uint64]struct{}
  145. removedwa_agent map[uint64]struct{}
  146. clearedwa_agent bool
  147. xjs_agent map[uint64]struct{}
  148. removedxjs_agent map[uint64]struct{}
  149. clearedxjs_agent bool
  150. key_agent map[uint64]struct{}
  151. removedkey_agent map[uint64]struct{}
  152. clearedkey_agent bool
  153. done bool
  154. oldValue func(context.Context) (*Agent, error)
  155. predicates []predicate.Agent
  156. }
  157. var _ ent.Mutation = (*AgentMutation)(nil)
  158. // agentOption allows management of the mutation configuration using functional options.
  159. type agentOption func(*AgentMutation)
  160. // newAgentMutation creates new mutation for the Agent entity.
  161. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  162. m := &AgentMutation{
  163. config: c,
  164. op: op,
  165. typ: TypeAgent,
  166. clearedFields: make(map[string]struct{}),
  167. }
  168. for _, opt := range opts {
  169. opt(m)
  170. }
  171. return m
  172. }
  173. // withAgentID sets the ID field of the mutation.
  174. func withAgentID(id uint64) agentOption {
  175. return func(m *AgentMutation) {
  176. var (
  177. err error
  178. once sync.Once
  179. value *Agent
  180. )
  181. m.oldValue = func(ctx context.Context) (*Agent, error) {
  182. once.Do(func() {
  183. if m.done {
  184. err = errors.New("querying old values post mutation is not allowed")
  185. } else {
  186. value, err = m.Client().Agent.Get(ctx, id)
  187. }
  188. })
  189. return value, err
  190. }
  191. m.id = &id
  192. }
  193. }
  194. // withAgent sets the old Agent of the mutation.
  195. func withAgent(node *Agent) agentOption {
  196. return func(m *AgentMutation) {
  197. m.oldValue = func(context.Context) (*Agent, error) {
  198. return node, nil
  199. }
  200. m.id = &node.ID
  201. }
  202. }
  203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  204. // executed in a transaction (ent.Tx), a transactional client is returned.
  205. func (m AgentMutation) Client() *Client {
  206. client := &Client{config: m.config}
  207. client.init()
  208. return client
  209. }
  210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  211. // it returns an error otherwise.
  212. func (m AgentMutation) Tx() (*Tx, error) {
  213. if _, ok := m.driver.(*txDriver); !ok {
  214. return nil, errors.New("ent: mutation is not running in a transaction")
  215. }
  216. tx := &Tx{config: m.config}
  217. tx.init()
  218. return tx, nil
  219. }
  220. // SetID sets the value of the id field. Note that this
  221. // operation is only accepted on creation of Agent entities.
  222. func (m *AgentMutation) SetID(id uint64) {
  223. m.id = &id
  224. }
  225. // ID returns the ID value in the mutation. Note that the ID is only available
  226. // if it was provided to the builder or after it was returned from the database.
  227. func (m *AgentMutation) ID() (id uint64, exists bool) {
  228. if m.id == nil {
  229. return
  230. }
  231. return *m.id, true
  232. }
  233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  234. // That means, if the mutation is applied within a transaction with an isolation level such
  235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  236. // or updated by the mutation.
  237. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  238. switch {
  239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  240. id, exists := m.ID()
  241. if exists {
  242. return []uint64{id}, nil
  243. }
  244. fallthrough
  245. case m.op.Is(OpUpdate | OpDelete):
  246. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  247. default:
  248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  249. }
  250. }
  251. // SetCreatedAt sets the "created_at" field.
  252. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  253. m.created_at = &t
  254. }
  255. // CreatedAt returns the value of the "created_at" field in the mutation.
  256. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  257. v := m.created_at
  258. if v == nil {
  259. return
  260. }
  261. return *v, true
  262. }
  263. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  264. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  266. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  267. if !m.op.Is(OpUpdateOne) {
  268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  269. }
  270. if m.id == nil || m.oldValue == nil {
  271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  272. }
  273. oldValue, err := m.oldValue(ctx)
  274. if err != nil {
  275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  276. }
  277. return oldValue.CreatedAt, nil
  278. }
  279. // ResetCreatedAt resets all changes to the "created_at" field.
  280. func (m *AgentMutation) ResetCreatedAt() {
  281. m.created_at = nil
  282. }
  283. // SetUpdatedAt sets the "updated_at" field.
  284. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  285. m.updated_at = &t
  286. }
  287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  288. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  289. v := m.updated_at
  290. if v == nil {
  291. return
  292. }
  293. return *v, true
  294. }
  295. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  296. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  298. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  299. if !m.op.Is(OpUpdateOne) {
  300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  301. }
  302. if m.id == nil || m.oldValue == nil {
  303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  304. }
  305. oldValue, err := m.oldValue(ctx)
  306. if err != nil {
  307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  308. }
  309. return oldValue.UpdatedAt, nil
  310. }
  311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  312. func (m *AgentMutation) ResetUpdatedAt() {
  313. m.updated_at = nil
  314. }
  315. // SetDeletedAt sets the "deleted_at" field.
  316. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  317. m.deleted_at = &t
  318. }
  319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  320. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  321. v := m.deleted_at
  322. if v == nil {
  323. return
  324. }
  325. return *v, true
  326. }
  327. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  328. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  330. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  331. if !m.op.Is(OpUpdateOne) {
  332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  333. }
  334. if m.id == nil || m.oldValue == nil {
  335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  336. }
  337. oldValue, err := m.oldValue(ctx)
  338. if err != nil {
  339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  340. }
  341. return oldValue.DeletedAt, nil
  342. }
  343. // ClearDeletedAt clears the value of the "deleted_at" field.
  344. func (m *AgentMutation) ClearDeletedAt() {
  345. m.deleted_at = nil
  346. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  347. }
  348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  349. func (m *AgentMutation) DeletedAtCleared() bool {
  350. _, ok := m.clearedFields[agent.FieldDeletedAt]
  351. return ok
  352. }
  353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  354. func (m *AgentMutation) ResetDeletedAt() {
  355. m.deleted_at = nil
  356. delete(m.clearedFields, agent.FieldDeletedAt)
  357. }
  358. // SetName sets the "name" field.
  359. func (m *AgentMutation) SetName(s string) {
  360. m.name = &s
  361. }
  362. // Name returns the value of the "name" field in the mutation.
  363. func (m *AgentMutation) Name() (r string, exists bool) {
  364. v := m.name
  365. if v == nil {
  366. return
  367. }
  368. return *v, true
  369. }
  370. // OldName returns the old "name" field's value of the Agent entity.
  371. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  373. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  374. if !m.op.Is(OpUpdateOne) {
  375. return v, errors.New("OldName is only allowed on UpdateOne operations")
  376. }
  377. if m.id == nil || m.oldValue == nil {
  378. return v, errors.New("OldName requires an ID field in the mutation")
  379. }
  380. oldValue, err := m.oldValue(ctx)
  381. if err != nil {
  382. return v, fmt.Errorf("querying old value for OldName: %w", err)
  383. }
  384. return oldValue.Name, nil
  385. }
  386. // ResetName resets all changes to the "name" field.
  387. func (m *AgentMutation) ResetName() {
  388. m.name = nil
  389. }
  390. // SetRole sets the "role" field.
  391. func (m *AgentMutation) SetRole(s string) {
  392. m.role = &s
  393. }
  394. // Role returns the value of the "role" field in the mutation.
  395. func (m *AgentMutation) Role() (r string, exists bool) {
  396. v := m.role
  397. if v == nil {
  398. return
  399. }
  400. return *v, true
  401. }
  402. // OldRole returns the old "role" field's value of the Agent entity.
  403. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  405. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  406. if !m.op.Is(OpUpdateOne) {
  407. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  408. }
  409. if m.id == nil || m.oldValue == nil {
  410. return v, errors.New("OldRole requires an ID field in the mutation")
  411. }
  412. oldValue, err := m.oldValue(ctx)
  413. if err != nil {
  414. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  415. }
  416. return oldValue.Role, nil
  417. }
  418. // ClearRole clears the value of the "role" field.
  419. func (m *AgentMutation) ClearRole() {
  420. m.role = nil
  421. m.clearedFields[agent.FieldRole] = struct{}{}
  422. }
  423. // RoleCleared returns if the "role" field was cleared in this mutation.
  424. func (m *AgentMutation) RoleCleared() bool {
  425. _, ok := m.clearedFields[agent.FieldRole]
  426. return ok
  427. }
  428. // ResetRole resets all changes to the "role" field.
  429. func (m *AgentMutation) ResetRole() {
  430. m.role = nil
  431. delete(m.clearedFields, agent.FieldRole)
  432. }
  433. // SetStatus sets the "status" field.
  434. func (m *AgentMutation) SetStatus(i int) {
  435. m.status = &i
  436. m.addstatus = nil
  437. }
  438. // Status returns the value of the "status" field in the mutation.
  439. func (m *AgentMutation) Status() (r int, exists bool) {
  440. v := m.status
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // OldStatus returns the old "status" field's value of the Agent entity.
  447. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  449. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  450. if !m.op.Is(OpUpdateOne) {
  451. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  452. }
  453. if m.id == nil || m.oldValue == nil {
  454. return v, errors.New("OldStatus requires an ID field in the mutation")
  455. }
  456. oldValue, err := m.oldValue(ctx)
  457. if err != nil {
  458. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  459. }
  460. return oldValue.Status, nil
  461. }
  462. // AddStatus adds i to the "status" field.
  463. func (m *AgentMutation) AddStatus(i int) {
  464. if m.addstatus != nil {
  465. *m.addstatus += i
  466. } else {
  467. m.addstatus = &i
  468. }
  469. }
  470. // AddedStatus returns the value that was added to the "status" field in this mutation.
  471. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  472. v := m.addstatus
  473. if v == nil {
  474. return
  475. }
  476. return *v, true
  477. }
  478. // ClearStatus clears the value of the "status" field.
  479. func (m *AgentMutation) ClearStatus() {
  480. m.status = nil
  481. m.addstatus = nil
  482. m.clearedFields[agent.FieldStatus] = struct{}{}
  483. }
  484. // StatusCleared returns if the "status" field was cleared in this mutation.
  485. func (m *AgentMutation) StatusCleared() bool {
  486. _, ok := m.clearedFields[agent.FieldStatus]
  487. return ok
  488. }
  489. // ResetStatus resets all changes to the "status" field.
  490. func (m *AgentMutation) ResetStatus() {
  491. m.status = nil
  492. m.addstatus = nil
  493. delete(m.clearedFields, agent.FieldStatus)
  494. }
  495. // SetBackground sets the "background" field.
  496. func (m *AgentMutation) SetBackground(s string) {
  497. m.background = &s
  498. }
  499. // Background returns the value of the "background" field in the mutation.
  500. func (m *AgentMutation) Background() (r string, exists bool) {
  501. v := m.background
  502. if v == nil {
  503. return
  504. }
  505. return *v, true
  506. }
  507. // OldBackground returns the old "background" field's value of the Agent entity.
  508. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  510. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  511. if !m.op.Is(OpUpdateOne) {
  512. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  513. }
  514. if m.id == nil || m.oldValue == nil {
  515. return v, errors.New("OldBackground requires an ID field in the mutation")
  516. }
  517. oldValue, err := m.oldValue(ctx)
  518. if err != nil {
  519. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  520. }
  521. return oldValue.Background, nil
  522. }
  523. // ClearBackground clears the value of the "background" field.
  524. func (m *AgentMutation) ClearBackground() {
  525. m.background = nil
  526. m.clearedFields[agent.FieldBackground] = struct{}{}
  527. }
  528. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  529. func (m *AgentMutation) BackgroundCleared() bool {
  530. _, ok := m.clearedFields[agent.FieldBackground]
  531. return ok
  532. }
  533. // ResetBackground resets all changes to the "background" field.
  534. func (m *AgentMutation) ResetBackground() {
  535. m.background = nil
  536. delete(m.clearedFields, agent.FieldBackground)
  537. }
  538. // SetExamples sets the "examples" field.
  539. func (m *AgentMutation) SetExamples(s string) {
  540. m.examples = &s
  541. }
  542. // Examples returns the value of the "examples" field in the mutation.
  543. func (m *AgentMutation) Examples() (r string, exists bool) {
  544. v := m.examples
  545. if v == nil {
  546. return
  547. }
  548. return *v, true
  549. }
  550. // OldExamples returns the old "examples" field's value of the Agent entity.
  551. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  553. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  554. if !m.op.Is(OpUpdateOne) {
  555. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  556. }
  557. if m.id == nil || m.oldValue == nil {
  558. return v, errors.New("OldExamples requires an ID field in the mutation")
  559. }
  560. oldValue, err := m.oldValue(ctx)
  561. if err != nil {
  562. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  563. }
  564. return oldValue.Examples, nil
  565. }
  566. // ClearExamples clears the value of the "examples" field.
  567. func (m *AgentMutation) ClearExamples() {
  568. m.examples = nil
  569. m.clearedFields[agent.FieldExamples] = struct{}{}
  570. }
  571. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  572. func (m *AgentMutation) ExamplesCleared() bool {
  573. _, ok := m.clearedFields[agent.FieldExamples]
  574. return ok
  575. }
  576. // ResetExamples resets all changes to the "examples" field.
  577. func (m *AgentMutation) ResetExamples() {
  578. m.examples = nil
  579. delete(m.clearedFields, agent.FieldExamples)
  580. }
  581. // SetOrganizationID sets the "organization_id" field.
  582. func (m *AgentMutation) SetOrganizationID(u uint64) {
  583. m.organization_id = &u
  584. m.addorganization_id = nil
  585. }
  586. // OrganizationID returns the value of the "organization_id" field in the mutation.
  587. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  588. v := m.organization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  595. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  597. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  598. if !m.op.Is(OpUpdateOne) {
  599. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  600. }
  601. if m.id == nil || m.oldValue == nil {
  602. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  603. }
  604. oldValue, err := m.oldValue(ctx)
  605. if err != nil {
  606. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  607. }
  608. return oldValue.OrganizationID, nil
  609. }
  610. // AddOrganizationID adds u to the "organization_id" field.
  611. func (m *AgentMutation) AddOrganizationID(u int64) {
  612. if m.addorganization_id != nil {
  613. *m.addorganization_id += u
  614. } else {
  615. m.addorganization_id = &u
  616. }
  617. }
  618. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  619. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  620. v := m.addorganization_id
  621. if v == nil {
  622. return
  623. }
  624. return *v, true
  625. }
  626. // ResetOrganizationID resets all changes to the "organization_id" field.
  627. func (m *AgentMutation) ResetOrganizationID() {
  628. m.organization_id = nil
  629. m.addorganization_id = nil
  630. }
  631. // SetDatasetID sets the "dataset_id" field.
  632. func (m *AgentMutation) SetDatasetID(s string) {
  633. m.dataset_id = &s
  634. }
  635. // DatasetID returns the value of the "dataset_id" field in the mutation.
  636. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  637. v := m.dataset_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  644. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  646. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  652. }
  653. oldValue, err := m.oldValue(ctx)
  654. if err != nil {
  655. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  656. }
  657. return oldValue.DatasetID, nil
  658. }
  659. // ResetDatasetID resets all changes to the "dataset_id" field.
  660. func (m *AgentMutation) ResetDatasetID() {
  661. m.dataset_id = nil
  662. }
  663. // SetCollectionID sets the "collection_id" field.
  664. func (m *AgentMutation) SetCollectionID(s string) {
  665. m.collection_id = &s
  666. }
  667. // CollectionID returns the value of the "collection_id" field in the mutation.
  668. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  669. v := m.collection_id
  670. if v == nil {
  671. return
  672. }
  673. return *v, true
  674. }
  675. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  676. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  678. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  679. if !m.op.Is(OpUpdateOne) {
  680. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  681. }
  682. if m.id == nil || m.oldValue == nil {
  683. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  684. }
  685. oldValue, err := m.oldValue(ctx)
  686. if err != nil {
  687. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  688. }
  689. return oldValue.CollectionID, nil
  690. }
  691. // ResetCollectionID resets all changes to the "collection_id" field.
  692. func (m *AgentMutation) ResetCollectionID() {
  693. m.collection_id = nil
  694. }
  695. // SetModel sets the "model" field.
  696. func (m *AgentMutation) SetModel(s string) {
  697. m.model = &s
  698. }
  699. // Model returns the value of the "model" field in the mutation.
  700. func (m *AgentMutation) Model() (r string, exists bool) {
  701. v := m.model
  702. if v == nil {
  703. return
  704. }
  705. return *v, true
  706. }
  707. // OldModel returns the old "model" field's value of the Agent entity.
  708. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  710. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  711. if !m.op.Is(OpUpdateOne) {
  712. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  713. }
  714. if m.id == nil || m.oldValue == nil {
  715. return v, errors.New("OldModel requires an ID field in the mutation")
  716. }
  717. oldValue, err := m.oldValue(ctx)
  718. if err != nil {
  719. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  720. }
  721. return oldValue.Model, nil
  722. }
  723. // ClearModel clears the value of the "model" field.
  724. func (m *AgentMutation) ClearModel() {
  725. m.model = nil
  726. m.clearedFields[agent.FieldModel] = struct{}{}
  727. }
  728. // ModelCleared returns if the "model" field was cleared in this mutation.
  729. func (m *AgentMutation) ModelCleared() bool {
  730. _, ok := m.clearedFields[agent.FieldModel]
  731. return ok
  732. }
  733. // ResetModel resets all changes to the "model" field.
  734. func (m *AgentMutation) ResetModel() {
  735. m.model = nil
  736. delete(m.clearedFields, agent.FieldModel)
  737. }
  738. // SetAPIBase sets the "api_base" field.
  739. func (m *AgentMutation) SetAPIBase(s string) {
  740. m.api_base = &s
  741. }
  742. // APIBase returns the value of the "api_base" field in the mutation.
  743. func (m *AgentMutation) APIBase() (r string, exists bool) {
  744. v := m.api_base
  745. if v == nil {
  746. return
  747. }
  748. return *v, true
  749. }
  750. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  751. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  753. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  754. if !m.op.Is(OpUpdateOne) {
  755. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  756. }
  757. if m.id == nil || m.oldValue == nil {
  758. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  759. }
  760. oldValue, err := m.oldValue(ctx)
  761. if err != nil {
  762. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  763. }
  764. return oldValue.APIBase, nil
  765. }
  766. // ClearAPIBase clears the value of the "api_base" field.
  767. func (m *AgentMutation) ClearAPIBase() {
  768. m.api_base = nil
  769. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  770. }
  771. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  772. func (m *AgentMutation) APIBaseCleared() bool {
  773. _, ok := m.clearedFields[agent.FieldAPIBase]
  774. return ok
  775. }
  776. // ResetAPIBase resets all changes to the "api_base" field.
  777. func (m *AgentMutation) ResetAPIBase() {
  778. m.api_base = nil
  779. delete(m.clearedFields, agent.FieldAPIBase)
  780. }
  781. // SetAPIKey sets the "api_key" field.
  782. func (m *AgentMutation) SetAPIKey(s string) {
  783. m.api_key = &s
  784. }
  785. // APIKey returns the value of the "api_key" field in the mutation.
  786. func (m *AgentMutation) APIKey() (r string, exists bool) {
  787. v := m.api_key
  788. if v == nil {
  789. return
  790. }
  791. return *v, true
  792. }
  793. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  794. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  796. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  797. if !m.op.Is(OpUpdateOne) {
  798. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  799. }
  800. if m.id == nil || m.oldValue == nil {
  801. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  802. }
  803. oldValue, err := m.oldValue(ctx)
  804. if err != nil {
  805. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  806. }
  807. return oldValue.APIKey, nil
  808. }
  809. // ClearAPIKey clears the value of the "api_key" field.
  810. func (m *AgentMutation) ClearAPIKey() {
  811. m.api_key = nil
  812. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  813. }
  814. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  815. func (m *AgentMutation) APIKeyCleared() bool {
  816. _, ok := m.clearedFields[agent.FieldAPIKey]
  817. return ok
  818. }
  819. // ResetAPIKey resets all changes to the "api_key" field.
  820. func (m *AgentMutation) ResetAPIKey() {
  821. m.api_key = nil
  822. delete(m.clearedFields, agent.FieldAPIKey)
  823. }
  824. // SetType sets the "type" field.
  825. func (m *AgentMutation) SetType(i int) {
  826. m._type = &i
  827. m.add_type = nil
  828. }
  829. // GetType returns the value of the "type" field in the mutation.
  830. func (m *AgentMutation) GetType() (r int, exists bool) {
  831. v := m._type
  832. if v == nil {
  833. return
  834. }
  835. return *v, true
  836. }
  837. // OldType returns the old "type" field's value of the Agent entity.
  838. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  840. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  841. if !m.op.Is(OpUpdateOne) {
  842. return v, errors.New("OldType is only allowed on UpdateOne operations")
  843. }
  844. if m.id == nil || m.oldValue == nil {
  845. return v, errors.New("OldType requires an ID field in the mutation")
  846. }
  847. oldValue, err := m.oldValue(ctx)
  848. if err != nil {
  849. return v, fmt.Errorf("querying old value for OldType: %w", err)
  850. }
  851. return oldValue.Type, nil
  852. }
  853. // AddType adds i to the "type" field.
  854. func (m *AgentMutation) AddType(i int) {
  855. if m.add_type != nil {
  856. *m.add_type += i
  857. } else {
  858. m.add_type = &i
  859. }
  860. }
  861. // AddedType returns the value that was added to the "type" field in this mutation.
  862. func (m *AgentMutation) AddedType() (r int, exists bool) {
  863. v := m.add_type
  864. if v == nil {
  865. return
  866. }
  867. return *v, true
  868. }
  869. // ClearType clears the value of the "type" field.
  870. func (m *AgentMutation) ClearType() {
  871. m._type = nil
  872. m.add_type = nil
  873. m.clearedFields[agent.FieldType] = struct{}{}
  874. }
  875. // TypeCleared returns if the "type" field was cleared in this mutation.
  876. func (m *AgentMutation) TypeCleared() bool {
  877. _, ok := m.clearedFields[agent.FieldType]
  878. return ok
  879. }
  880. // ResetType resets all changes to the "type" field.
  881. func (m *AgentMutation) ResetType() {
  882. m._type = nil
  883. m.add_type = nil
  884. delete(m.clearedFields, agent.FieldType)
  885. }
  886. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  887. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  888. if m.wx_agent == nil {
  889. m.wx_agent = make(map[uint64]struct{})
  890. }
  891. for i := range ids {
  892. m.wx_agent[ids[i]] = struct{}{}
  893. }
  894. }
  895. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  896. func (m *AgentMutation) ClearWxAgent() {
  897. m.clearedwx_agent = true
  898. }
  899. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  900. func (m *AgentMutation) WxAgentCleared() bool {
  901. return m.clearedwx_agent
  902. }
  903. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  904. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  905. if m.removedwx_agent == nil {
  906. m.removedwx_agent = make(map[uint64]struct{})
  907. }
  908. for i := range ids {
  909. delete(m.wx_agent, ids[i])
  910. m.removedwx_agent[ids[i]] = struct{}{}
  911. }
  912. }
  913. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  914. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  915. for id := range m.removedwx_agent {
  916. ids = append(ids, id)
  917. }
  918. return
  919. }
  920. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  921. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  922. for id := range m.wx_agent {
  923. ids = append(ids, id)
  924. }
  925. return
  926. }
  927. // ResetWxAgent resets all changes to the "wx_agent" edge.
  928. func (m *AgentMutation) ResetWxAgent() {
  929. m.wx_agent = nil
  930. m.clearedwx_agent = false
  931. m.removedwx_agent = nil
  932. }
  933. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  934. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  935. if m.token_agent == nil {
  936. m.token_agent = make(map[uint64]struct{})
  937. }
  938. for i := range ids {
  939. m.token_agent[ids[i]] = struct{}{}
  940. }
  941. }
  942. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  943. func (m *AgentMutation) ClearTokenAgent() {
  944. m.clearedtoken_agent = true
  945. }
  946. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  947. func (m *AgentMutation) TokenAgentCleared() bool {
  948. return m.clearedtoken_agent
  949. }
  950. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  951. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  952. if m.removedtoken_agent == nil {
  953. m.removedtoken_agent = make(map[uint64]struct{})
  954. }
  955. for i := range ids {
  956. delete(m.token_agent, ids[i])
  957. m.removedtoken_agent[ids[i]] = struct{}{}
  958. }
  959. }
  960. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  961. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  962. for id := range m.removedtoken_agent {
  963. ids = append(ids, id)
  964. }
  965. return
  966. }
  967. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  968. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  969. for id := range m.token_agent {
  970. ids = append(ids, id)
  971. }
  972. return
  973. }
  974. // ResetTokenAgent resets all changes to the "token_agent" edge.
  975. func (m *AgentMutation) ResetTokenAgent() {
  976. m.token_agent = nil
  977. m.clearedtoken_agent = false
  978. m.removedtoken_agent = nil
  979. }
  980. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  981. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  982. if m.wa_agent == nil {
  983. m.wa_agent = make(map[uint64]struct{})
  984. }
  985. for i := range ids {
  986. m.wa_agent[ids[i]] = struct{}{}
  987. }
  988. }
  989. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  990. func (m *AgentMutation) ClearWaAgent() {
  991. m.clearedwa_agent = true
  992. }
  993. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  994. func (m *AgentMutation) WaAgentCleared() bool {
  995. return m.clearedwa_agent
  996. }
  997. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  998. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  999. if m.removedwa_agent == nil {
  1000. m.removedwa_agent = make(map[uint64]struct{})
  1001. }
  1002. for i := range ids {
  1003. delete(m.wa_agent, ids[i])
  1004. m.removedwa_agent[ids[i]] = struct{}{}
  1005. }
  1006. }
  1007. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1008. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1009. for id := range m.removedwa_agent {
  1010. ids = append(ids, id)
  1011. }
  1012. return
  1013. }
  1014. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1015. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1016. for id := range m.wa_agent {
  1017. ids = append(ids, id)
  1018. }
  1019. return
  1020. }
  1021. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1022. func (m *AgentMutation) ResetWaAgent() {
  1023. m.wa_agent = nil
  1024. m.clearedwa_agent = false
  1025. m.removedwa_agent = nil
  1026. }
  1027. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  1028. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  1029. if m.xjs_agent == nil {
  1030. m.xjs_agent = make(map[uint64]struct{})
  1031. }
  1032. for i := range ids {
  1033. m.xjs_agent[ids[i]] = struct{}{}
  1034. }
  1035. }
  1036. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  1037. func (m *AgentMutation) ClearXjsAgent() {
  1038. m.clearedxjs_agent = true
  1039. }
  1040. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  1041. func (m *AgentMutation) XjsAgentCleared() bool {
  1042. return m.clearedxjs_agent
  1043. }
  1044. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  1045. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  1046. if m.removedxjs_agent == nil {
  1047. m.removedxjs_agent = make(map[uint64]struct{})
  1048. }
  1049. for i := range ids {
  1050. delete(m.xjs_agent, ids[i])
  1051. m.removedxjs_agent[ids[i]] = struct{}{}
  1052. }
  1053. }
  1054. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  1055. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  1056. for id := range m.removedxjs_agent {
  1057. ids = append(ids, id)
  1058. }
  1059. return
  1060. }
  1061. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  1062. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  1063. for id := range m.xjs_agent {
  1064. ids = append(ids, id)
  1065. }
  1066. return
  1067. }
  1068. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  1069. func (m *AgentMutation) ResetXjsAgent() {
  1070. m.xjs_agent = nil
  1071. m.clearedxjs_agent = false
  1072. m.removedxjs_agent = nil
  1073. }
  1074. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1075. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1076. if m.key_agent == nil {
  1077. m.key_agent = make(map[uint64]struct{})
  1078. }
  1079. for i := range ids {
  1080. m.key_agent[ids[i]] = struct{}{}
  1081. }
  1082. }
  1083. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1084. func (m *AgentMutation) ClearKeyAgent() {
  1085. m.clearedkey_agent = true
  1086. }
  1087. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1088. func (m *AgentMutation) KeyAgentCleared() bool {
  1089. return m.clearedkey_agent
  1090. }
  1091. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1092. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1093. if m.removedkey_agent == nil {
  1094. m.removedkey_agent = make(map[uint64]struct{})
  1095. }
  1096. for i := range ids {
  1097. delete(m.key_agent, ids[i])
  1098. m.removedkey_agent[ids[i]] = struct{}{}
  1099. }
  1100. }
  1101. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1102. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1103. for id := range m.removedkey_agent {
  1104. ids = append(ids, id)
  1105. }
  1106. return
  1107. }
  1108. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1109. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1110. for id := range m.key_agent {
  1111. ids = append(ids, id)
  1112. }
  1113. return
  1114. }
  1115. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1116. func (m *AgentMutation) ResetKeyAgent() {
  1117. m.key_agent = nil
  1118. m.clearedkey_agent = false
  1119. m.removedkey_agent = nil
  1120. }
  1121. // Where appends a list predicates to the AgentMutation builder.
  1122. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1123. m.predicates = append(m.predicates, ps...)
  1124. }
  1125. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1126. // users can use type-assertion to append predicates that do not depend on any generated package.
  1127. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1128. p := make([]predicate.Agent, len(ps))
  1129. for i := range ps {
  1130. p[i] = ps[i]
  1131. }
  1132. m.Where(p...)
  1133. }
  1134. // Op returns the operation name.
  1135. func (m *AgentMutation) Op() Op {
  1136. return m.op
  1137. }
  1138. // SetOp allows setting the mutation operation.
  1139. func (m *AgentMutation) SetOp(op Op) {
  1140. m.op = op
  1141. }
  1142. // Type returns the node type of this mutation (Agent).
  1143. func (m *AgentMutation) Type() string {
  1144. return m.typ
  1145. }
  1146. // Fields returns all fields that were changed during this mutation. Note that in
  1147. // order to get all numeric fields that were incremented/decremented, call
  1148. // AddedFields().
  1149. func (m *AgentMutation) Fields() []string {
  1150. fields := make([]string, 0, 15)
  1151. if m.created_at != nil {
  1152. fields = append(fields, agent.FieldCreatedAt)
  1153. }
  1154. if m.updated_at != nil {
  1155. fields = append(fields, agent.FieldUpdatedAt)
  1156. }
  1157. if m.deleted_at != nil {
  1158. fields = append(fields, agent.FieldDeletedAt)
  1159. }
  1160. if m.name != nil {
  1161. fields = append(fields, agent.FieldName)
  1162. }
  1163. if m.role != nil {
  1164. fields = append(fields, agent.FieldRole)
  1165. }
  1166. if m.status != nil {
  1167. fields = append(fields, agent.FieldStatus)
  1168. }
  1169. if m.background != nil {
  1170. fields = append(fields, agent.FieldBackground)
  1171. }
  1172. if m.examples != nil {
  1173. fields = append(fields, agent.FieldExamples)
  1174. }
  1175. if m.organization_id != nil {
  1176. fields = append(fields, agent.FieldOrganizationID)
  1177. }
  1178. if m.dataset_id != nil {
  1179. fields = append(fields, agent.FieldDatasetID)
  1180. }
  1181. if m.collection_id != nil {
  1182. fields = append(fields, agent.FieldCollectionID)
  1183. }
  1184. if m.model != nil {
  1185. fields = append(fields, agent.FieldModel)
  1186. }
  1187. if m.api_base != nil {
  1188. fields = append(fields, agent.FieldAPIBase)
  1189. }
  1190. if m.api_key != nil {
  1191. fields = append(fields, agent.FieldAPIKey)
  1192. }
  1193. if m._type != nil {
  1194. fields = append(fields, agent.FieldType)
  1195. }
  1196. return fields
  1197. }
  1198. // Field returns the value of a field with the given name. The second boolean
  1199. // return value indicates that this field was not set, or was not defined in the
  1200. // schema.
  1201. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1202. switch name {
  1203. case agent.FieldCreatedAt:
  1204. return m.CreatedAt()
  1205. case agent.FieldUpdatedAt:
  1206. return m.UpdatedAt()
  1207. case agent.FieldDeletedAt:
  1208. return m.DeletedAt()
  1209. case agent.FieldName:
  1210. return m.Name()
  1211. case agent.FieldRole:
  1212. return m.Role()
  1213. case agent.FieldStatus:
  1214. return m.Status()
  1215. case agent.FieldBackground:
  1216. return m.Background()
  1217. case agent.FieldExamples:
  1218. return m.Examples()
  1219. case agent.FieldOrganizationID:
  1220. return m.OrganizationID()
  1221. case agent.FieldDatasetID:
  1222. return m.DatasetID()
  1223. case agent.FieldCollectionID:
  1224. return m.CollectionID()
  1225. case agent.FieldModel:
  1226. return m.Model()
  1227. case agent.FieldAPIBase:
  1228. return m.APIBase()
  1229. case agent.FieldAPIKey:
  1230. return m.APIKey()
  1231. case agent.FieldType:
  1232. return m.GetType()
  1233. }
  1234. return nil, false
  1235. }
  1236. // OldField returns the old value of the field from the database. An error is
  1237. // returned if the mutation operation is not UpdateOne, or the query to the
  1238. // database failed.
  1239. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1240. switch name {
  1241. case agent.FieldCreatedAt:
  1242. return m.OldCreatedAt(ctx)
  1243. case agent.FieldUpdatedAt:
  1244. return m.OldUpdatedAt(ctx)
  1245. case agent.FieldDeletedAt:
  1246. return m.OldDeletedAt(ctx)
  1247. case agent.FieldName:
  1248. return m.OldName(ctx)
  1249. case agent.FieldRole:
  1250. return m.OldRole(ctx)
  1251. case agent.FieldStatus:
  1252. return m.OldStatus(ctx)
  1253. case agent.FieldBackground:
  1254. return m.OldBackground(ctx)
  1255. case agent.FieldExamples:
  1256. return m.OldExamples(ctx)
  1257. case agent.FieldOrganizationID:
  1258. return m.OldOrganizationID(ctx)
  1259. case agent.FieldDatasetID:
  1260. return m.OldDatasetID(ctx)
  1261. case agent.FieldCollectionID:
  1262. return m.OldCollectionID(ctx)
  1263. case agent.FieldModel:
  1264. return m.OldModel(ctx)
  1265. case agent.FieldAPIBase:
  1266. return m.OldAPIBase(ctx)
  1267. case agent.FieldAPIKey:
  1268. return m.OldAPIKey(ctx)
  1269. case agent.FieldType:
  1270. return m.OldType(ctx)
  1271. }
  1272. return nil, fmt.Errorf("unknown Agent field %s", name)
  1273. }
  1274. // SetField sets the value of a field with the given name. It returns an error if
  1275. // the field is not defined in the schema, or if the type mismatched the field
  1276. // type.
  1277. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1278. switch name {
  1279. case agent.FieldCreatedAt:
  1280. v, ok := value.(time.Time)
  1281. if !ok {
  1282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1283. }
  1284. m.SetCreatedAt(v)
  1285. return nil
  1286. case agent.FieldUpdatedAt:
  1287. v, ok := value.(time.Time)
  1288. if !ok {
  1289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1290. }
  1291. m.SetUpdatedAt(v)
  1292. return nil
  1293. case agent.FieldDeletedAt:
  1294. v, ok := value.(time.Time)
  1295. if !ok {
  1296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1297. }
  1298. m.SetDeletedAt(v)
  1299. return nil
  1300. case agent.FieldName:
  1301. v, ok := value.(string)
  1302. if !ok {
  1303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1304. }
  1305. m.SetName(v)
  1306. return nil
  1307. case agent.FieldRole:
  1308. v, ok := value.(string)
  1309. if !ok {
  1310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1311. }
  1312. m.SetRole(v)
  1313. return nil
  1314. case agent.FieldStatus:
  1315. v, ok := value.(int)
  1316. if !ok {
  1317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1318. }
  1319. m.SetStatus(v)
  1320. return nil
  1321. case agent.FieldBackground:
  1322. v, ok := value.(string)
  1323. if !ok {
  1324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1325. }
  1326. m.SetBackground(v)
  1327. return nil
  1328. case agent.FieldExamples:
  1329. v, ok := value.(string)
  1330. if !ok {
  1331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1332. }
  1333. m.SetExamples(v)
  1334. return nil
  1335. case agent.FieldOrganizationID:
  1336. v, ok := value.(uint64)
  1337. if !ok {
  1338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1339. }
  1340. m.SetOrganizationID(v)
  1341. return nil
  1342. case agent.FieldDatasetID:
  1343. v, ok := value.(string)
  1344. if !ok {
  1345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1346. }
  1347. m.SetDatasetID(v)
  1348. return nil
  1349. case agent.FieldCollectionID:
  1350. v, ok := value.(string)
  1351. if !ok {
  1352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1353. }
  1354. m.SetCollectionID(v)
  1355. return nil
  1356. case agent.FieldModel:
  1357. v, ok := value.(string)
  1358. if !ok {
  1359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1360. }
  1361. m.SetModel(v)
  1362. return nil
  1363. case agent.FieldAPIBase:
  1364. v, ok := value.(string)
  1365. if !ok {
  1366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1367. }
  1368. m.SetAPIBase(v)
  1369. return nil
  1370. case agent.FieldAPIKey:
  1371. v, ok := value.(string)
  1372. if !ok {
  1373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1374. }
  1375. m.SetAPIKey(v)
  1376. return nil
  1377. case agent.FieldType:
  1378. v, ok := value.(int)
  1379. if !ok {
  1380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1381. }
  1382. m.SetType(v)
  1383. return nil
  1384. }
  1385. return fmt.Errorf("unknown Agent field %s", name)
  1386. }
  1387. // AddedFields returns all numeric fields that were incremented/decremented during
  1388. // this mutation.
  1389. func (m *AgentMutation) AddedFields() []string {
  1390. var fields []string
  1391. if m.addstatus != nil {
  1392. fields = append(fields, agent.FieldStatus)
  1393. }
  1394. if m.addorganization_id != nil {
  1395. fields = append(fields, agent.FieldOrganizationID)
  1396. }
  1397. if m.add_type != nil {
  1398. fields = append(fields, agent.FieldType)
  1399. }
  1400. return fields
  1401. }
  1402. // AddedField returns the numeric value that was incremented/decremented on a field
  1403. // with the given name. The second boolean return value indicates that this field
  1404. // was not set, or was not defined in the schema.
  1405. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1406. switch name {
  1407. case agent.FieldStatus:
  1408. return m.AddedStatus()
  1409. case agent.FieldOrganizationID:
  1410. return m.AddedOrganizationID()
  1411. case agent.FieldType:
  1412. return m.AddedType()
  1413. }
  1414. return nil, false
  1415. }
  1416. // AddField adds the value to the field with the given name. It returns an error if
  1417. // the field is not defined in the schema, or if the type mismatched the field
  1418. // type.
  1419. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1420. switch name {
  1421. case agent.FieldStatus:
  1422. v, ok := value.(int)
  1423. if !ok {
  1424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1425. }
  1426. m.AddStatus(v)
  1427. return nil
  1428. case agent.FieldOrganizationID:
  1429. v, ok := value.(int64)
  1430. if !ok {
  1431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1432. }
  1433. m.AddOrganizationID(v)
  1434. return nil
  1435. case agent.FieldType:
  1436. v, ok := value.(int)
  1437. if !ok {
  1438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1439. }
  1440. m.AddType(v)
  1441. return nil
  1442. }
  1443. return fmt.Errorf("unknown Agent numeric field %s", name)
  1444. }
  1445. // ClearedFields returns all nullable fields that were cleared during this
  1446. // mutation.
  1447. func (m *AgentMutation) ClearedFields() []string {
  1448. var fields []string
  1449. if m.FieldCleared(agent.FieldDeletedAt) {
  1450. fields = append(fields, agent.FieldDeletedAt)
  1451. }
  1452. if m.FieldCleared(agent.FieldRole) {
  1453. fields = append(fields, agent.FieldRole)
  1454. }
  1455. if m.FieldCleared(agent.FieldStatus) {
  1456. fields = append(fields, agent.FieldStatus)
  1457. }
  1458. if m.FieldCleared(agent.FieldBackground) {
  1459. fields = append(fields, agent.FieldBackground)
  1460. }
  1461. if m.FieldCleared(agent.FieldExamples) {
  1462. fields = append(fields, agent.FieldExamples)
  1463. }
  1464. if m.FieldCleared(agent.FieldModel) {
  1465. fields = append(fields, agent.FieldModel)
  1466. }
  1467. if m.FieldCleared(agent.FieldAPIBase) {
  1468. fields = append(fields, agent.FieldAPIBase)
  1469. }
  1470. if m.FieldCleared(agent.FieldAPIKey) {
  1471. fields = append(fields, agent.FieldAPIKey)
  1472. }
  1473. if m.FieldCleared(agent.FieldType) {
  1474. fields = append(fields, agent.FieldType)
  1475. }
  1476. return fields
  1477. }
  1478. // FieldCleared returns a boolean indicating if a field with the given name was
  1479. // cleared in this mutation.
  1480. func (m *AgentMutation) FieldCleared(name string) bool {
  1481. _, ok := m.clearedFields[name]
  1482. return ok
  1483. }
  1484. // ClearField clears the value of the field with the given name. It returns an
  1485. // error if the field is not defined in the schema.
  1486. func (m *AgentMutation) ClearField(name string) error {
  1487. switch name {
  1488. case agent.FieldDeletedAt:
  1489. m.ClearDeletedAt()
  1490. return nil
  1491. case agent.FieldRole:
  1492. m.ClearRole()
  1493. return nil
  1494. case agent.FieldStatus:
  1495. m.ClearStatus()
  1496. return nil
  1497. case agent.FieldBackground:
  1498. m.ClearBackground()
  1499. return nil
  1500. case agent.FieldExamples:
  1501. m.ClearExamples()
  1502. return nil
  1503. case agent.FieldModel:
  1504. m.ClearModel()
  1505. return nil
  1506. case agent.FieldAPIBase:
  1507. m.ClearAPIBase()
  1508. return nil
  1509. case agent.FieldAPIKey:
  1510. m.ClearAPIKey()
  1511. return nil
  1512. case agent.FieldType:
  1513. m.ClearType()
  1514. return nil
  1515. }
  1516. return fmt.Errorf("unknown Agent nullable field %s", name)
  1517. }
  1518. // ResetField resets all changes in the mutation for the field with the given name.
  1519. // It returns an error if the field is not defined in the schema.
  1520. func (m *AgentMutation) ResetField(name string) error {
  1521. switch name {
  1522. case agent.FieldCreatedAt:
  1523. m.ResetCreatedAt()
  1524. return nil
  1525. case agent.FieldUpdatedAt:
  1526. m.ResetUpdatedAt()
  1527. return nil
  1528. case agent.FieldDeletedAt:
  1529. m.ResetDeletedAt()
  1530. return nil
  1531. case agent.FieldName:
  1532. m.ResetName()
  1533. return nil
  1534. case agent.FieldRole:
  1535. m.ResetRole()
  1536. return nil
  1537. case agent.FieldStatus:
  1538. m.ResetStatus()
  1539. return nil
  1540. case agent.FieldBackground:
  1541. m.ResetBackground()
  1542. return nil
  1543. case agent.FieldExamples:
  1544. m.ResetExamples()
  1545. return nil
  1546. case agent.FieldOrganizationID:
  1547. m.ResetOrganizationID()
  1548. return nil
  1549. case agent.FieldDatasetID:
  1550. m.ResetDatasetID()
  1551. return nil
  1552. case agent.FieldCollectionID:
  1553. m.ResetCollectionID()
  1554. return nil
  1555. case agent.FieldModel:
  1556. m.ResetModel()
  1557. return nil
  1558. case agent.FieldAPIBase:
  1559. m.ResetAPIBase()
  1560. return nil
  1561. case agent.FieldAPIKey:
  1562. m.ResetAPIKey()
  1563. return nil
  1564. case agent.FieldType:
  1565. m.ResetType()
  1566. return nil
  1567. }
  1568. return fmt.Errorf("unknown Agent field %s", name)
  1569. }
  1570. // AddedEdges returns all edge names that were set/added in this mutation.
  1571. func (m *AgentMutation) AddedEdges() []string {
  1572. edges := make([]string, 0, 5)
  1573. if m.wx_agent != nil {
  1574. edges = append(edges, agent.EdgeWxAgent)
  1575. }
  1576. if m.token_agent != nil {
  1577. edges = append(edges, agent.EdgeTokenAgent)
  1578. }
  1579. if m.wa_agent != nil {
  1580. edges = append(edges, agent.EdgeWaAgent)
  1581. }
  1582. if m.xjs_agent != nil {
  1583. edges = append(edges, agent.EdgeXjsAgent)
  1584. }
  1585. if m.key_agent != nil {
  1586. edges = append(edges, agent.EdgeKeyAgent)
  1587. }
  1588. return edges
  1589. }
  1590. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1591. // name in this mutation.
  1592. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1593. switch name {
  1594. case agent.EdgeWxAgent:
  1595. ids := make([]ent.Value, 0, len(m.wx_agent))
  1596. for id := range m.wx_agent {
  1597. ids = append(ids, id)
  1598. }
  1599. return ids
  1600. case agent.EdgeTokenAgent:
  1601. ids := make([]ent.Value, 0, len(m.token_agent))
  1602. for id := range m.token_agent {
  1603. ids = append(ids, id)
  1604. }
  1605. return ids
  1606. case agent.EdgeWaAgent:
  1607. ids := make([]ent.Value, 0, len(m.wa_agent))
  1608. for id := range m.wa_agent {
  1609. ids = append(ids, id)
  1610. }
  1611. return ids
  1612. case agent.EdgeXjsAgent:
  1613. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1614. for id := range m.xjs_agent {
  1615. ids = append(ids, id)
  1616. }
  1617. return ids
  1618. case agent.EdgeKeyAgent:
  1619. ids := make([]ent.Value, 0, len(m.key_agent))
  1620. for id := range m.key_agent {
  1621. ids = append(ids, id)
  1622. }
  1623. return ids
  1624. }
  1625. return nil
  1626. }
  1627. // RemovedEdges returns all edge names that were removed in this mutation.
  1628. func (m *AgentMutation) RemovedEdges() []string {
  1629. edges := make([]string, 0, 5)
  1630. if m.removedwx_agent != nil {
  1631. edges = append(edges, agent.EdgeWxAgent)
  1632. }
  1633. if m.removedtoken_agent != nil {
  1634. edges = append(edges, agent.EdgeTokenAgent)
  1635. }
  1636. if m.removedwa_agent != nil {
  1637. edges = append(edges, agent.EdgeWaAgent)
  1638. }
  1639. if m.removedxjs_agent != nil {
  1640. edges = append(edges, agent.EdgeXjsAgent)
  1641. }
  1642. if m.removedkey_agent != nil {
  1643. edges = append(edges, agent.EdgeKeyAgent)
  1644. }
  1645. return edges
  1646. }
  1647. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1648. // the given name in this mutation.
  1649. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1650. switch name {
  1651. case agent.EdgeWxAgent:
  1652. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1653. for id := range m.removedwx_agent {
  1654. ids = append(ids, id)
  1655. }
  1656. return ids
  1657. case agent.EdgeTokenAgent:
  1658. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1659. for id := range m.removedtoken_agent {
  1660. ids = append(ids, id)
  1661. }
  1662. return ids
  1663. case agent.EdgeWaAgent:
  1664. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1665. for id := range m.removedwa_agent {
  1666. ids = append(ids, id)
  1667. }
  1668. return ids
  1669. case agent.EdgeXjsAgent:
  1670. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1671. for id := range m.removedxjs_agent {
  1672. ids = append(ids, id)
  1673. }
  1674. return ids
  1675. case agent.EdgeKeyAgent:
  1676. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1677. for id := range m.removedkey_agent {
  1678. ids = append(ids, id)
  1679. }
  1680. return ids
  1681. }
  1682. return nil
  1683. }
  1684. // ClearedEdges returns all edge names that were cleared in this mutation.
  1685. func (m *AgentMutation) ClearedEdges() []string {
  1686. edges := make([]string, 0, 5)
  1687. if m.clearedwx_agent {
  1688. edges = append(edges, agent.EdgeWxAgent)
  1689. }
  1690. if m.clearedtoken_agent {
  1691. edges = append(edges, agent.EdgeTokenAgent)
  1692. }
  1693. if m.clearedwa_agent {
  1694. edges = append(edges, agent.EdgeWaAgent)
  1695. }
  1696. if m.clearedxjs_agent {
  1697. edges = append(edges, agent.EdgeXjsAgent)
  1698. }
  1699. if m.clearedkey_agent {
  1700. edges = append(edges, agent.EdgeKeyAgent)
  1701. }
  1702. return edges
  1703. }
  1704. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1705. // was cleared in this mutation.
  1706. func (m *AgentMutation) EdgeCleared(name string) bool {
  1707. switch name {
  1708. case agent.EdgeWxAgent:
  1709. return m.clearedwx_agent
  1710. case agent.EdgeTokenAgent:
  1711. return m.clearedtoken_agent
  1712. case agent.EdgeWaAgent:
  1713. return m.clearedwa_agent
  1714. case agent.EdgeXjsAgent:
  1715. return m.clearedxjs_agent
  1716. case agent.EdgeKeyAgent:
  1717. return m.clearedkey_agent
  1718. }
  1719. return false
  1720. }
  1721. // ClearEdge clears the value of the edge with the given name. It returns an error
  1722. // if that edge is not defined in the schema.
  1723. func (m *AgentMutation) ClearEdge(name string) error {
  1724. switch name {
  1725. }
  1726. return fmt.Errorf("unknown Agent unique edge %s", name)
  1727. }
  1728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1729. // It returns an error if the edge is not defined in the schema.
  1730. func (m *AgentMutation) ResetEdge(name string) error {
  1731. switch name {
  1732. case agent.EdgeWxAgent:
  1733. m.ResetWxAgent()
  1734. return nil
  1735. case agent.EdgeTokenAgent:
  1736. m.ResetTokenAgent()
  1737. return nil
  1738. case agent.EdgeWaAgent:
  1739. m.ResetWaAgent()
  1740. return nil
  1741. case agent.EdgeXjsAgent:
  1742. m.ResetXjsAgent()
  1743. return nil
  1744. case agent.EdgeKeyAgent:
  1745. m.ResetKeyAgent()
  1746. return nil
  1747. }
  1748. return fmt.Errorf("unknown Agent edge %s", name)
  1749. }
  1750. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1751. type AgentBaseMutation struct {
  1752. config
  1753. op Op
  1754. typ string
  1755. id *string
  1756. q *string
  1757. a *string
  1758. chunk_index *uint64
  1759. addchunk_index *int64
  1760. indexes *[]string
  1761. appendindexes []string
  1762. dataset_id *string
  1763. collection_id *string
  1764. source_name *string
  1765. can_write *[]bool
  1766. appendcan_write []bool
  1767. is_owner *[]bool
  1768. appendis_owner []bool
  1769. clearedFields map[string]struct{}
  1770. wx_agent map[uint64]struct{}
  1771. removedwx_agent map[uint64]struct{}
  1772. clearedwx_agent bool
  1773. done bool
  1774. oldValue func(context.Context) (*AgentBase, error)
  1775. predicates []predicate.AgentBase
  1776. }
  1777. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1778. // agentbaseOption allows management of the mutation configuration using functional options.
  1779. type agentbaseOption func(*AgentBaseMutation)
  1780. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1781. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1782. m := &AgentBaseMutation{
  1783. config: c,
  1784. op: op,
  1785. typ: TypeAgentBase,
  1786. clearedFields: make(map[string]struct{}),
  1787. }
  1788. for _, opt := range opts {
  1789. opt(m)
  1790. }
  1791. return m
  1792. }
  1793. // withAgentBaseID sets the ID field of the mutation.
  1794. func withAgentBaseID(id string) agentbaseOption {
  1795. return func(m *AgentBaseMutation) {
  1796. var (
  1797. err error
  1798. once sync.Once
  1799. value *AgentBase
  1800. )
  1801. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1802. once.Do(func() {
  1803. if m.done {
  1804. err = errors.New("querying old values post mutation is not allowed")
  1805. } else {
  1806. value, err = m.Client().AgentBase.Get(ctx, id)
  1807. }
  1808. })
  1809. return value, err
  1810. }
  1811. m.id = &id
  1812. }
  1813. }
  1814. // withAgentBase sets the old AgentBase of the mutation.
  1815. func withAgentBase(node *AgentBase) agentbaseOption {
  1816. return func(m *AgentBaseMutation) {
  1817. m.oldValue = func(context.Context) (*AgentBase, error) {
  1818. return node, nil
  1819. }
  1820. m.id = &node.ID
  1821. }
  1822. }
  1823. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1824. // executed in a transaction (ent.Tx), a transactional client is returned.
  1825. func (m AgentBaseMutation) Client() *Client {
  1826. client := &Client{config: m.config}
  1827. client.init()
  1828. return client
  1829. }
  1830. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1831. // it returns an error otherwise.
  1832. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1833. if _, ok := m.driver.(*txDriver); !ok {
  1834. return nil, errors.New("ent: mutation is not running in a transaction")
  1835. }
  1836. tx := &Tx{config: m.config}
  1837. tx.init()
  1838. return tx, nil
  1839. }
  1840. // SetID sets the value of the id field. Note that this
  1841. // operation is only accepted on creation of AgentBase entities.
  1842. func (m *AgentBaseMutation) SetID(id string) {
  1843. m.id = &id
  1844. }
  1845. // ID returns the ID value in the mutation. Note that the ID is only available
  1846. // if it was provided to the builder or after it was returned from the database.
  1847. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1848. if m.id == nil {
  1849. return
  1850. }
  1851. return *m.id, true
  1852. }
  1853. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1854. // That means, if the mutation is applied within a transaction with an isolation level such
  1855. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1856. // or updated by the mutation.
  1857. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1858. switch {
  1859. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1860. id, exists := m.ID()
  1861. if exists {
  1862. return []string{id}, nil
  1863. }
  1864. fallthrough
  1865. case m.op.Is(OpUpdate | OpDelete):
  1866. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1867. default:
  1868. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1869. }
  1870. }
  1871. // SetQ sets the "q" field.
  1872. func (m *AgentBaseMutation) SetQ(s string) {
  1873. m.q = &s
  1874. }
  1875. // Q returns the value of the "q" field in the mutation.
  1876. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1877. v := m.q
  1878. if v == nil {
  1879. return
  1880. }
  1881. return *v, true
  1882. }
  1883. // OldQ returns the old "q" field's value of the AgentBase entity.
  1884. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1886. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1887. if !m.op.Is(OpUpdateOne) {
  1888. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1889. }
  1890. if m.id == nil || m.oldValue == nil {
  1891. return v, errors.New("OldQ requires an ID field in the mutation")
  1892. }
  1893. oldValue, err := m.oldValue(ctx)
  1894. if err != nil {
  1895. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1896. }
  1897. return oldValue.Q, nil
  1898. }
  1899. // ClearQ clears the value of the "q" field.
  1900. func (m *AgentBaseMutation) ClearQ() {
  1901. m.q = nil
  1902. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1903. }
  1904. // QCleared returns if the "q" field was cleared in this mutation.
  1905. func (m *AgentBaseMutation) QCleared() bool {
  1906. _, ok := m.clearedFields[agentbase.FieldQ]
  1907. return ok
  1908. }
  1909. // ResetQ resets all changes to the "q" field.
  1910. func (m *AgentBaseMutation) ResetQ() {
  1911. m.q = nil
  1912. delete(m.clearedFields, agentbase.FieldQ)
  1913. }
  1914. // SetA sets the "a" field.
  1915. func (m *AgentBaseMutation) SetA(s string) {
  1916. m.a = &s
  1917. }
  1918. // A returns the value of the "a" field in the mutation.
  1919. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1920. v := m.a
  1921. if v == nil {
  1922. return
  1923. }
  1924. return *v, true
  1925. }
  1926. // OldA returns the old "a" field's value of the AgentBase entity.
  1927. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1929. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1930. if !m.op.Is(OpUpdateOne) {
  1931. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1932. }
  1933. if m.id == nil || m.oldValue == nil {
  1934. return v, errors.New("OldA requires an ID field in the mutation")
  1935. }
  1936. oldValue, err := m.oldValue(ctx)
  1937. if err != nil {
  1938. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1939. }
  1940. return oldValue.A, nil
  1941. }
  1942. // ClearA clears the value of the "a" field.
  1943. func (m *AgentBaseMutation) ClearA() {
  1944. m.a = nil
  1945. m.clearedFields[agentbase.FieldA] = struct{}{}
  1946. }
  1947. // ACleared returns if the "a" field was cleared in this mutation.
  1948. func (m *AgentBaseMutation) ACleared() bool {
  1949. _, ok := m.clearedFields[agentbase.FieldA]
  1950. return ok
  1951. }
  1952. // ResetA resets all changes to the "a" field.
  1953. func (m *AgentBaseMutation) ResetA() {
  1954. m.a = nil
  1955. delete(m.clearedFields, agentbase.FieldA)
  1956. }
  1957. // SetChunkIndex sets the "chunk_index" field.
  1958. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1959. m.chunk_index = &u
  1960. m.addchunk_index = nil
  1961. }
  1962. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1963. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1964. v := m.chunk_index
  1965. if v == nil {
  1966. return
  1967. }
  1968. return *v, true
  1969. }
  1970. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1971. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1973. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1974. if !m.op.Is(OpUpdateOne) {
  1975. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1976. }
  1977. if m.id == nil || m.oldValue == nil {
  1978. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1979. }
  1980. oldValue, err := m.oldValue(ctx)
  1981. if err != nil {
  1982. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1983. }
  1984. return oldValue.ChunkIndex, nil
  1985. }
  1986. // AddChunkIndex adds u to the "chunk_index" field.
  1987. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1988. if m.addchunk_index != nil {
  1989. *m.addchunk_index += u
  1990. } else {
  1991. m.addchunk_index = &u
  1992. }
  1993. }
  1994. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1995. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1996. v := m.addchunk_index
  1997. if v == nil {
  1998. return
  1999. }
  2000. return *v, true
  2001. }
  2002. // ResetChunkIndex resets all changes to the "chunk_index" field.
  2003. func (m *AgentBaseMutation) ResetChunkIndex() {
  2004. m.chunk_index = nil
  2005. m.addchunk_index = nil
  2006. }
  2007. // SetIndexes sets the "indexes" field.
  2008. func (m *AgentBaseMutation) SetIndexes(s []string) {
  2009. m.indexes = &s
  2010. m.appendindexes = nil
  2011. }
  2012. // Indexes returns the value of the "indexes" field in the mutation.
  2013. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  2014. v := m.indexes
  2015. if v == nil {
  2016. return
  2017. }
  2018. return *v, true
  2019. }
  2020. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  2021. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2023. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  2024. if !m.op.Is(OpUpdateOne) {
  2025. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  2026. }
  2027. if m.id == nil || m.oldValue == nil {
  2028. return v, errors.New("OldIndexes requires an ID field in the mutation")
  2029. }
  2030. oldValue, err := m.oldValue(ctx)
  2031. if err != nil {
  2032. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  2033. }
  2034. return oldValue.Indexes, nil
  2035. }
  2036. // AppendIndexes adds s to the "indexes" field.
  2037. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  2038. m.appendindexes = append(m.appendindexes, s...)
  2039. }
  2040. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  2041. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  2042. if len(m.appendindexes) == 0 {
  2043. return nil, false
  2044. }
  2045. return m.appendindexes, true
  2046. }
  2047. // ClearIndexes clears the value of the "indexes" field.
  2048. func (m *AgentBaseMutation) ClearIndexes() {
  2049. m.indexes = nil
  2050. m.appendindexes = nil
  2051. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  2052. }
  2053. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  2054. func (m *AgentBaseMutation) IndexesCleared() bool {
  2055. _, ok := m.clearedFields[agentbase.FieldIndexes]
  2056. return ok
  2057. }
  2058. // ResetIndexes resets all changes to the "indexes" field.
  2059. func (m *AgentBaseMutation) ResetIndexes() {
  2060. m.indexes = nil
  2061. m.appendindexes = nil
  2062. delete(m.clearedFields, agentbase.FieldIndexes)
  2063. }
  2064. // SetDatasetID sets the "dataset_id" field.
  2065. func (m *AgentBaseMutation) SetDatasetID(s string) {
  2066. m.dataset_id = &s
  2067. }
  2068. // DatasetID returns the value of the "dataset_id" field in the mutation.
  2069. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  2070. v := m.dataset_id
  2071. if v == nil {
  2072. return
  2073. }
  2074. return *v, true
  2075. }
  2076. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  2077. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2079. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2080. if !m.op.Is(OpUpdateOne) {
  2081. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2082. }
  2083. if m.id == nil || m.oldValue == nil {
  2084. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2085. }
  2086. oldValue, err := m.oldValue(ctx)
  2087. if err != nil {
  2088. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2089. }
  2090. return oldValue.DatasetID, nil
  2091. }
  2092. // ClearDatasetID clears the value of the "dataset_id" field.
  2093. func (m *AgentBaseMutation) ClearDatasetID() {
  2094. m.dataset_id = nil
  2095. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2096. }
  2097. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2098. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2099. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2100. return ok
  2101. }
  2102. // ResetDatasetID resets all changes to the "dataset_id" field.
  2103. func (m *AgentBaseMutation) ResetDatasetID() {
  2104. m.dataset_id = nil
  2105. delete(m.clearedFields, agentbase.FieldDatasetID)
  2106. }
  2107. // SetCollectionID sets the "collection_id" field.
  2108. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2109. m.collection_id = &s
  2110. }
  2111. // CollectionID returns the value of the "collection_id" field in the mutation.
  2112. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2113. v := m.collection_id
  2114. if v == nil {
  2115. return
  2116. }
  2117. return *v, true
  2118. }
  2119. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2120. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2122. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2123. if !m.op.Is(OpUpdateOne) {
  2124. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2125. }
  2126. if m.id == nil || m.oldValue == nil {
  2127. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2128. }
  2129. oldValue, err := m.oldValue(ctx)
  2130. if err != nil {
  2131. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2132. }
  2133. return oldValue.CollectionID, nil
  2134. }
  2135. // ClearCollectionID clears the value of the "collection_id" field.
  2136. func (m *AgentBaseMutation) ClearCollectionID() {
  2137. m.collection_id = nil
  2138. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2139. }
  2140. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2141. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2142. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2143. return ok
  2144. }
  2145. // ResetCollectionID resets all changes to the "collection_id" field.
  2146. func (m *AgentBaseMutation) ResetCollectionID() {
  2147. m.collection_id = nil
  2148. delete(m.clearedFields, agentbase.FieldCollectionID)
  2149. }
  2150. // SetSourceName sets the "source_name" field.
  2151. func (m *AgentBaseMutation) SetSourceName(s string) {
  2152. m.source_name = &s
  2153. }
  2154. // SourceName returns the value of the "source_name" field in the mutation.
  2155. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2156. v := m.source_name
  2157. if v == nil {
  2158. return
  2159. }
  2160. return *v, true
  2161. }
  2162. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2163. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2165. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2166. if !m.op.Is(OpUpdateOne) {
  2167. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2168. }
  2169. if m.id == nil || m.oldValue == nil {
  2170. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2171. }
  2172. oldValue, err := m.oldValue(ctx)
  2173. if err != nil {
  2174. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2175. }
  2176. return oldValue.SourceName, nil
  2177. }
  2178. // ClearSourceName clears the value of the "source_name" field.
  2179. func (m *AgentBaseMutation) ClearSourceName() {
  2180. m.source_name = nil
  2181. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2182. }
  2183. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2184. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2185. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2186. return ok
  2187. }
  2188. // ResetSourceName resets all changes to the "source_name" field.
  2189. func (m *AgentBaseMutation) ResetSourceName() {
  2190. m.source_name = nil
  2191. delete(m.clearedFields, agentbase.FieldSourceName)
  2192. }
  2193. // SetCanWrite sets the "can_write" field.
  2194. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2195. m.can_write = &b
  2196. m.appendcan_write = nil
  2197. }
  2198. // CanWrite returns the value of the "can_write" field in the mutation.
  2199. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2200. v := m.can_write
  2201. if v == nil {
  2202. return
  2203. }
  2204. return *v, true
  2205. }
  2206. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2207. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2209. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2210. if !m.op.Is(OpUpdateOne) {
  2211. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2212. }
  2213. if m.id == nil || m.oldValue == nil {
  2214. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2215. }
  2216. oldValue, err := m.oldValue(ctx)
  2217. if err != nil {
  2218. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2219. }
  2220. return oldValue.CanWrite, nil
  2221. }
  2222. // AppendCanWrite adds b to the "can_write" field.
  2223. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2224. m.appendcan_write = append(m.appendcan_write, b...)
  2225. }
  2226. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2227. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2228. if len(m.appendcan_write) == 0 {
  2229. return nil, false
  2230. }
  2231. return m.appendcan_write, true
  2232. }
  2233. // ClearCanWrite clears the value of the "can_write" field.
  2234. func (m *AgentBaseMutation) ClearCanWrite() {
  2235. m.can_write = nil
  2236. m.appendcan_write = nil
  2237. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2238. }
  2239. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2240. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2241. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2242. return ok
  2243. }
  2244. // ResetCanWrite resets all changes to the "can_write" field.
  2245. func (m *AgentBaseMutation) ResetCanWrite() {
  2246. m.can_write = nil
  2247. m.appendcan_write = nil
  2248. delete(m.clearedFields, agentbase.FieldCanWrite)
  2249. }
  2250. // SetIsOwner sets the "is_owner" field.
  2251. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2252. m.is_owner = &b
  2253. m.appendis_owner = nil
  2254. }
  2255. // IsOwner returns the value of the "is_owner" field in the mutation.
  2256. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2257. v := m.is_owner
  2258. if v == nil {
  2259. return
  2260. }
  2261. return *v, true
  2262. }
  2263. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2264. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2266. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2267. if !m.op.Is(OpUpdateOne) {
  2268. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2269. }
  2270. if m.id == nil || m.oldValue == nil {
  2271. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2272. }
  2273. oldValue, err := m.oldValue(ctx)
  2274. if err != nil {
  2275. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2276. }
  2277. return oldValue.IsOwner, nil
  2278. }
  2279. // AppendIsOwner adds b to the "is_owner" field.
  2280. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2281. m.appendis_owner = append(m.appendis_owner, b...)
  2282. }
  2283. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2284. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2285. if len(m.appendis_owner) == 0 {
  2286. return nil, false
  2287. }
  2288. return m.appendis_owner, true
  2289. }
  2290. // ClearIsOwner clears the value of the "is_owner" field.
  2291. func (m *AgentBaseMutation) ClearIsOwner() {
  2292. m.is_owner = nil
  2293. m.appendis_owner = nil
  2294. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2295. }
  2296. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2297. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2298. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2299. return ok
  2300. }
  2301. // ResetIsOwner resets all changes to the "is_owner" field.
  2302. func (m *AgentBaseMutation) ResetIsOwner() {
  2303. m.is_owner = nil
  2304. m.appendis_owner = nil
  2305. delete(m.clearedFields, agentbase.FieldIsOwner)
  2306. }
  2307. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2308. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2309. if m.wx_agent == nil {
  2310. m.wx_agent = make(map[uint64]struct{})
  2311. }
  2312. for i := range ids {
  2313. m.wx_agent[ids[i]] = struct{}{}
  2314. }
  2315. }
  2316. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2317. func (m *AgentBaseMutation) ClearWxAgent() {
  2318. m.clearedwx_agent = true
  2319. }
  2320. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2321. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2322. return m.clearedwx_agent
  2323. }
  2324. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2325. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2326. if m.removedwx_agent == nil {
  2327. m.removedwx_agent = make(map[uint64]struct{})
  2328. }
  2329. for i := range ids {
  2330. delete(m.wx_agent, ids[i])
  2331. m.removedwx_agent[ids[i]] = struct{}{}
  2332. }
  2333. }
  2334. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2335. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2336. for id := range m.removedwx_agent {
  2337. ids = append(ids, id)
  2338. }
  2339. return
  2340. }
  2341. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2342. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2343. for id := range m.wx_agent {
  2344. ids = append(ids, id)
  2345. }
  2346. return
  2347. }
  2348. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2349. func (m *AgentBaseMutation) ResetWxAgent() {
  2350. m.wx_agent = nil
  2351. m.clearedwx_agent = false
  2352. m.removedwx_agent = nil
  2353. }
  2354. // Where appends a list predicates to the AgentBaseMutation builder.
  2355. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2356. m.predicates = append(m.predicates, ps...)
  2357. }
  2358. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2359. // users can use type-assertion to append predicates that do not depend on any generated package.
  2360. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2361. p := make([]predicate.AgentBase, len(ps))
  2362. for i := range ps {
  2363. p[i] = ps[i]
  2364. }
  2365. m.Where(p...)
  2366. }
  2367. // Op returns the operation name.
  2368. func (m *AgentBaseMutation) Op() Op {
  2369. return m.op
  2370. }
  2371. // SetOp allows setting the mutation operation.
  2372. func (m *AgentBaseMutation) SetOp(op Op) {
  2373. m.op = op
  2374. }
  2375. // Type returns the node type of this mutation (AgentBase).
  2376. func (m *AgentBaseMutation) Type() string {
  2377. return m.typ
  2378. }
  2379. // Fields returns all fields that were changed during this mutation. Note that in
  2380. // order to get all numeric fields that were incremented/decremented, call
  2381. // AddedFields().
  2382. func (m *AgentBaseMutation) Fields() []string {
  2383. fields := make([]string, 0, 9)
  2384. if m.q != nil {
  2385. fields = append(fields, agentbase.FieldQ)
  2386. }
  2387. if m.a != nil {
  2388. fields = append(fields, agentbase.FieldA)
  2389. }
  2390. if m.chunk_index != nil {
  2391. fields = append(fields, agentbase.FieldChunkIndex)
  2392. }
  2393. if m.indexes != nil {
  2394. fields = append(fields, agentbase.FieldIndexes)
  2395. }
  2396. if m.dataset_id != nil {
  2397. fields = append(fields, agentbase.FieldDatasetID)
  2398. }
  2399. if m.collection_id != nil {
  2400. fields = append(fields, agentbase.FieldCollectionID)
  2401. }
  2402. if m.source_name != nil {
  2403. fields = append(fields, agentbase.FieldSourceName)
  2404. }
  2405. if m.can_write != nil {
  2406. fields = append(fields, agentbase.FieldCanWrite)
  2407. }
  2408. if m.is_owner != nil {
  2409. fields = append(fields, agentbase.FieldIsOwner)
  2410. }
  2411. return fields
  2412. }
  2413. // Field returns the value of a field with the given name. The second boolean
  2414. // return value indicates that this field was not set, or was not defined in the
  2415. // schema.
  2416. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2417. switch name {
  2418. case agentbase.FieldQ:
  2419. return m.Q()
  2420. case agentbase.FieldA:
  2421. return m.A()
  2422. case agentbase.FieldChunkIndex:
  2423. return m.ChunkIndex()
  2424. case agentbase.FieldIndexes:
  2425. return m.Indexes()
  2426. case agentbase.FieldDatasetID:
  2427. return m.DatasetID()
  2428. case agentbase.FieldCollectionID:
  2429. return m.CollectionID()
  2430. case agentbase.FieldSourceName:
  2431. return m.SourceName()
  2432. case agentbase.FieldCanWrite:
  2433. return m.CanWrite()
  2434. case agentbase.FieldIsOwner:
  2435. return m.IsOwner()
  2436. }
  2437. return nil, false
  2438. }
  2439. // OldField returns the old value of the field from the database. An error is
  2440. // returned if the mutation operation is not UpdateOne, or the query to the
  2441. // database failed.
  2442. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2443. switch name {
  2444. case agentbase.FieldQ:
  2445. return m.OldQ(ctx)
  2446. case agentbase.FieldA:
  2447. return m.OldA(ctx)
  2448. case agentbase.FieldChunkIndex:
  2449. return m.OldChunkIndex(ctx)
  2450. case agentbase.FieldIndexes:
  2451. return m.OldIndexes(ctx)
  2452. case agentbase.FieldDatasetID:
  2453. return m.OldDatasetID(ctx)
  2454. case agentbase.FieldCollectionID:
  2455. return m.OldCollectionID(ctx)
  2456. case agentbase.FieldSourceName:
  2457. return m.OldSourceName(ctx)
  2458. case agentbase.FieldCanWrite:
  2459. return m.OldCanWrite(ctx)
  2460. case agentbase.FieldIsOwner:
  2461. return m.OldIsOwner(ctx)
  2462. }
  2463. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2464. }
  2465. // SetField sets the value of a field with the given name. It returns an error if
  2466. // the field is not defined in the schema, or if the type mismatched the field
  2467. // type.
  2468. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2469. switch name {
  2470. case agentbase.FieldQ:
  2471. v, ok := value.(string)
  2472. if !ok {
  2473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2474. }
  2475. m.SetQ(v)
  2476. return nil
  2477. case agentbase.FieldA:
  2478. v, ok := value.(string)
  2479. if !ok {
  2480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2481. }
  2482. m.SetA(v)
  2483. return nil
  2484. case agentbase.FieldChunkIndex:
  2485. v, ok := value.(uint64)
  2486. if !ok {
  2487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2488. }
  2489. m.SetChunkIndex(v)
  2490. return nil
  2491. case agentbase.FieldIndexes:
  2492. v, ok := value.([]string)
  2493. if !ok {
  2494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2495. }
  2496. m.SetIndexes(v)
  2497. return nil
  2498. case agentbase.FieldDatasetID:
  2499. v, ok := value.(string)
  2500. if !ok {
  2501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2502. }
  2503. m.SetDatasetID(v)
  2504. return nil
  2505. case agentbase.FieldCollectionID:
  2506. v, ok := value.(string)
  2507. if !ok {
  2508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2509. }
  2510. m.SetCollectionID(v)
  2511. return nil
  2512. case agentbase.FieldSourceName:
  2513. v, ok := value.(string)
  2514. if !ok {
  2515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2516. }
  2517. m.SetSourceName(v)
  2518. return nil
  2519. case agentbase.FieldCanWrite:
  2520. v, ok := value.([]bool)
  2521. if !ok {
  2522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2523. }
  2524. m.SetCanWrite(v)
  2525. return nil
  2526. case agentbase.FieldIsOwner:
  2527. v, ok := value.([]bool)
  2528. if !ok {
  2529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2530. }
  2531. m.SetIsOwner(v)
  2532. return nil
  2533. }
  2534. return fmt.Errorf("unknown AgentBase field %s", name)
  2535. }
  2536. // AddedFields returns all numeric fields that were incremented/decremented during
  2537. // this mutation.
  2538. func (m *AgentBaseMutation) AddedFields() []string {
  2539. var fields []string
  2540. if m.addchunk_index != nil {
  2541. fields = append(fields, agentbase.FieldChunkIndex)
  2542. }
  2543. return fields
  2544. }
  2545. // AddedField returns the numeric value that was incremented/decremented on a field
  2546. // with the given name. The second boolean return value indicates that this field
  2547. // was not set, or was not defined in the schema.
  2548. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2549. switch name {
  2550. case agentbase.FieldChunkIndex:
  2551. return m.AddedChunkIndex()
  2552. }
  2553. return nil, false
  2554. }
  2555. // AddField adds the value to the field with the given name. It returns an error if
  2556. // the field is not defined in the schema, or if the type mismatched the field
  2557. // type.
  2558. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2559. switch name {
  2560. case agentbase.FieldChunkIndex:
  2561. v, ok := value.(int64)
  2562. if !ok {
  2563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2564. }
  2565. m.AddChunkIndex(v)
  2566. return nil
  2567. }
  2568. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2569. }
  2570. // ClearedFields returns all nullable fields that were cleared during this
  2571. // mutation.
  2572. func (m *AgentBaseMutation) ClearedFields() []string {
  2573. var fields []string
  2574. if m.FieldCleared(agentbase.FieldQ) {
  2575. fields = append(fields, agentbase.FieldQ)
  2576. }
  2577. if m.FieldCleared(agentbase.FieldA) {
  2578. fields = append(fields, agentbase.FieldA)
  2579. }
  2580. if m.FieldCleared(agentbase.FieldIndexes) {
  2581. fields = append(fields, agentbase.FieldIndexes)
  2582. }
  2583. if m.FieldCleared(agentbase.FieldDatasetID) {
  2584. fields = append(fields, agentbase.FieldDatasetID)
  2585. }
  2586. if m.FieldCleared(agentbase.FieldCollectionID) {
  2587. fields = append(fields, agentbase.FieldCollectionID)
  2588. }
  2589. if m.FieldCleared(agentbase.FieldSourceName) {
  2590. fields = append(fields, agentbase.FieldSourceName)
  2591. }
  2592. if m.FieldCleared(agentbase.FieldCanWrite) {
  2593. fields = append(fields, agentbase.FieldCanWrite)
  2594. }
  2595. if m.FieldCleared(agentbase.FieldIsOwner) {
  2596. fields = append(fields, agentbase.FieldIsOwner)
  2597. }
  2598. return fields
  2599. }
  2600. // FieldCleared returns a boolean indicating if a field with the given name was
  2601. // cleared in this mutation.
  2602. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2603. _, ok := m.clearedFields[name]
  2604. return ok
  2605. }
  2606. // ClearField clears the value of the field with the given name. It returns an
  2607. // error if the field is not defined in the schema.
  2608. func (m *AgentBaseMutation) ClearField(name string) error {
  2609. switch name {
  2610. case agentbase.FieldQ:
  2611. m.ClearQ()
  2612. return nil
  2613. case agentbase.FieldA:
  2614. m.ClearA()
  2615. return nil
  2616. case agentbase.FieldIndexes:
  2617. m.ClearIndexes()
  2618. return nil
  2619. case agentbase.FieldDatasetID:
  2620. m.ClearDatasetID()
  2621. return nil
  2622. case agentbase.FieldCollectionID:
  2623. m.ClearCollectionID()
  2624. return nil
  2625. case agentbase.FieldSourceName:
  2626. m.ClearSourceName()
  2627. return nil
  2628. case agentbase.FieldCanWrite:
  2629. m.ClearCanWrite()
  2630. return nil
  2631. case agentbase.FieldIsOwner:
  2632. m.ClearIsOwner()
  2633. return nil
  2634. }
  2635. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2636. }
  2637. // ResetField resets all changes in the mutation for the field with the given name.
  2638. // It returns an error if the field is not defined in the schema.
  2639. func (m *AgentBaseMutation) ResetField(name string) error {
  2640. switch name {
  2641. case agentbase.FieldQ:
  2642. m.ResetQ()
  2643. return nil
  2644. case agentbase.FieldA:
  2645. m.ResetA()
  2646. return nil
  2647. case agentbase.FieldChunkIndex:
  2648. m.ResetChunkIndex()
  2649. return nil
  2650. case agentbase.FieldIndexes:
  2651. m.ResetIndexes()
  2652. return nil
  2653. case agentbase.FieldDatasetID:
  2654. m.ResetDatasetID()
  2655. return nil
  2656. case agentbase.FieldCollectionID:
  2657. m.ResetCollectionID()
  2658. return nil
  2659. case agentbase.FieldSourceName:
  2660. m.ResetSourceName()
  2661. return nil
  2662. case agentbase.FieldCanWrite:
  2663. m.ResetCanWrite()
  2664. return nil
  2665. case agentbase.FieldIsOwner:
  2666. m.ResetIsOwner()
  2667. return nil
  2668. }
  2669. return fmt.Errorf("unknown AgentBase field %s", name)
  2670. }
  2671. // AddedEdges returns all edge names that were set/added in this mutation.
  2672. func (m *AgentBaseMutation) AddedEdges() []string {
  2673. edges := make([]string, 0, 1)
  2674. if m.wx_agent != nil {
  2675. edges = append(edges, agentbase.EdgeWxAgent)
  2676. }
  2677. return edges
  2678. }
  2679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2680. // name in this mutation.
  2681. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2682. switch name {
  2683. case agentbase.EdgeWxAgent:
  2684. ids := make([]ent.Value, 0, len(m.wx_agent))
  2685. for id := range m.wx_agent {
  2686. ids = append(ids, id)
  2687. }
  2688. return ids
  2689. }
  2690. return nil
  2691. }
  2692. // RemovedEdges returns all edge names that were removed in this mutation.
  2693. func (m *AgentBaseMutation) RemovedEdges() []string {
  2694. edges := make([]string, 0, 1)
  2695. if m.removedwx_agent != nil {
  2696. edges = append(edges, agentbase.EdgeWxAgent)
  2697. }
  2698. return edges
  2699. }
  2700. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2701. // the given name in this mutation.
  2702. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2703. switch name {
  2704. case agentbase.EdgeWxAgent:
  2705. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2706. for id := range m.removedwx_agent {
  2707. ids = append(ids, id)
  2708. }
  2709. return ids
  2710. }
  2711. return nil
  2712. }
  2713. // ClearedEdges returns all edge names that were cleared in this mutation.
  2714. func (m *AgentBaseMutation) ClearedEdges() []string {
  2715. edges := make([]string, 0, 1)
  2716. if m.clearedwx_agent {
  2717. edges = append(edges, agentbase.EdgeWxAgent)
  2718. }
  2719. return edges
  2720. }
  2721. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2722. // was cleared in this mutation.
  2723. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2724. switch name {
  2725. case agentbase.EdgeWxAgent:
  2726. return m.clearedwx_agent
  2727. }
  2728. return false
  2729. }
  2730. // ClearEdge clears the value of the edge with the given name. It returns an error
  2731. // if that edge is not defined in the schema.
  2732. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2733. switch name {
  2734. }
  2735. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2736. }
  2737. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2738. // It returns an error if the edge is not defined in the schema.
  2739. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2740. switch name {
  2741. case agentbase.EdgeWxAgent:
  2742. m.ResetWxAgent()
  2743. return nil
  2744. }
  2745. return fmt.Errorf("unknown AgentBase edge %s", name)
  2746. }
  2747. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2748. type AliyunAvatarMutation struct {
  2749. config
  2750. op Op
  2751. typ string
  2752. id *uint64
  2753. created_at *time.Time
  2754. updated_at *time.Time
  2755. deleted_at *time.Time
  2756. user_id *uint64
  2757. adduser_id *int64
  2758. biz_id *string
  2759. access_key_id *string
  2760. access_key_secret *string
  2761. app_id *string
  2762. tenant_id *uint64
  2763. addtenant_id *int64
  2764. response *string
  2765. token *string
  2766. session_id *string
  2767. clearedFields map[string]struct{}
  2768. done bool
  2769. oldValue func(context.Context) (*AliyunAvatar, error)
  2770. predicates []predicate.AliyunAvatar
  2771. }
  2772. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2773. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2774. type aliyunavatarOption func(*AliyunAvatarMutation)
  2775. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2776. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2777. m := &AliyunAvatarMutation{
  2778. config: c,
  2779. op: op,
  2780. typ: TypeAliyunAvatar,
  2781. clearedFields: make(map[string]struct{}),
  2782. }
  2783. for _, opt := range opts {
  2784. opt(m)
  2785. }
  2786. return m
  2787. }
  2788. // withAliyunAvatarID sets the ID field of the mutation.
  2789. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2790. return func(m *AliyunAvatarMutation) {
  2791. var (
  2792. err error
  2793. once sync.Once
  2794. value *AliyunAvatar
  2795. )
  2796. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2797. once.Do(func() {
  2798. if m.done {
  2799. err = errors.New("querying old values post mutation is not allowed")
  2800. } else {
  2801. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2802. }
  2803. })
  2804. return value, err
  2805. }
  2806. m.id = &id
  2807. }
  2808. }
  2809. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2810. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2811. return func(m *AliyunAvatarMutation) {
  2812. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2813. return node, nil
  2814. }
  2815. m.id = &node.ID
  2816. }
  2817. }
  2818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2819. // executed in a transaction (ent.Tx), a transactional client is returned.
  2820. func (m AliyunAvatarMutation) Client() *Client {
  2821. client := &Client{config: m.config}
  2822. client.init()
  2823. return client
  2824. }
  2825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2826. // it returns an error otherwise.
  2827. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2828. if _, ok := m.driver.(*txDriver); !ok {
  2829. return nil, errors.New("ent: mutation is not running in a transaction")
  2830. }
  2831. tx := &Tx{config: m.config}
  2832. tx.init()
  2833. return tx, nil
  2834. }
  2835. // SetID sets the value of the id field. Note that this
  2836. // operation is only accepted on creation of AliyunAvatar entities.
  2837. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2838. m.id = &id
  2839. }
  2840. // ID returns the ID value in the mutation. Note that the ID is only available
  2841. // if it was provided to the builder or after it was returned from the database.
  2842. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2843. if m.id == nil {
  2844. return
  2845. }
  2846. return *m.id, true
  2847. }
  2848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2849. // That means, if the mutation is applied within a transaction with an isolation level such
  2850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2851. // or updated by the mutation.
  2852. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2853. switch {
  2854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2855. id, exists := m.ID()
  2856. if exists {
  2857. return []uint64{id}, nil
  2858. }
  2859. fallthrough
  2860. case m.op.Is(OpUpdate | OpDelete):
  2861. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2862. default:
  2863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2864. }
  2865. }
  2866. // SetCreatedAt sets the "created_at" field.
  2867. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2868. m.created_at = &t
  2869. }
  2870. // CreatedAt returns the value of the "created_at" field in the mutation.
  2871. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2872. v := m.created_at
  2873. if v == nil {
  2874. return
  2875. }
  2876. return *v, true
  2877. }
  2878. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2879. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2881. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2882. if !m.op.Is(OpUpdateOne) {
  2883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2884. }
  2885. if m.id == nil || m.oldValue == nil {
  2886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2887. }
  2888. oldValue, err := m.oldValue(ctx)
  2889. if err != nil {
  2890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2891. }
  2892. return oldValue.CreatedAt, nil
  2893. }
  2894. // ResetCreatedAt resets all changes to the "created_at" field.
  2895. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2896. m.created_at = nil
  2897. }
  2898. // SetUpdatedAt sets the "updated_at" field.
  2899. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2900. m.updated_at = &t
  2901. }
  2902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2903. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2904. v := m.updated_at
  2905. if v == nil {
  2906. return
  2907. }
  2908. return *v, true
  2909. }
  2910. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2911. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2913. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2914. if !m.op.Is(OpUpdateOne) {
  2915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2916. }
  2917. if m.id == nil || m.oldValue == nil {
  2918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2919. }
  2920. oldValue, err := m.oldValue(ctx)
  2921. if err != nil {
  2922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2923. }
  2924. return oldValue.UpdatedAt, nil
  2925. }
  2926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2927. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2928. m.updated_at = nil
  2929. }
  2930. // SetDeletedAt sets the "deleted_at" field.
  2931. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2932. m.deleted_at = &t
  2933. }
  2934. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2935. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2936. v := m.deleted_at
  2937. if v == nil {
  2938. return
  2939. }
  2940. return *v, true
  2941. }
  2942. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2943. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2945. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2946. if !m.op.Is(OpUpdateOne) {
  2947. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2948. }
  2949. if m.id == nil || m.oldValue == nil {
  2950. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2951. }
  2952. oldValue, err := m.oldValue(ctx)
  2953. if err != nil {
  2954. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2955. }
  2956. return oldValue.DeletedAt, nil
  2957. }
  2958. // ClearDeletedAt clears the value of the "deleted_at" field.
  2959. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2960. m.deleted_at = nil
  2961. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2962. }
  2963. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2964. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2965. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2966. return ok
  2967. }
  2968. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2969. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2970. m.deleted_at = nil
  2971. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2972. }
  2973. // SetUserID sets the "user_id" field.
  2974. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2975. m.user_id = &u
  2976. m.adduser_id = nil
  2977. }
  2978. // UserID returns the value of the "user_id" field in the mutation.
  2979. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2980. v := m.user_id
  2981. if v == nil {
  2982. return
  2983. }
  2984. return *v, true
  2985. }
  2986. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2987. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2989. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2990. if !m.op.Is(OpUpdateOne) {
  2991. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2992. }
  2993. if m.id == nil || m.oldValue == nil {
  2994. return v, errors.New("OldUserID requires an ID field in the mutation")
  2995. }
  2996. oldValue, err := m.oldValue(ctx)
  2997. if err != nil {
  2998. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2999. }
  3000. return oldValue.UserID, nil
  3001. }
  3002. // AddUserID adds u to the "user_id" field.
  3003. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  3004. if m.adduser_id != nil {
  3005. *m.adduser_id += u
  3006. } else {
  3007. m.adduser_id = &u
  3008. }
  3009. }
  3010. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  3011. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  3012. v := m.adduser_id
  3013. if v == nil {
  3014. return
  3015. }
  3016. return *v, true
  3017. }
  3018. // ResetUserID resets all changes to the "user_id" field.
  3019. func (m *AliyunAvatarMutation) ResetUserID() {
  3020. m.user_id = nil
  3021. m.adduser_id = nil
  3022. }
  3023. // SetBizID sets the "biz_id" field.
  3024. func (m *AliyunAvatarMutation) SetBizID(s string) {
  3025. m.biz_id = &s
  3026. }
  3027. // BizID returns the value of the "biz_id" field in the mutation.
  3028. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  3029. v := m.biz_id
  3030. if v == nil {
  3031. return
  3032. }
  3033. return *v, true
  3034. }
  3035. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  3036. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3038. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  3039. if !m.op.Is(OpUpdateOne) {
  3040. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  3041. }
  3042. if m.id == nil || m.oldValue == nil {
  3043. return v, errors.New("OldBizID requires an ID field in the mutation")
  3044. }
  3045. oldValue, err := m.oldValue(ctx)
  3046. if err != nil {
  3047. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  3048. }
  3049. return oldValue.BizID, nil
  3050. }
  3051. // ResetBizID resets all changes to the "biz_id" field.
  3052. func (m *AliyunAvatarMutation) ResetBizID() {
  3053. m.biz_id = nil
  3054. }
  3055. // SetAccessKeyID sets the "access_key_id" field.
  3056. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  3057. m.access_key_id = &s
  3058. }
  3059. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  3060. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  3061. v := m.access_key_id
  3062. if v == nil {
  3063. return
  3064. }
  3065. return *v, true
  3066. }
  3067. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  3068. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3070. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  3071. if !m.op.Is(OpUpdateOne) {
  3072. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  3073. }
  3074. if m.id == nil || m.oldValue == nil {
  3075. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  3076. }
  3077. oldValue, err := m.oldValue(ctx)
  3078. if err != nil {
  3079. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3080. }
  3081. return oldValue.AccessKeyID, nil
  3082. }
  3083. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3084. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3085. m.access_key_id = nil
  3086. }
  3087. // SetAccessKeySecret sets the "access_key_secret" field.
  3088. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3089. m.access_key_secret = &s
  3090. }
  3091. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3092. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3093. v := m.access_key_secret
  3094. if v == nil {
  3095. return
  3096. }
  3097. return *v, true
  3098. }
  3099. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3100. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3102. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3103. if !m.op.Is(OpUpdateOne) {
  3104. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3105. }
  3106. if m.id == nil || m.oldValue == nil {
  3107. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3108. }
  3109. oldValue, err := m.oldValue(ctx)
  3110. if err != nil {
  3111. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3112. }
  3113. return oldValue.AccessKeySecret, nil
  3114. }
  3115. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3116. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3117. m.access_key_secret = nil
  3118. }
  3119. // SetAppID sets the "app_id" field.
  3120. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3121. m.app_id = &s
  3122. }
  3123. // AppID returns the value of the "app_id" field in the mutation.
  3124. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3125. v := m.app_id
  3126. if v == nil {
  3127. return
  3128. }
  3129. return *v, true
  3130. }
  3131. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3132. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3134. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3135. if !m.op.Is(OpUpdateOne) {
  3136. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3137. }
  3138. if m.id == nil || m.oldValue == nil {
  3139. return v, errors.New("OldAppID requires an ID field in the mutation")
  3140. }
  3141. oldValue, err := m.oldValue(ctx)
  3142. if err != nil {
  3143. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3144. }
  3145. return oldValue.AppID, nil
  3146. }
  3147. // ClearAppID clears the value of the "app_id" field.
  3148. func (m *AliyunAvatarMutation) ClearAppID() {
  3149. m.app_id = nil
  3150. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3151. }
  3152. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3153. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3154. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3155. return ok
  3156. }
  3157. // ResetAppID resets all changes to the "app_id" field.
  3158. func (m *AliyunAvatarMutation) ResetAppID() {
  3159. m.app_id = nil
  3160. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3161. }
  3162. // SetTenantID sets the "tenant_id" field.
  3163. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3164. m.tenant_id = &u
  3165. m.addtenant_id = nil
  3166. }
  3167. // TenantID returns the value of the "tenant_id" field in the mutation.
  3168. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3169. v := m.tenant_id
  3170. if v == nil {
  3171. return
  3172. }
  3173. return *v, true
  3174. }
  3175. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3176. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3178. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3179. if !m.op.Is(OpUpdateOne) {
  3180. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3181. }
  3182. if m.id == nil || m.oldValue == nil {
  3183. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3184. }
  3185. oldValue, err := m.oldValue(ctx)
  3186. if err != nil {
  3187. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3188. }
  3189. return oldValue.TenantID, nil
  3190. }
  3191. // AddTenantID adds u to the "tenant_id" field.
  3192. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3193. if m.addtenant_id != nil {
  3194. *m.addtenant_id += u
  3195. } else {
  3196. m.addtenant_id = &u
  3197. }
  3198. }
  3199. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3200. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3201. v := m.addtenant_id
  3202. if v == nil {
  3203. return
  3204. }
  3205. return *v, true
  3206. }
  3207. // ResetTenantID resets all changes to the "tenant_id" field.
  3208. func (m *AliyunAvatarMutation) ResetTenantID() {
  3209. m.tenant_id = nil
  3210. m.addtenant_id = nil
  3211. }
  3212. // SetResponse sets the "response" field.
  3213. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3214. m.response = &s
  3215. }
  3216. // Response returns the value of the "response" field in the mutation.
  3217. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3218. v := m.response
  3219. if v == nil {
  3220. return
  3221. }
  3222. return *v, true
  3223. }
  3224. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3225. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3227. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3228. if !m.op.Is(OpUpdateOne) {
  3229. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3230. }
  3231. if m.id == nil || m.oldValue == nil {
  3232. return v, errors.New("OldResponse requires an ID field in the mutation")
  3233. }
  3234. oldValue, err := m.oldValue(ctx)
  3235. if err != nil {
  3236. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3237. }
  3238. return oldValue.Response, nil
  3239. }
  3240. // ResetResponse resets all changes to the "response" field.
  3241. func (m *AliyunAvatarMutation) ResetResponse() {
  3242. m.response = nil
  3243. }
  3244. // SetToken sets the "token" field.
  3245. func (m *AliyunAvatarMutation) SetToken(s string) {
  3246. m.token = &s
  3247. }
  3248. // Token returns the value of the "token" field in the mutation.
  3249. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3250. v := m.token
  3251. if v == nil {
  3252. return
  3253. }
  3254. return *v, true
  3255. }
  3256. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3257. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3259. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3260. if !m.op.Is(OpUpdateOne) {
  3261. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3262. }
  3263. if m.id == nil || m.oldValue == nil {
  3264. return v, errors.New("OldToken requires an ID field in the mutation")
  3265. }
  3266. oldValue, err := m.oldValue(ctx)
  3267. if err != nil {
  3268. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3269. }
  3270. return oldValue.Token, nil
  3271. }
  3272. // ResetToken resets all changes to the "token" field.
  3273. func (m *AliyunAvatarMutation) ResetToken() {
  3274. m.token = nil
  3275. }
  3276. // SetSessionID sets the "session_id" field.
  3277. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3278. m.session_id = &s
  3279. }
  3280. // SessionID returns the value of the "session_id" field in the mutation.
  3281. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3282. v := m.session_id
  3283. if v == nil {
  3284. return
  3285. }
  3286. return *v, true
  3287. }
  3288. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3289. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3291. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3292. if !m.op.Is(OpUpdateOne) {
  3293. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3294. }
  3295. if m.id == nil || m.oldValue == nil {
  3296. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3297. }
  3298. oldValue, err := m.oldValue(ctx)
  3299. if err != nil {
  3300. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3301. }
  3302. return oldValue.SessionID, nil
  3303. }
  3304. // ResetSessionID resets all changes to the "session_id" field.
  3305. func (m *AliyunAvatarMutation) ResetSessionID() {
  3306. m.session_id = nil
  3307. }
  3308. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3309. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3310. m.predicates = append(m.predicates, ps...)
  3311. }
  3312. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3313. // users can use type-assertion to append predicates that do not depend on any generated package.
  3314. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3315. p := make([]predicate.AliyunAvatar, len(ps))
  3316. for i := range ps {
  3317. p[i] = ps[i]
  3318. }
  3319. m.Where(p...)
  3320. }
  3321. // Op returns the operation name.
  3322. func (m *AliyunAvatarMutation) Op() Op {
  3323. return m.op
  3324. }
  3325. // SetOp allows setting the mutation operation.
  3326. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3327. m.op = op
  3328. }
  3329. // Type returns the node type of this mutation (AliyunAvatar).
  3330. func (m *AliyunAvatarMutation) Type() string {
  3331. return m.typ
  3332. }
  3333. // Fields returns all fields that were changed during this mutation. Note that in
  3334. // order to get all numeric fields that were incremented/decremented, call
  3335. // AddedFields().
  3336. func (m *AliyunAvatarMutation) Fields() []string {
  3337. fields := make([]string, 0, 12)
  3338. if m.created_at != nil {
  3339. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3340. }
  3341. if m.updated_at != nil {
  3342. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3343. }
  3344. if m.deleted_at != nil {
  3345. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3346. }
  3347. if m.user_id != nil {
  3348. fields = append(fields, aliyunavatar.FieldUserID)
  3349. }
  3350. if m.biz_id != nil {
  3351. fields = append(fields, aliyunavatar.FieldBizID)
  3352. }
  3353. if m.access_key_id != nil {
  3354. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3355. }
  3356. if m.access_key_secret != nil {
  3357. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3358. }
  3359. if m.app_id != nil {
  3360. fields = append(fields, aliyunavatar.FieldAppID)
  3361. }
  3362. if m.tenant_id != nil {
  3363. fields = append(fields, aliyunavatar.FieldTenantID)
  3364. }
  3365. if m.response != nil {
  3366. fields = append(fields, aliyunavatar.FieldResponse)
  3367. }
  3368. if m.token != nil {
  3369. fields = append(fields, aliyunavatar.FieldToken)
  3370. }
  3371. if m.session_id != nil {
  3372. fields = append(fields, aliyunavatar.FieldSessionID)
  3373. }
  3374. return fields
  3375. }
  3376. // Field returns the value of a field with the given name. The second boolean
  3377. // return value indicates that this field was not set, or was not defined in the
  3378. // schema.
  3379. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3380. switch name {
  3381. case aliyunavatar.FieldCreatedAt:
  3382. return m.CreatedAt()
  3383. case aliyunavatar.FieldUpdatedAt:
  3384. return m.UpdatedAt()
  3385. case aliyunavatar.FieldDeletedAt:
  3386. return m.DeletedAt()
  3387. case aliyunavatar.FieldUserID:
  3388. return m.UserID()
  3389. case aliyunavatar.FieldBizID:
  3390. return m.BizID()
  3391. case aliyunavatar.FieldAccessKeyID:
  3392. return m.AccessKeyID()
  3393. case aliyunavatar.FieldAccessKeySecret:
  3394. return m.AccessKeySecret()
  3395. case aliyunavatar.FieldAppID:
  3396. return m.AppID()
  3397. case aliyunavatar.FieldTenantID:
  3398. return m.TenantID()
  3399. case aliyunavatar.FieldResponse:
  3400. return m.Response()
  3401. case aliyunavatar.FieldToken:
  3402. return m.Token()
  3403. case aliyunavatar.FieldSessionID:
  3404. return m.SessionID()
  3405. }
  3406. return nil, false
  3407. }
  3408. // OldField returns the old value of the field from the database. An error is
  3409. // returned if the mutation operation is not UpdateOne, or the query to the
  3410. // database failed.
  3411. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3412. switch name {
  3413. case aliyunavatar.FieldCreatedAt:
  3414. return m.OldCreatedAt(ctx)
  3415. case aliyunavatar.FieldUpdatedAt:
  3416. return m.OldUpdatedAt(ctx)
  3417. case aliyunavatar.FieldDeletedAt:
  3418. return m.OldDeletedAt(ctx)
  3419. case aliyunavatar.FieldUserID:
  3420. return m.OldUserID(ctx)
  3421. case aliyunavatar.FieldBizID:
  3422. return m.OldBizID(ctx)
  3423. case aliyunavatar.FieldAccessKeyID:
  3424. return m.OldAccessKeyID(ctx)
  3425. case aliyunavatar.FieldAccessKeySecret:
  3426. return m.OldAccessKeySecret(ctx)
  3427. case aliyunavatar.FieldAppID:
  3428. return m.OldAppID(ctx)
  3429. case aliyunavatar.FieldTenantID:
  3430. return m.OldTenantID(ctx)
  3431. case aliyunavatar.FieldResponse:
  3432. return m.OldResponse(ctx)
  3433. case aliyunavatar.FieldToken:
  3434. return m.OldToken(ctx)
  3435. case aliyunavatar.FieldSessionID:
  3436. return m.OldSessionID(ctx)
  3437. }
  3438. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3439. }
  3440. // SetField sets the value of a field with the given name. It returns an error if
  3441. // the field is not defined in the schema, or if the type mismatched the field
  3442. // type.
  3443. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3444. switch name {
  3445. case aliyunavatar.FieldCreatedAt:
  3446. v, ok := value.(time.Time)
  3447. if !ok {
  3448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3449. }
  3450. m.SetCreatedAt(v)
  3451. return nil
  3452. case aliyunavatar.FieldUpdatedAt:
  3453. v, ok := value.(time.Time)
  3454. if !ok {
  3455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3456. }
  3457. m.SetUpdatedAt(v)
  3458. return nil
  3459. case aliyunavatar.FieldDeletedAt:
  3460. v, ok := value.(time.Time)
  3461. if !ok {
  3462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3463. }
  3464. m.SetDeletedAt(v)
  3465. return nil
  3466. case aliyunavatar.FieldUserID:
  3467. v, ok := value.(uint64)
  3468. if !ok {
  3469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3470. }
  3471. m.SetUserID(v)
  3472. return nil
  3473. case aliyunavatar.FieldBizID:
  3474. v, ok := value.(string)
  3475. if !ok {
  3476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3477. }
  3478. m.SetBizID(v)
  3479. return nil
  3480. case aliyunavatar.FieldAccessKeyID:
  3481. v, ok := value.(string)
  3482. if !ok {
  3483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3484. }
  3485. m.SetAccessKeyID(v)
  3486. return nil
  3487. case aliyunavatar.FieldAccessKeySecret:
  3488. v, ok := value.(string)
  3489. if !ok {
  3490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3491. }
  3492. m.SetAccessKeySecret(v)
  3493. return nil
  3494. case aliyunavatar.FieldAppID:
  3495. v, ok := value.(string)
  3496. if !ok {
  3497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3498. }
  3499. m.SetAppID(v)
  3500. return nil
  3501. case aliyunavatar.FieldTenantID:
  3502. v, ok := value.(uint64)
  3503. if !ok {
  3504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3505. }
  3506. m.SetTenantID(v)
  3507. return nil
  3508. case aliyunavatar.FieldResponse:
  3509. v, ok := value.(string)
  3510. if !ok {
  3511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3512. }
  3513. m.SetResponse(v)
  3514. return nil
  3515. case aliyunavatar.FieldToken:
  3516. v, ok := value.(string)
  3517. if !ok {
  3518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3519. }
  3520. m.SetToken(v)
  3521. return nil
  3522. case aliyunavatar.FieldSessionID:
  3523. v, ok := value.(string)
  3524. if !ok {
  3525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3526. }
  3527. m.SetSessionID(v)
  3528. return nil
  3529. }
  3530. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3531. }
  3532. // AddedFields returns all numeric fields that were incremented/decremented during
  3533. // this mutation.
  3534. func (m *AliyunAvatarMutation) AddedFields() []string {
  3535. var fields []string
  3536. if m.adduser_id != nil {
  3537. fields = append(fields, aliyunavatar.FieldUserID)
  3538. }
  3539. if m.addtenant_id != nil {
  3540. fields = append(fields, aliyunavatar.FieldTenantID)
  3541. }
  3542. return fields
  3543. }
  3544. // AddedField returns the numeric value that was incremented/decremented on a field
  3545. // with the given name. The second boolean return value indicates that this field
  3546. // was not set, or was not defined in the schema.
  3547. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3548. switch name {
  3549. case aliyunavatar.FieldUserID:
  3550. return m.AddedUserID()
  3551. case aliyunavatar.FieldTenantID:
  3552. return m.AddedTenantID()
  3553. }
  3554. return nil, false
  3555. }
  3556. // AddField adds the value to the field with the given name. It returns an error if
  3557. // the field is not defined in the schema, or if the type mismatched the field
  3558. // type.
  3559. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3560. switch name {
  3561. case aliyunavatar.FieldUserID:
  3562. v, ok := value.(int64)
  3563. if !ok {
  3564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3565. }
  3566. m.AddUserID(v)
  3567. return nil
  3568. case aliyunavatar.FieldTenantID:
  3569. v, ok := value.(int64)
  3570. if !ok {
  3571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3572. }
  3573. m.AddTenantID(v)
  3574. return nil
  3575. }
  3576. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3577. }
  3578. // ClearedFields returns all nullable fields that were cleared during this
  3579. // mutation.
  3580. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3581. var fields []string
  3582. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3583. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3584. }
  3585. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3586. fields = append(fields, aliyunavatar.FieldAppID)
  3587. }
  3588. return fields
  3589. }
  3590. // FieldCleared returns a boolean indicating if a field with the given name was
  3591. // cleared in this mutation.
  3592. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3593. _, ok := m.clearedFields[name]
  3594. return ok
  3595. }
  3596. // ClearField clears the value of the field with the given name. It returns an
  3597. // error if the field is not defined in the schema.
  3598. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3599. switch name {
  3600. case aliyunavatar.FieldDeletedAt:
  3601. m.ClearDeletedAt()
  3602. return nil
  3603. case aliyunavatar.FieldAppID:
  3604. m.ClearAppID()
  3605. return nil
  3606. }
  3607. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3608. }
  3609. // ResetField resets all changes in the mutation for the field with the given name.
  3610. // It returns an error if the field is not defined in the schema.
  3611. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3612. switch name {
  3613. case aliyunavatar.FieldCreatedAt:
  3614. m.ResetCreatedAt()
  3615. return nil
  3616. case aliyunavatar.FieldUpdatedAt:
  3617. m.ResetUpdatedAt()
  3618. return nil
  3619. case aliyunavatar.FieldDeletedAt:
  3620. m.ResetDeletedAt()
  3621. return nil
  3622. case aliyunavatar.FieldUserID:
  3623. m.ResetUserID()
  3624. return nil
  3625. case aliyunavatar.FieldBizID:
  3626. m.ResetBizID()
  3627. return nil
  3628. case aliyunavatar.FieldAccessKeyID:
  3629. m.ResetAccessKeyID()
  3630. return nil
  3631. case aliyunavatar.FieldAccessKeySecret:
  3632. m.ResetAccessKeySecret()
  3633. return nil
  3634. case aliyunavatar.FieldAppID:
  3635. m.ResetAppID()
  3636. return nil
  3637. case aliyunavatar.FieldTenantID:
  3638. m.ResetTenantID()
  3639. return nil
  3640. case aliyunavatar.FieldResponse:
  3641. m.ResetResponse()
  3642. return nil
  3643. case aliyunavatar.FieldToken:
  3644. m.ResetToken()
  3645. return nil
  3646. case aliyunavatar.FieldSessionID:
  3647. m.ResetSessionID()
  3648. return nil
  3649. }
  3650. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3651. }
  3652. // AddedEdges returns all edge names that were set/added in this mutation.
  3653. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3654. edges := make([]string, 0, 0)
  3655. return edges
  3656. }
  3657. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3658. // name in this mutation.
  3659. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3660. return nil
  3661. }
  3662. // RemovedEdges returns all edge names that were removed in this mutation.
  3663. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3664. edges := make([]string, 0, 0)
  3665. return edges
  3666. }
  3667. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3668. // the given name in this mutation.
  3669. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3670. return nil
  3671. }
  3672. // ClearedEdges returns all edge names that were cleared in this mutation.
  3673. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3674. edges := make([]string, 0, 0)
  3675. return edges
  3676. }
  3677. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3678. // was cleared in this mutation.
  3679. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3680. return false
  3681. }
  3682. // ClearEdge clears the value of the edge with the given name. It returns an error
  3683. // if that edge is not defined in the schema.
  3684. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3685. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3686. }
  3687. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3688. // It returns an error if the edge is not defined in the schema.
  3689. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3690. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3691. }
  3692. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3693. type AllocAgentMutation struct {
  3694. config
  3695. op Op
  3696. typ string
  3697. id *uint64
  3698. created_at *time.Time
  3699. updated_at *time.Time
  3700. deleted_at *time.Time
  3701. user_id *string
  3702. organization_id *uint64
  3703. addorganization_id *int64
  3704. agents *[]uint64
  3705. appendagents []uint64
  3706. status *int
  3707. addstatus *int
  3708. clearedFields map[string]struct{}
  3709. done bool
  3710. oldValue func(context.Context) (*AllocAgent, error)
  3711. predicates []predicate.AllocAgent
  3712. }
  3713. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3714. // allocagentOption allows management of the mutation configuration using functional options.
  3715. type allocagentOption func(*AllocAgentMutation)
  3716. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3717. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3718. m := &AllocAgentMutation{
  3719. config: c,
  3720. op: op,
  3721. typ: TypeAllocAgent,
  3722. clearedFields: make(map[string]struct{}),
  3723. }
  3724. for _, opt := range opts {
  3725. opt(m)
  3726. }
  3727. return m
  3728. }
  3729. // withAllocAgentID sets the ID field of the mutation.
  3730. func withAllocAgentID(id uint64) allocagentOption {
  3731. return func(m *AllocAgentMutation) {
  3732. var (
  3733. err error
  3734. once sync.Once
  3735. value *AllocAgent
  3736. )
  3737. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3738. once.Do(func() {
  3739. if m.done {
  3740. err = errors.New("querying old values post mutation is not allowed")
  3741. } else {
  3742. value, err = m.Client().AllocAgent.Get(ctx, id)
  3743. }
  3744. })
  3745. return value, err
  3746. }
  3747. m.id = &id
  3748. }
  3749. }
  3750. // withAllocAgent sets the old AllocAgent of the mutation.
  3751. func withAllocAgent(node *AllocAgent) allocagentOption {
  3752. return func(m *AllocAgentMutation) {
  3753. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3754. return node, nil
  3755. }
  3756. m.id = &node.ID
  3757. }
  3758. }
  3759. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3760. // executed in a transaction (ent.Tx), a transactional client is returned.
  3761. func (m AllocAgentMutation) Client() *Client {
  3762. client := &Client{config: m.config}
  3763. client.init()
  3764. return client
  3765. }
  3766. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3767. // it returns an error otherwise.
  3768. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3769. if _, ok := m.driver.(*txDriver); !ok {
  3770. return nil, errors.New("ent: mutation is not running in a transaction")
  3771. }
  3772. tx := &Tx{config: m.config}
  3773. tx.init()
  3774. return tx, nil
  3775. }
  3776. // SetID sets the value of the id field. Note that this
  3777. // operation is only accepted on creation of AllocAgent entities.
  3778. func (m *AllocAgentMutation) SetID(id uint64) {
  3779. m.id = &id
  3780. }
  3781. // ID returns the ID value in the mutation. Note that the ID is only available
  3782. // if it was provided to the builder or after it was returned from the database.
  3783. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3784. if m.id == nil {
  3785. return
  3786. }
  3787. return *m.id, true
  3788. }
  3789. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3790. // That means, if the mutation is applied within a transaction with an isolation level such
  3791. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3792. // or updated by the mutation.
  3793. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3794. switch {
  3795. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3796. id, exists := m.ID()
  3797. if exists {
  3798. return []uint64{id}, nil
  3799. }
  3800. fallthrough
  3801. case m.op.Is(OpUpdate | OpDelete):
  3802. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3803. default:
  3804. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3805. }
  3806. }
  3807. // SetCreatedAt sets the "created_at" field.
  3808. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3809. m.created_at = &t
  3810. }
  3811. // CreatedAt returns the value of the "created_at" field in the mutation.
  3812. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3813. v := m.created_at
  3814. if v == nil {
  3815. return
  3816. }
  3817. return *v, true
  3818. }
  3819. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3820. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3822. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3823. if !m.op.Is(OpUpdateOne) {
  3824. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3825. }
  3826. if m.id == nil || m.oldValue == nil {
  3827. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3828. }
  3829. oldValue, err := m.oldValue(ctx)
  3830. if err != nil {
  3831. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3832. }
  3833. return oldValue.CreatedAt, nil
  3834. }
  3835. // ResetCreatedAt resets all changes to the "created_at" field.
  3836. func (m *AllocAgentMutation) ResetCreatedAt() {
  3837. m.created_at = nil
  3838. }
  3839. // SetUpdatedAt sets the "updated_at" field.
  3840. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3841. m.updated_at = &t
  3842. }
  3843. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3844. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3845. v := m.updated_at
  3846. if v == nil {
  3847. return
  3848. }
  3849. return *v, true
  3850. }
  3851. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3852. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3854. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3855. if !m.op.Is(OpUpdateOne) {
  3856. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3857. }
  3858. if m.id == nil || m.oldValue == nil {
  3859. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3860. }
  3861. oldValue, err := m.oldValue(ctx)
  3862. if err != nil {
  3863. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3864. }
  3865. return oldValue.UpdatedAt, nil
  3866. }
  3867. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3868. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3869. m.updated_at = nil
  3870. }
  3871. // SetDeletedAt sets the "deleted_at" field.
  3872. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3873. m.deleted_at = &t
  3874. }
  3875. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3876. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3877. v := m.deleted_at
  3878. if v == nil {
  3879. return
  3880. }
  3881. return *v, true
  3882. }
  3883. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3884. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3886. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3887. if !m.op.Is(OpUpdateOne) {
  3888. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3889. }
  3890. if m.id == nil || m.oldValue == nil {
  3891. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3892. }
  3893. oldValue, err := m.oldValue(ctx)
  3894. if err != nil {
  3895. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3896. }
  3897. return oldValue.DeletedAt, nil
  3898. }
  3899. // ClearDeletedAt clears the value of the "deleted_at" field.
  3900. func (m *AllocAgentMutation) ClearDeletedAt() {
  3901. m.deleted_at = nil
  3902. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3903. }
  3904. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3905. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3906. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3907. return ok
  3908. }
  3909. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3910. func (m *AllocAgentMutation) ResetDeletedAt() {
  3911. m.deleted_at = nil
  3912. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3913. }
  3914. // SetUserID sets the "user_id" field.
  3915. func (m *AllocAgentMutation) SetUserID(s string) {
  3916. m.user_id = &s
  3917. }
  3918. // UserID returns the value of the "user_id" field in the mutation.
  3919. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3920. v := m.user_id
  3921. if v == nil {
  3922. return
  3923. }
  3924. return *v, true
  3925. }
  3926. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3927. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3929. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3930. if !m.op.Is(OpUpdateOne) {
  3931. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3932. }
  3933. if m.id == nil || m.oldValue == nil {
  3934. return v, errors.New("OldUserID requires an ID field in the mutation")
  3935. }
  3936. oldValue, err := m.oldValue(ctx)
  3937. if err != nil {
  3938. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3939. }
  3940. return oldValue.UserID, nil
  3941. }
  3942. // ClearUserID clears the value of the "user_id" field.
  3943. func (m *AllocAgentMutation) ClearUserID() {
  3944. m.user_id = nil
  3945. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3946. }
  3947. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3948. func (m *AllocAgentMutation) UserIDCleared() bool {
  3949. _, ok := m.clearedFields[allocagent.FieldUserID]
  3950. return ok
  3951. }
  3952. // ResetUserID resets all changes to the "user_id" field.
  3953. func (m *AllocAgentMutation) ResetUserID() {
  3954. m.user_id = nil
  3955. delete(m.clearedFields, allocagent.FieldUserID)
  3956. }
  3957. // SetOrganizationID sets the "organization_id" field.
  3958. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3959. m.organization_id = &u
  3960. m.addorganization_id = nil
  3961. }
  3962. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3963. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3964. v := m.organization_id
  3965. if v == nil {
  3966. return
  3967. }
  3968. return *v, true
  3969. }
  3970. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3971. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3973. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3974. if !m.op.Is(OpUpdateOne) {
  3975. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3976. }
  3977. if m.id == nil || m.oldValue == nil {
  3978. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3979. }
  3980. oldValue, err := m.oldValue(ctx)
  3981. if err != nil {
  3982. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3983. }
  3984. return oldValue.OrganizationID, nil
  3985. }
  3986. // AddOrganizationID adds u to the "organization_id" field.
  3987. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3988. if m.addorganization_id != nil {
  3989. *m.addorganization_id += u
  3990. } else {
  3991. m.addorganization_id = &u
  3992. }
  3993. }
  3994. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3995. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3996. v := m.addorganization_id
  3997. if v == nil {
  3998. return
  3999. }
  4000. return *v, true
  4001. }
  4002. // ClearOrganizationID clears the value of the "organization_id" field.
  4003. func (m *AllocAgentMutation) ClearOrganizationID() {
  4004. m.organization_id = nil
  4005. m.addorganization_id = nil
  4006. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  4007. }
  4008. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4009. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  4010. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  4011. return ok
  4012. }
  4013. // ResetOrganizationID resets all changes to the "organization_id" field.
  4014. func (m *AllocAgentMutation) ResetOrganizationID() {
  4015. m.organization_id = nil
  4016. m.addorganization_id = nil
  4017. delete(m.clearedFields, allocagent.FieldOrganizationID)
  4018. }
  4019. // SetAgents sets the "agents" field.
  4020. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  4021. m.agents = &u
  4022. m.appendagents = nil
  4023. }
  4024. // Agents returns the value of the "agents" field in the mutation.
  4025. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  4026. v := m.agents
  4027. if v == nil {
  4028. return
  4029. }
  4030. return *v, true
  4031. }
  4032. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  4033. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4035. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  4036. if !m.op.Is(OpUpdateOne) {
  4037. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  4038. }
  4039. if m.id == nil || m.oldValue == nil {
  4040. return v, errors.New("OldAgents requires an ID field in the mutation")
  4041. }
  4042. oldValue, err := m.oldValue(ctx)
  4043. if err != nil {
  4044. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  4045. }
  4046. return oldValue.Agents, nil
  4047. }
  4048. // AppendAgents adds u to the "agents" field.
  4049. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  4050. m.appendagents = append(m.appendagents, u...)
  4051. }
  4052. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  4053. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  4054. if len(m.appendagents) == 0 {
  4055. return nil, false
  4056. }
  4057. return m.appendagents, true
  4058. }
  4059. // ResetAgents resets all changes to the "agents" field.
  4060. func (m *AllocAgentMutation) ResetAgents() {
  4061. m.agents = nil
  4062. m.appendagents = nil
  4063. }
  4064. // SetStatus sets the "status" field.
  4065. func (m *AllocAgentMutation) SetStatus(i int) {
  4066. m.status = &i
  4067. m.addstatus = nil
  4068. }
  4069. // Status returns the value of the "status" field in the mutation.
  4070. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  4071. v := m.status
  4072. if v == nil {
  4073. return
  4074. }
  4075. return *v, true
  4076. }
  4077. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4078. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4080. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4081. if !m.op.Is(OpUpdateOne) {
  4082. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4083. }
  4084. if m.id == nil || m.oldValue == nil {
  4085. return v, errors.New("OldStatus requires an ID field in the mutation")
  4086. }
  4087. oldValue, err := m.oldValue(ctx)
  4088. if err != nil {
  4089. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4090. }
  4091. return oldValue.Status, nil
  4092. }
  4093. // AddStatus adds i to the "status" field.
  4094. func (m *AllocAgentMutation) AddStatus(i int) {
  4095. if m.addstatus != nil {
  4096. *m.addstatus += i
  4097. } else {
  4098. m.addstatus = &i
  4099. }
  4100. }
  4101. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4102. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4103. v := m.addstatus
  4104. if v == nil {
  4105. return
  4106. }
  4107. return *v, true
  4108. }
  4109. // ClearStatus clears the value of the "status" field.
  4110. func (m *AllocAgentMutation) ClearStatus() {
  4111. m.status = nil
  4112. m.addstatus = nil
  4113. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4114. }
  4115. // StatusCleared returns if the "status" field was cleared in this mutation.
  4116. func (m *AllocAgentMutation) StatusCleared() bool {
  4117. _, ok := m.clearedFields[allocagent.FieldStatus]
  4118. return ok
  4119. }
  4120. // ResetStatus resets all changes to the "status" field.
  4121. func (m *AllocAgentMutation) ResetStatus() {
  4122. m.status = nil
  4123. m.addstatus = nil
  4124. delete(m.clearedFields, allocagent.FieldStatus)
  4125. }
  4126. // Where appends a list predicates to the AllocAgentMutation builder.
  4127. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4128. m.predicates = append(m.predicates, ps...)
  4129. }
  4130. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4131. // users can use type-assertion to append predicates that do not depend on any generated package.
  4132. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4133. p := make([]predicate.AllocAgent, len(ps))
  4134. for i := range ps {
  4135. p[i] = ps[i]
  4136. }
  4137. m.Where(p...)
  4138. }
  4139. // Op returns the operation name.
  4140. func (m *AllocAgentMutation) Op() Op {
  4141. return m.op
  4142. }
  4143. // SetOp allows setting the mutation operation.
  4144. func (m *AllocAgentMutation) SetOp(op Op) {
  4145. m.op = op
  4146. }
  4147. // Type returns the node type of this mutation (AllocAgent).
  4148. func (m *AllocAgentMutation) Type() string {
  4149. return m.typ
  4150. }
  4151. // Fields returns all fields that were changed during this mutation. Note that in
  4152. // order to get all numeric fields that were incremented/decremented, call
  4153. // AddedFields().
  4154. func (m *AllocAgentMutation) Fields() []string {
  4155. fields := make([]string, 0, 7)
  4156. if m.created_at != nil {
  4157. fields = append(fields, allocagent.FieldCreatedAt)
  4158. }
  4159. if m.updated_at != nil {
  4160. fields = append(fields, allocagent.FieldUpdatedAt)
  4161. }
  4162. if m.deleted_at != nil {
  4163. fields = append(fields, allocagent.FieldDeletedAt)
  4164. }
  4165. if m.user_id != nil {
  4166. fields = append(fields, allocagent.FieldUserID)
  4167. }
  4168. if m.organization_id != nil {
  4169. fields = append(fields, allocagent.FieldOrganizationID)
  4170. }
  4171. if m.agents != nil {
  4172. fields = append(fields, allocagent.FieldAgents)
  4173. }
  4174. if m.status != nil {
  4175. fields = append(fields, allocagent.FieldStatus)
  4176. }
  4177. return fields
  4178. }
  4179. // Field returns the value of a field with the given name. The second boolean
  4180. // return value indicates that this field was not set, or was not defined in the
  4181. // schema.
  4182. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4183. switch name {
  4184. case allocagent.FieldCreatedAt:
  4185. return m.CreatedAt()
  4186. case allocagent.FieldUpdatedAt:
  4187. return m.UpdatedAt()
  4188. case allocagent.FieldDeletedAt:
  4189. return m.DeletedAt()
  4190. case allocagent.FieldUserID:
  4191. return m.UserID()
  4192. case allocagent.FieldOrganizationID:
  4193. return m.OrganizationID()
  4194. case allocagent.FieldAgents:
  4195. return m.Agents()
  4196. case allocagent.FieldStatus:
  4197. return m.Status()
  4198. }
  4199. return nil, false
  4200. }
  4201. // OldField returns the old value of the field from the database. An error is
  4202. // returned if the mutation operation is not UpdateOne, or the query to the
  4203. // database failed.
  4204. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4205. switch name {
  4206. case allocagent.FieldCreatedAt:
  4207. return m.OldCreatedAt(ctx)
  4208. case allocagent.FieldUpdatedAt:
  4209. return m.OldUpdatedAt(ctx)
  4210. case allocagent.FieldDeletedAt:
  4211. return m.OldDeletedAt(ctx)
  4212. case allocagent.FieldUserID:
  4213. return m.OldUserID(ctx)
  4214. case allocagent.FieldOrganizationID:
  4215. return m.OldOrganizationID(ctx)
  4216. case allocagent.FieldAgents:
  4217. return m.OldAgents(ctx)
  4218. case allocagent.FieldStatus:
  4219. return m.OldStatus(ctx)
  4220. }
  4221. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4222. }
  4223. // SetField sets the value of a field with the given name. It returns an error if
  4224. // the field is not defined in the schema, or if the type mismatched the field
  4225. // type.
  4226. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4227. switch name {
  4228. case allocagent.FieldCreatedAt:
  4229. v, ok := value.(time.Time)
  4230. if !ok {
  4231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4232. }
  4233. m.SetCreatedAt(v)
  4234. return nil
  4235. case allocagent.FieldUpdatedAt:
  4236. v, ok := value.(time.Time)
  4237. if !ok {
  4238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4239. }
  4240. m.SetUpdatedAt(v)
  4241. return nil
  4242. case allocagent.FieldDeletedAt:
  4243. v, ok := value.(time.Time)
  4244. if !ok {
  4245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4246. }
  4247. m.SetDeletedAt(v)
  4248. return nil
  4249. case allocagent.FieldUserID:
  4250. v, ok := value.(string)
  4251. if !ok {
  4252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4253. }
  4254. m.SetUserID(v)
  4255. return nil
  4256. case allocagent.FieldOrganizationID:
  4257. v, ok := value.(uint64)
  4258. if !ok {
  4259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4260. }
  4261. m.SetOrganizationID(v)
  4262. return nil
  4263. case allocagent.FieldAgents:
  4264. v, ok := value.([]uint64)
  4265. if !ok {
  4266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4267. }
  4268. m.SetAgents(v)
  4269. return nil
  4270. case allocagent.FieldStatus:
  4271. v, ok := value.(int)
  4272. if !ok {
  4273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4274. }
  4275. m.SetStatus(v)
  4276. return nil
  4277. }
  4278. return fmt.Errorf("unknown AllocAgent field %s", name)
  4279. }
  4280. // AddedFields returns all numeric fields that were incremented/decremented during
  4281. // this mutation.
  4282. func (m *AllocAgentMutation) AddedFields() []string {
  4283. var fields []string
  4284. if m.addorganization_id != nil {
  4285. fields = append(fields, allocagent.FieldOrganizationID)
  4286. }
  4287. if m.addstatus != nil {
  4288. fields = append(fields, allocagent.FieldStatus)
  4289. }
  4290. return fields
  4291. }
  4292. // AddedField returns the numeric value that was incremented/decremented on a field
  4293. // with the given name. The second boolean return value indicates that this field
  4294. // was not set, or was not defined in the schema.
  4295. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4296. switch name {
  4297. case allocagent.FieldOrganizationID:
  4298. return m.AddedOrganizationID()
  4299. case allocagent.FieldStatus:
  4300. return m.AddedStatus()
  4301. }
  4302. return nil, false
  4303. }
  4304. // AddField adds the value to the field with the given name. It returns an error if
  4305. // the field is not defined in the schema, or if the type mismatched the field
  4306. // type.
  4307. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4308. switch name {
  4309. case allocagent.FieldOrganizationID:
  4310. v, ok := value.(int64)
  4311. if !ok {
  4312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4313. }
  4314. m.AddOrganizationID(v)
  4315. return nil
  4316. case allocagent.FieldStatus:
  4317. v, ok := value.(int)
  4318. if !ok {
  4319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4320. }
  4321. m.AddStatus(v)
  4322. return nil
  4323. }
  4324. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4325. }
  4326. // ClearedFields returns all nullable fields that were cleared during this
  4327. // mutation.
  4328. func (m *AllocAgentMutation) ClearedFields() []string {
  4329. var fields []string
  4330. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4331. fields = append(fields, allocagent.FieldDeletedAt)
  4332. }
  4333. if m.FieldCleared(allocagent.FieldUserID) {
  4334. fields = append(fields, allocagent.FieldUserID)
  4335. }
  4336. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4337. fields = append(fields, allocagent.FieldOrganizationID)
  4338. }
  4339. if m.FieldCleared(allocagent.FieldStatus) {
  4340. fields = append(fields, allocagent.FieldStatus)
  4341. }
  4342. return fields
  4343. }
  4344. // FieldCleared returns a boolean indicating if a field with the given name was
  4345. // cleared in this mutation.
  4346. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4347. _, ok := m.clearedFields[name]
  4348. return ok
  4349. }
  4350. // ClearField clears the value of the field with the given name. It returns an
  4351. // error if the field is not defined in the schema.
  4352. func (m *AllocAgentMutation) ClearField(name string) error {
  4353. switch name {
  4354. case allocagent.FieldDeletedAt:
  4355. m.ClearDeletedAt()
  4356. return nil
  4357. case allocagent.FieldUserID:
  4358. m.ClearUserID()
  4359. return nil
  4360. case allocagent.FieldOrganizationID:
  4361. m.ClearOrganizationID()
  4362. return nil
  4363. case allocagent.FieldStatus:
  4364. m.ClearStatus()
  4365. return nil
  4366. }
  4367. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4368. }
  4369. // ResetField resets all changes in the mutation for the field with the given name.
  4370. // It returns an error if the field is not defined in the schema.
  4371. func (m *AllocAgentMutation) ResetField(name string) error {
  4372. switch name {
  4373. case allocagent.FieldCreatedAt:
  4374. m.ResetCreatedAt()
  4375. return nil
  4376. case allocagent.FieldUpdatedAt:
  4377. m.ResetUpdatedAt()
  4378. return nil
  4379. case allocagent.FieldDeletedAt:
  4380. m.ResetDeletedAt()
  4381. return nil
  4382. case allocagent.FieldUserID:
  4383. m.ResetUserID()
  4384. return nil
  4385. case allocagent.FieldOrganizationID:
  4386. m.ResetOrganizationID()
  4387. return nil
  4388. case allocagent.FieldAgents:
  4389. m.ResetAgents()
  4390. return nil
  4391. case allocagent.FieldStatus:
  4392. m.ResetStatus()
  4393. return nil
  4394. }
  4395. return fmt.Errorf("unknown AllocAgent field %s", name)
  4396. }
  4397. // AddedEdges returns all edge names that were set/added in this mutation.
  4398. func (m *AllocAgentMutation) AddedEdges() []string {
  4399. edges := make([]string, 0, 0)
  4400. return edges
  4401. }
  4402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4403. // name in this mutation.
  4404. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4405. return nil
  4406. }
  4407. // RemovedEdges returns all edge names that were removed in this mutation.
  4408. func (m *AllocAgentMutation) RemovedEdges() []string {
  4409. edges := make([]string, 0, 0)
  4410. return edges
  4411. }
  4412. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4413. // the given name in this mutation.
  4414. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4415. return nil
  4416. }
  4417. // ClearedEdges returns all edge names that were cleared in this mutation.
  4418. func (m *AllocAgentMutation) ClearedEdges() []string {
  4419. edges := make([]string, 0, 0)
  4420. return edges
  4421. }
  4422. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4423. // was cleared in this mutation.
  4424. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4425. return false
  4426. }
  4427. // ClearEdge clears the value of the edge with the given name. It returns an error
  4428. // if that edge is not defined in the schema.
  4429. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4430. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4431. }
  4432. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4433. // It returns an error if the edge is not defined in the schema.
  4434. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4435. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4436. }
  4437. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4438. type ApiKeyMutation struct {
  4439. config
  4440. op Op
  4441. typ string
  4442. id *uint64
  4443. created_at *time.Time
  4444. updated_at *time.Time
  4445. deleted_at *time.Time
  4446. title *string
  4447. key *string
  4448. organization_id *uint64
  4449. addorganization_id *int64
  4450. custom_agent_base *string
  4451. custom_agent_key *string
  4452. openai_base *string
  4453. openai_key *string
  4454. clearedFields map[string]struct{}
  4455. agent *uint64
  4456. clearedagent bool
  4457. done bool
  4458. oldValue func(context.Context) (*ApiKey, error)
  4459. predicates []predicate.ApiKey
  4460. }
  4461. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4462. // apikeyOption allows management of the mutation configuration using functional options.
  4463. type apikeyOption func(*ApiKeyMutation)
  4464. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4465. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4466. m := &ApiKeyMutation{
  4467. config: c,
  4468. op: op,
  4469. typ: TypeApiKey,
  4470. clearedFields: make(map[string]struct{}),
  4471. }
  4472. for _, opt := range opts {
  4473. opt(m)
  4474. }
  4475. return m
  4476. }
  4477. // withApiKeyID sets the ID field of the mutation.
  4478. func withApiKeyID(id uint64) apikeyOption {
  4479. return func(m *ApiKeyMutation) {
  4480. var (
  4481. err error
  4482. once sync.Once
  4483. value *ApiKey
  4484. )
  4485. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4486. once.Do(func() {
  4487. if m.done {
  4488. err = errors.New("querying old values post mutation is not allowed")
  4489. } else {
  4490. value, err = m.Client().ApiKey.Get(ctx, id)
  4491. }
  4492. })
  4493. return value, err
  4494. }
  4495. m.id = &id
  4496. }
  4497. }
  4498. // withApiKey sets the old ApiKey of the mutation.
  4499. func withApiKey(node *ApiKey) apikeyOption {
  4500. return func(m *ApiKeyMutation) {
  4501. m.oldValue = func(context.Context) (*ApiKey, error) {
  4502. return node, nil
  4503. }
  4504. m.id = &node.ID
  4505. }
  4506. }
  4507. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4508. // executed in a transaction (ent.Tx), a transactional client is returned.
  4509. func (m ApiKeyMutation) Client() *Client {
  4510. client := &Client{config: m.config}
  4511. client.init()
  4512. return client
  4513. }
  4514. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4515. // it returns an error otherwise.
  4516. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4517. if _, ok := m.driver.(*txDriver); !ok {
  4518. return nil, errors.New("ent: mutation is not running in a transaction")
  4519. }
  4520. tx := &Tx{config: m.config}
  4521. tx.init()
  4522. return tx, nil
  4523. }
  4524. // SetID sets the value of the id field. Note that this
  4525. // operation is only accepted on creation of ApiKey entities.
  4526. func (m *ApiKeyMutation) SetID(id uint64) {
  4527. m.id = &id
  4528. }
  4529. // ID returns the ID value in the mutation. Note that the ID is only available
  4530. // if it was provided to the builder or after it was returned from the database.
  4531. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4532. if m.id == nil {
  4533. return
  4534. }
  4535. return *m.id, true
  4536. }
  4537. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4538. // That means, if the mutation is applied within a transaction with an isolation level such
  4539. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4540. // or updated by the mutation.
  4541. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4542. switch {
  4543. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4544. id, exists := m.ID()
  4545. if exists {
  4546. return []uint64{id}, nil
  4547. }
  4548. fallthrough
  4549. case m.op.Is(OpUpdate | OpDelete):
  4550. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4551. default:
  4552. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4553. }
  4554. }
  4555. // SetCreatedAt sets the "created_at" field.
  4556. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4557. m.created_at = &t
  4558. }
  4559. // CreatedAt returns the value of the "created_at" field in the mutation.
  4560. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4561. v := m.created_at
  4562. if v == nil {
  4563. return
  4564. }
  4565. return *v, true
  4566. }
  4567. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4568. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4570. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4571. if !m.op.Is(OpUpdateOne) {
  4572. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4573. }
  4574. if m.id == nil || m.oldValue == nil {
  4575. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4576. }
  4577. oldValue, err := m.oldValue(ctx)
  4578. if err != nil {
  4579. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4580. }
  4581. return oldValue.CreatedAt, nil
  4582. }
  4583. // ResetCreatedAt resets all changes to the "created_at" field.
  4584. func (m *ApiKeyMutation) ResetCreatedAt() {
  4585. m.created_at = nil
  4586. }
  4587. // SetUpdatedAt sets the "updated_at" field.
  4588. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4589. m.updated_at = &t
  4590. }
  4591. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4592. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4593. v := m.updated_at
  4594. if v == nil {
  4595. return
  4596. }
  4597. return *v, true
  4598. }
  4599. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4600. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4602. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4603. if !m.op.Is(OpUpdateOne) {
  4604. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4605. }
  4606. if m.id == nil || m.oldValue == nil {
  4607. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4608. }
  4609. oldValue, err := m.oldValue(ctx)
  4610. if err != nil {
  4611. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4612. }
  4613. return oldValue.UpdatedAt, nil
  4614. }
  4615. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4616. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4617. m.updated_at = nil
  4618. }
  4619. // SetDeletedAt sets the "deleted_at" field.
  4620. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4621. m.deleted_at = &t
  4622. }
  4623. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4624. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4625. v := m.deleted_at
  4626. if v == nil {
  4627. return
  4628. }
  4629. return *v, true
  4630. }
  4631. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4632. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4634. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4635. if !m.op.Is(OpUpdateOne) {
  4636. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4637. }
  4638. if m.id == nil || m.oldValue == nil {
  4639. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4640. }
  4641. oldValue, err := m.oldValue(ctx)
  4642. if err != nil {
  4643. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4644. }
  4645. return oldValue.DeletedAt, nil
  4646. }
  4647. // ClearDeletedAt clears the value of the "deleted_at" field.
  4648. func (m *ApiKeyMutation) ClearDeletedAt() {
  4649. m.deleted_at = nil
  4650. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4651. }
  4652. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4653. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4654. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4655. return ok
  4656. }
  4657. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4658. func (m *ApiKeyMutation) ResetDeletedAt() {
  4659. m.deleted_at = nil
  4660. delete(m.clearedFields, apikey.FieldDeletedAt)
  4661. }
  4662. // SetTitle sets the "title" field.
  4663. func (m *ApiKeyMutation) SetTitle(s string) {
  4664. m.title = &s
  4665. }
  4666. // Title returns the value of the "title" field in the mutation.
  4667. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4668. v := m.title
  4669. if v == nil {
  4670. return
  4671. }
  4672. return *v, true
  4673. }
  4674. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4675. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4677. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4678. if !m.op.Is(OpUpdateOne) {
  4679. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4680. }
  4681. if m.id == nil || m.oldValue == nil {
  4682. return v, errors.New("OldTitle requires an ID field in the mutation")
  4683. }
  4684. oldValue, err := m.oldValue(ctx)
  4685. if err != nil {
  4686. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4687. }
  4688. return oldValue.Title, nil
  4689. }
  4690. // ClearTitle clears the value of the "title" field.
  4691. func (m *ApiKeyMutation) ClearTitle() {
  4692. m.title = nil
  4693. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4694. }
  4695. // TitleCleared returns if the "title" field was cleared in this mutation.
  4696. func (m *ApiKeyMutation) TitleCleared() bool {
  4697. _, ok := m.clearedFields[apikey.FieldTitle]
  4698. return ok
  4699. }
  4700. // ResetTitle resets all changes to the "title" field.
  4701. func (m *ApiKeyMutation) ResetTitle() {
  4702. m.title = nil
  4703. delete(m.clearedFields, apikey.FieldTitle)
  4704. }
  4705. // SetKey sets the "key" field.
  4706. func (m *ApiKeyMutation) SetKey(s string) {
  4707. m.key = &s
  4708. }
  4709. // Key returns the value of the "key" field in the mutation.
  4710. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4711. v := m.key
  4712. if v == nil {
  4713. return
  4714. }
  4715. return *v, true
  4716. }
  4717. // OldKey returns the old "key" field's value of the ApiKey entity.
  4718. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4720. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4721. if !m.op.Is(OpUpdateOne) {
  4722. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4723. }
  4724. if m.id == nil || m.oldValue == nil {
  4725. return v, errors.New("OldKey requires an ID field in the mutation")
  4726. }
  4727. oldValue, err := m.oldValue(ctx)
  4728. if err != nil {
  4729. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4730. }
  4731. return oldValue.Key, nil
  4732. }
  4733. // ClearKey clears the value of the "key" field.
  4734. func (m *ApiKeyMutation) ClearKey() {
  4735. m.key = nil
  4736. m.clearedFields[apikey.FieldKey] = struct{}{}
  4737. }
  4738. // KeyCleared returns if the "key" field was cleared in this mutation.
  4739. func (m *ApiKeyMutation) KeyCleared() bool {
  4740. _, ok := m.clearedFields[apikey.FieldKey]
  4741. return ok
  4742. }
  4743. // ResetKey resets all changes to the "key" field.
  4744. func (m *ApiKeyMutation) ResetKey() {
  4745. m.key = nil
  4746. delete(m.clearedFields, apikey.FieldKey)
  4747. }
  4748. // SetOrganizationID sets the "organization_id" field.
  4749. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4750. m.organization_id = &u
  4751. m.addorganization_id = nil
  4752. }
  4753. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4754. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4755. v := m.organization_id
  4756. if v == nil {
  4757. return
  4758. }
  4759. return *v, true
  4760. }
  4761. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4762. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4764. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4765. if !m.op.Is(OpUpdateOne) {
  4766. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4767. }
  4768. if m.id == nil || m.oldValue == nil {
  4769. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4770. }
  4771. oldValue, err := m.oldValue(ctx)
  4772. if err != nil {
  4773. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4774. }
  4775. return oldValue.OrganizationID, nil
  4776. }
  4777. // AddOrganizationID adds u to the "organization_id" field.
  4778. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4779. if m.addorganization_id != nil {
  4780. *m.addorganization_id += u
  4781. } else {
  4782. m.addorganization_id = &u
  4783. }
  4784. }
  4785. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4786. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4787. v := m.addorganization_id
  4788. if v == nil {
  4789. return
  4790. }
  4791. return *v, true
  4792. }
  4793. // ResetOrganizationID resets all changes to the "organization_id" field.
  4794. func (m *ApiKeyMutation) ResetOrganizationID() {
  4795. m.organization_id = nil
  4796. m.addorganization_id = nil
  4797. }
  4798. // SetAgentID sets the "agent_id" field.
  4799. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4800. m.agent = &u
  4801. }
  4802. // AgentID returns the value of the "agent_id" field in the mutation.
  4803. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4804. v := m.agent
  4805. if v == nil {
  4806. return
  4807. }
  4808. return *v, true
  4809. }
  4810. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4811. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4813. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4814. if !m.op.Is(OpUpdateOne) {
  4815. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4816. }
  4817. if m.id == nil || m.oldValue == nil {
  4818. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4819. }
  4820. oldValue, err := m.oldValue(ctx)
  4821. if err != nil {
  4822. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4823. }
  4824. return oldValue.AgentID, nil
  4825. }
  4826. // ResetAgentID resets all changes to the "agent_id" field.
  4827. func (m *ApiKeyMutation) ResetAgentID() {
  4828. m.agent = nil
  4829. }
  4830. // SetCustomAgentBase sets the "custom_agent_base" field.
  4831. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4832. m.custom_agent_base = &s
  4833. }
  4834. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4835. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4836. v := m.custom_agent_base
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4843. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4845. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4846. if !m.op.Is(OpUpdateOne) {
  4847. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4848. }
  4849. if m.id == nil || m.oldValue == nil {
  4850. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4851. }
  4852. oldValue, err := m.oldValue(ctx)
  4853. if err != nil {
  4854. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4855. }
  4856. return oldValue.CustomAgentBase, nil
  4857. }
  4858. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4859. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4860. m.custom_agent_base = nil
  4861. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4862. }
  4863. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4864. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4865. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4866. return ok
  4867. }
  4868. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4869. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4870. m.custom_agent_base = nil
  4871. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4872. }
  4873. // SetCustomAgentKey sets the "custom_agent_key" field.
  4874. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4875. m.custom_agent_key = &s
  4876. }
  4877. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4878. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4879. v := m.custom_agent_key
  4880. if v == nil {
  4881. return
  4882. }
  4883. return *v, true
  4884. }
  4885. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4886. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4888. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4889. if !m.op.Is(OpUpdateOne) {
  4890. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4891. }
  4892. if m.id == nil || m.oldValue == nil {
  4893. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4894. }
  4895. oldValue, err := m.oldValue(ctx)
  4896. if err != nil {
  4897. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4898. }
  4899. return oldValue.CustomAgentKey, nil
  4900. }
  4901. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4902. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4903. m.custom_agent_key = nil
  4904. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4905. }
  4906. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4907. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4908. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4909. return ok
  4910. }
  4911. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4912. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4913. m.custom_agent_key = nil
  4914. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4915. }
  4916. // SetOpenaiBase sets the "openai_base" field.
  4917. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4918. m.openai_base = &s
  4919. }
  4920. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4921. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4922. v := m.openai_base
  4923. if v == nil {
  4924. return
  4925. }
  4926. return *v, true
  4927. }
  4928. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4929. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4931. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4932. if !m.op.Is(OpUpdateOne) {
  4933. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4934. }
  4935. if m.id == nil || m.oldValue == nil {
  4936. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4937. }
  4938. oldValue, err := m.oldValue(ctx)
  4939. if err != nil {
  4940. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4941. }
  4942. return oldValue.OpenaiBase, nil
  4943. }
  4944. // ClearOpenaiBase clears the value of the "openai_base" field.
  4945. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4946. m.openai_base = nil
  4947. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4948. }
  4949. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4950. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4951. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4952. return ok
  4953. }
  4954. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4955. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4956. m.openai_base = nil
  4957. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4958. }
  4959. // SetOpenaiKey sets the "openai_key" field.
  4960. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4961. m.openai_key = &s
  4962. }
  4963. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4964. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4965. v := m.openai_key
  4966. if v == nil {
  4967. return
  4968. }
  4969. return *v, true
  4970. }
  4971. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4972. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4974. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4975. if !m.op.Is(OpUpdateOne) {
  4976. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4977. }
  4978. if m.id == nil || m.oldValue == nil {
  4979. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4980. }
  4981. oldValue, err := m.oldValue(ctx)
  4982. if err != nil {
  4983. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4984. }
  4985. return oldValue.OpenaiKey, nil
  4986. }
  4987. // ClearOpenaiKey clears the value of the "openai_key" field.
  4988. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4989. m.openai_key = nil
  4990. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4991. }
  4992. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4993. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4994. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4995. return ok
  4996. }
  4997. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4998. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4999. m.openai_key = nil
  5000. delete(m.clearedFields, apikey.FieldOpenaiKey)
  5001. }
  5002. // ClearAgent clears the "agent" edge to the Agent entity.
  5003. func (m *ApiKeyMutation) ClearAgent() {
  5004. m.clearedagent = true
  5005. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  5006. }
  5007. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  5008. func (m *ApiKeyMutation) AgentCleared() bool {
  5009. return m.clearedagent
  5010. }
  5011. // AgentIDs returns the "agent" edge IDs in the mutation.
  5012. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5013. // AgentID instead. It exists only for internal usage by the builders.
  5014. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  5015. if id := m.agent; id != nil {
  5016. ids = append(ids, *id)
  5017. }
  5018. return
  5019. }
  5020. // ResetAgent resets all changes to the "agent" edge.
  5021. func (m *ApiKeyMutation) ResetAgent() {
  5022. m.agent = nil
  5023. m.clearedagent = false
  5024. }
  5025. // Where appends a list predicates to the ApiKeyMutation builder.
  5026. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  5027. m.predicates = append(m.predicates, ps...)
  5028. }
  5029. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  5030. // users can use type-assertion to append predicates that do not depend on any generated package.
  5031. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  5032. p := make([]predicate.ApiKey, len(ps))
  5033. for i := range ps {
  5034. p[i] = ps[i]
  5035. }
  5036. m.Where(p...)
  5037. }
  5038. // Op returns the operation name.
  5039. func (m *ApiKeyMutation) Op() Op {
  5040. return m.op
  5041. }
  5042. // SetOp allows setting the mutation operation.
  5043. func (m *ApiKeyMutation) SetOp(op Op) {
  5044. m.op = op
  5045. }
  5046. // Type returns the node type of this mutation (ApiKey).
  5047. func (m *ApiKeyMutation) Type() string {
  5048. return m.typ
  5049. }
  5050. // Fields returns all fields that were changed during this mutation. Note that in
  5051. // order to get all numeric fields that were incremented/decremented, call
  5052. // AddedFields().
  5053. func (m *ApiKeyMutation) Fields() []string {
  5054. fields := make([]string, 0, 11)
  5055. if m.created_at != nil {
  5056. fields = append(fields, apikey.FieldCreatedAt)
  5057. }
  5058. if m.updated_at != nil {
  5059. fields = append(fields, apikey.FieldUpdatedAt)
  5060. }
  5061. if m.deleted_at != nil {
  5062. fields = append(fields, apikey.FieldDeletedAt)
  5063. }
  5064. if m.title != nil {
  5065. fields = append(fields, apikey.FieldTitle)
  5066. }
  5067. if m.key != nil {
  5068. fields = append(fields, apikey.FieldKey)
  5069. }
  5070. if m.organization_id != nil {
  5071. fields = append(fields, apikey.FieldOrganizationID)
  5072. }
  5073. if m.agent != nil {
  5074. fields = append(fields, apikey.FieldAgentID)
  5075. }
  5076. if m.custom_agent_base != nil {
  5077. fields = append(fields, apikey.FieldCustomAgentBase)
  5078. }
  5079. if m.custom_agent_key != nil {
  5080. fields = append(fields, apikey.FieldCustomAgentKey)
  5081. }
  5082. if m.openai_base != nil {
  5083. fields = append(fields, apikey.FieldOpenaiBase)
  5084. }
  5085. if m.openai_key != nil {
  5086. fields = append(fields, apikey.FieldOpenaiKey)
  5087. }
  5088. return fields
  5089. }
  5090. // Field returns the value of a field with the given name. The second boolean
  5091. // return value indicates that this field was not set, or was not defined in the
  5092. // schema.
  5093. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5094. switch name {
  5095. case apikey.FieldCreatedAt:
  5096. return m.CreatedAt()
  5097. case apikey.FieldUpdatedAt:
  5098. return m.UpdatedAt()
  5099. case apikey.FieldDeletedAt:
  5100. return m.DeletedAt()
  5101. case apikey.FieldTitle:
  5102. return m.Title()
  5103. case apikey.FieldKey:
  5104. return m.Key()
  5105. case apikey.FieldOrganizationID:
  5106. return m.OrganizationID()
  5107. case apikey.FieldAgentID:
  5108. return m.AgentID()
  5109. case apikey.FieldCustomAgentBase:
  5110. return m.CustomAgentBase()
  5111. case apikey.FieldCustomAgentKey:
  5112. return m.CustomAgentKey()
  5113. case apikey.FieldOpenaiBase:
  5114. return m.OpenaiBase()
  5115. case apikey.FieldOpenaiKey:
  5116. return m.OpenaiKey()
  5117. }
  5118. return nil, false
  5119. }
  5120. // OldField returns the old value of the field from the database. An error is
  5121. // returned if the mutation operation is not UpdateOne, or the query to the
  5122. // database failed.
  5123. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5124. switch name {
  5125. case apikey.FieldCreatedAt:
  5126. return m.OldCreatedAt(ctx)
  5127. case apikey.FieldUpdatedAt:
  5128. return m.OldUpdatedAt(ctx)
  5129. case apikey.FieldDeletedAt:
  5130. return m.OldDeletedAt(ctx)
  5131. case apikey.FieldTitle:
  5132. return m.OldTitle(ctx)
  5133. case apikey.FieldKey:
  5134. return m.OldKey(ctx)
  5135. case apikey.FieldOrganizationID:
  5136. return m.OldOrganizationID(ctx)
  5137. case apikey.FieldAgentID:
  5138. return m.OldAgentID(ctx)
  5139. case apikey.FieldCustomAgentBase:
  5140. return m.OldCustomAgentBase(ctx)
  5141. case apikey.FieldCustomAgentKey:
  5142. return m.OldCustomAgentKey(ctx)
  5143. case apikey.FieldOpenaiBase:
  5144. return m.OldOpenaiBase(ctx)
  5145. case apikey.FieldOpenaiKey:
  5146. return m.OldOpenaiKey(ctx)
  5147. }
  5148. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5149. }
  5150. // SetField sets the value of a field with the given name. It returns an error if
  5151. // the field is not defined in the schema, or if the type mismatched the field
  5152. // type.
  5153. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5154. switch name {
  5155. case apikey.FieldCreatedAt:
  5156. v, ok := value.(time.Time)
  5157. if !ok {
  5158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5159. }
  5160. m.SetCreatedAt(v)
  5161. return nil
  5162. case apikey.FieldUpdatedAt:
  5163. v, ok := value.(time.Time)
  5164. if !ok {
  5165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166. }
  5167. m.SetUpdatedAt(v)
  5168. return nil
  5169. case apikey.FieldDeletedAt:
  5170. v, ok := value.(time.Time)
  5171. if !ok {
  5172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5173. }
  5174. m.SetDeletedAt(v)
  5175. return nil
  5176. case apikey.FieldTitle:
  5177. v, ok := value.(string)
  5178. if !ok {
  5179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5180. }
  5181. m.SetTitle(v)
  5182. return nil
  5183. case apikey.FieldKey:
  5184. v, ok := value.(string)
  5185. if !ok {
  5186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187. }
  5188. m.SetKey(v)
  5189. return nil
  5190. case apikey.FieldOrganizationID:
  5191. v, ok := value.(uint64)
  5192. if !ok {
  5193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5194. }
  5195. m.SetOrganizationID(v)
  5196. return nil
  5197. case apikey.FieldAgentID:
  5198. v, ok := value.(uint64)
  5199. if !ok {
  5200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5201. }
  5202. m.SetAgentID(v)
  5203. return nil
  5204. case apikey.FieldCustomAgentBase:
  5205. v, ok := value.(string)
  5206. if !ok {
  5207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5208. }
  5209. m.SetCustomAgentBase(v)
  5210. return nil
  5211. case apikey.FieldCustomAgentKey:
  5212. v, ok := value.(string)
  5213. if !ok {
  5214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5215. }
  5216. m.SetCustomAgentKey(v)
  5217. return nil
  5218. case apikey.FieldOpenaiBase:
  5219. v, ok := value.(string)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.SetOpenaiBase(v)
  5224. return nil
  5225. case apikey.FieldOpenaiKey:
  5226. v, ok := value.(string)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.SetOpenaiKey(v)
  5231. return nil
  5232. }
  5233. return fmt.Errorf("unknown ApiKey field %s", name)
  5234. }
  5235. // AddedFields returns all numeric fields that were incremented/decremented during
  5236. // this mutation.
  5237. func (m *ApiKeyMutation) AddedFields() []string {
  5238. var fields []string
  5239. if m.addorganization_id != nil {
  5240. fields = append(fields, apikey.FieldOrganizationID)
  5241. }
  5242. return fields
  5243. }
  5244. // AddedField returns the numeric value that was incremented/decremented on a field
  5245. // with the given name. The second boolean return value indicates that this field
  5246. // was not set, or was not defined in the schema.
  5247. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5248. switch name {
  5249. case apikey.FieldOrganizationID:
  5250. return m.AddedOrganizationID()
  5251. }
  5252. return nil, false
  5253. }
  5254. // AddField adds the value to the field with the given name. It returns an error if
  5255. // the field is not defined in the schema, or if the type mismatched the field
  5256. // type.
  5257. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5258. switch name {
  5259. case apikey.FieldOrganizationID:
  5260. v, ok := value.(int64)
  5261. if !ok {
  5262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5263. }
  5264. m.AddOrganizationID(v)
  5265. return nil
  5266. }
  5267. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5268. }
  5269. // ClearedFields returns all nullable fields that were cleared during this
  5270. // mutation.
  5271. func (m *ApiKeyMutation) ClearedFields() []string {
  5272. var fields []string
  5273. if m.FieldCleared(apikey.FieldDeletedAt) {
  5274. fields = append(fields, apikey.FieldDeletedAt)
  5275. }
  5276. if m.FieldCleared(apikey.FieldTitle) {
  5277. fields = append(fields, apikey.FieldTitle)
  5278. }
  5279. if m.FieldCleared(apikey.FieldKey) {
  5280. fields = append(fields, apikey.FieldKey)
  5281. }
  5282. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5283. fields = append(fields, apikey.FieldCustomAgentBase)
  5284. }
  5285. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5286. fields = append(fields, apikey.FieldCustomAgentKey)
  5287. }
  5288. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5289. fields = append(fields, apikey.FieldOpenaiBase)
  5290. }
  5291. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5292. fields = append(fields, apikey.FieldOpenaiKey)
  5293. }
  5294. return fields
  5295. }
  5296. // FieldCleared returns a boolean indicating if a field with the given name was
  5297. // cleared in this mutation.
  5298. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5299. _, ok := m.clearedFields[name]
  5300. return ok
  5301. }
  5302. // ClearField clears the value of the field with the given name. It returns an
  5303. // error if the field is not defined in the schema.
  5304. func (m *ApiKeyMutation) ClearField(name string) error {
  5305. switch name {
  5306. case apikey.FieldDeletedAt:
  5307. m.ClearDeletedAt()
  5308. return nil
  5309. case apikey.FieldTitle:
  5310. m.ClearTitle()
  5311. return nil
  5312. case apikey.FieldKey:
  5313. m.ClearKey()
  5314. return nil
  5315. case apikey.FieldCustomAgentBase:
  5316. m.ClearCustomAgentBase()
  5317. return nil
  5318. case apikey.FieldCustomAgentKey:
  5319. m.ClearCustomAgentKey()
  5320. return nil
  5321. case apikey.FieldOpenaiBase:
  5322. m.ClearOpenaiBase()
  5323. return nil
  5324. case apikey.FieldOpenaiKey:
  5325. m.ClearOpenaiKey()
  5326. return nil
  5327. }
  5328. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5329. }
  5330. // ResetField resets all changes in the mutation for the field with the given name.
  5331. // It returns an error if the field is not defined in the schema.
  5332. func (m *ApiKeyMutation) ResetField(name string) error {
  5333. switch name {
  5334. case apikey.FieldCreatedAt:
  5335. m.ResetCreatedAt()
  5336. return nil
  5337. case apikey.FieldUpdatedAt:
  5338. m.ResetUpdatedAt()
  5339. return nil
  5340. case apikey.FieldDeletedAt:
  5341. m.ResetDeletedAt()
  5342. return nil
  5343. case apikey.FieldTitle:
  5344. m.ResetTitle()
  5345. return nil
  5346. case apikey.FieldKey:
  5347. m.ResetKey()
  5348. return nil
  5349. case apikey.FieldOrganizationID:
  5350. m.ResetOrganizationID()
  5351. return nil
  5352. case apikey.FieldAgentID:
  5353. m.ResetAgentID()
  5354. return nil
  5355. case apikey.FieldCustomAgentBase:
  5356. m.ResetCustomAgentBase()
  5357. return nil
  5358. case apikey.FieldCustomAgentKey:
  5359. m.ResetCustomAgentKey()
  5360. return nil
  5361. case apikey.FieldOpenaiBase:
  5362. m.ResetOpenaiBase()
  5363. return nil
  5364. case apikey.FieldOpenaiKey:
  5365. m.ResetOpenaiKey()
  5366. return nil
  5367. }
  5368. return fmt.Errorf("unknown ApiKey field %s", name)
  5369. }
  5370. // AddedEdges returns all edge names that were set/added in this mutation.
  5371. func (m *ApiKeyMutation) AddedEdges() []string {
  5372. edges := make([]string, 0, 1)
  5373. if m.agent != nil {
  5374. edges = append(edges, apikey.EdgeAgent)
  5375. }
  5376. return edges
  5377. }
  5378. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5379. // name in this mutation.
  5380. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5381. switch name {
  5382. case apikey.EdgeAgent:
  5383. if id := m.agent; id != nil {
  5384. return []ent.Value{*id}
  5385. }
  5386. }
  5387. return nil
  5388. }
  5389. // RemovedEdges returns all edge names that were removed in this mutation.
  5390. func (m *ApiKeyMutation) RemovedEdges() []string {
  5391. edges := make([]string, 0, 1)
  5392. return edges
  5393. }
  5394. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5395. // the given name in this mutation.
  5396. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5397. return nil
  5398. }
  5399. // ClearedEdges returns all edge names that were cleared in this mutation.
  5400. func (m *ApiKeyMutation) ClearedEdges() []string {
  5401. edges := make([]string, 0, 1)
  5402. if m.clearedagent {
  5403. edges = append(edges, apikey.EdgeAgent)
  5404. }
  5405. return edges
  5406. }
  5407. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5408. // was cleared in this mutation.
  5409. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5410. switch name {
  5411. case apikey.EdgeAgent:
  5412. return m.clearedagent
  5413. }
  5414. return false
  5415. }
  5416. // ClearEdge clears the value of the edge with the given name. It returns an error
  5417. // if that edge is not defined in the schema.
  5418. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5419. switch name {
  5420. case apikey.EdgeAgent:
  5421. m.ClearAgent()
  5422. return nil
  5423. }
  5424. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5425. }
  5426. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5427. // It returns an error if the edge is not defined in the schema.
  5428. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5429. switch name {
  5430. case apikey.EdgeAgent:
  5431. m.ResetAgent()
  5432. return nil
  5433. }
  5434. return fmt.Errorf("unknown ApiKey edge %s", name)
  5435. }
  5436. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5437. type BatchMsgMutation struct {
  5438. config
  5439. op Op
  5440. typ string
  5441. id *uint64
  5442. created_at *time.Time
  5443. updated_at *time.Time
  5444. deleted_at *time.Time
  5445. status *uint8
  5446. addstatus *int8
  5447. batch_no *string
  5448. task_name *string
  5449. fromwxid *string
  5450. msg *string
  5451. tag *string
  5452. tagids *string
  5453. total *int32
  5454. addtotal *int32
  5455. success *int32
  5456. addsuccess *int32
  5457. fail *int32
  5458. addfail *int32
  5459. start_time *time.Time
  5460. stop_time *time.Time
  5461. send_time *time.Time
  5462. _type *int32
  5463. add_type *int32
  5464. organization_id *uint64
  5465. addorganization_id *int64
  5466. ctype *uint64
  5467. addctype *int64
  5468. cc *string
  5469. phone *string
  5470. template_name *string
  5471. template_code *string
  5472. lang *string
  5473. clearedFields map[string]struct{}
  5474. done bool
  5475. oldValue func(context.Context) (*BatchMsg, error)
  5476. predicates []predicate.BatchMsg
  5477. }
  5478. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5479. // batchmsgOption allows management of the mutation configuration using functional options.
  5480. type batchmsgOption func(*BatchMsgMutation)
  5481. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5482. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5483. m := &BatchMsgMutation{
  5484. config: c,
  5485. op: op,
  5486. typ: TypeBatchMsg,
  5487. clearedFields: make(map[string]struct{}),
  5488. }
  5489. for _, opt := range opts {
  5490. opt(m)
  5491. }
  5492. return m
  5493. }
  5494. // withBatchMsgID sets the ID field of the mutation.
  5495. func withBatchMsgID(id uint64) batchmsgOption {
  5496. return func(m *BatchMsgMutation) {
  5497. var (
  5498. err error
  5499. once sync.Once
  5500. value *BatchMsg
  5501. )
  5502. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5503. once.Do(func() {
  5504. if m.done {
  5505. err = errors.New("querying old values post mutation is not allowed")
  5506. } else {
  5507. value, err = m.Client().BatchMsg.Get(ctx, id)
  5508. }
  5509. })
  5510. return value, err
  5511. }
  5512. m.id = &id
  5513. }
  5514. }
  5515. // withBatchMsg sets the old BatchMsg of the mutation.
  5516. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5517. return func(m *BatchMsgMutation) {
  5518. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5519. return node, nil
  5520. }
  5521. m.id = &node.ID
  5522. }
  5523. }
  5524. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5525. // executed in a transaction (ent.Tx), a transactional client is returned.
  5526. func (m BatchMsgMutation) Client() *Client {
  5527. client := &Client{config: m.config}
  5528. client.init()
  5529. return client
  5530. }
  5531. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5532. // it returns an error otherwise.
  5533. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5534. if _, ok := m.driver.(*txDriver); !ok {
  5535. return nil, errors.New("ent: mutation is not running in a transaction")
  5536. }
  5537. tx := &Tx{config: m.config}
  5538. tx.init()
  5539. return tx, nil
  5540. }
  5541. // SetID sets the value of the id field. Note that this
  5542. // operation is only accepted on creation of BatchMsg entities.
  5543. func (m *BatchMsgMutation) SetID(id uint64) {
  5544. m.id = &id
  5545. }
  5546. // ID returns the ID value in the mutation. Note that the ID is only available
  5547. // if it was provided to the builder or after it was returned from the database.
  5548. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5549. if m.id == nil {
  5550. return
  5551. }
  5552. return *m.id, true
  5553. }
  5554. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5555. // That means, if the mutation is applied within a transaction with an isolation level such
  5556. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5557. // or updated by the mutation.
  5558. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5559. switch {
  5560. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5561. id, exists := m.ID()
  5562. if exists {
  5563. return []uint64{id}, nil
  5564. }
  5565. fallthrough
  5566. case m.op.Is(OpUpdate | OpDelete):
  5567. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5568. default:
  5569. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5570. }
  5571. }
  5572. // SetCreatedAt sets the "created_at" field.
  5573. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5574. m.created_at = &t
  5575. }
  5576. // CreatedAt returns the value of the "created_at" field in the mutation.
  5577. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5578. v := m.created_at
  5579. if v == nil {
  5580. return
  5581. }
  5582. return *v, true
  5583. }
  5584. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5585. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5587. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5588. if !m.op.Is(OpUpdateOne) {
  5589. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5590. }
  5591. if m.id == nil || m.oldValue == nil {
  5592. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5593. }
  5594. oldValue, err := m.oldValue(ctx)
  5595. if err != nil {
  5596. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5597. }
  5598. return oldValue.CreatedAt, nil
  5599. }
  5600. // ResetCreatedAt resets all changes to the "created_at" field.
  5601. func (m *BatchMsgMutation) ResetCreatedAt() {
  5602. m.created_at = nil
  5603. }
  5604. // SetUpdatedAt sets the "updated_at" field.
  5605. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5606. m.updated_at = &t
  5607. }
  5608. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5609. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5610. v := m.updated_at
  5611. if v == nil {
  5612. return
  5613. }
  5614. return *v, true
  5615. }
  5616. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5617. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5619. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5620. if !m.op.Is(OpUpdateOne) {
  5621. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5622. }
  5623. if m.id == nil || m.oldValue == nil {
  5624. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5625. }
  5626. oldValue, err := m.oldValue(ctx)
  5627. if err != nil {
  5628. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5629. }
  5630. return oldValue.UpdatedAt, nil
  5631. }
  5632. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5633. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5634. m.updated_at = nil
  5635. }
  5636. // SetDeletedAt sets the "deleted_at" field.
  5637. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5638. m.deleted_at = &t
  5639. }
  5640. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5641. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5642. v := m.deleted_at
  5643. if v == nil {
  5644. return
  5645. }
  5646. return *v, true
  5647. }
  5648. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5649. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5651. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5652. if !m.op.Is(OpUpdateOne) {
  5653. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5654. }
  5655. if m.id == nil || m.oldValue == nil {
  5656. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5657. }
  5658. oldValue, err := m.oldValue(ctx)
  5659. if err != nil {
  5660. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5661. }
  5662. return oldValue.DeletedAt, nil
  5663. }
  5664. // ClearDeletedAt clears the value of the "deleted_at" field.
  5665. func (m *BatchMsgMutation) ClearDeletedAt() {
  5666. m.deleted_at = nil
  5667. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5668. }
  5669. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5670. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5671. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5672. return ok
  5673. }
  5674. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5675. func (m *BatchMsgMutation) ResetDeletedAt() {
  5676. m.deleted_at = nil
  5677. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5678. }
  5679. // SetStatus sets the "status" field.
  5680. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5681. m.status = &u
  5682. m.addstatus = nil
  5683. }
  5684. // Status returns the value of the "status" field in the mutation.
  5685. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5686. v := m.status
  5687. if v == nil {
  5688. return
  5689. }
  5690. return *v, true
  5691. }
  5692. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5693. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5695. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5696. if !m.op.Is(OpUpdateOne) {
  5697. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5698. }
  5699. if m.id == nil || m.oldValue == nil {
  5700. return v, errors.New("OldStatus requires an ID field in the mutation")
  5701. }
  5702. oldValue, err := m.oldValue(ctx)
  5703. if err != nil {
  5704. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5705. }
  5706. return oldValue.Status, nil
  5707. }
  5708. // AddStatus adds u to the "status" field.
  5709. func (m *BatchMsgMutation) AddStatus(u int8) {
  5710. if m.addstatus != nil {
  5711. *m.addstatus += u
  5712. } else {
  5713. m.addstatus = &u
  5714. }
  5715. }
  5716. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5717. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5718. v := m.addstatus
  5719. if v == nil {
  5720. return
  5721. }
  5722. return *v, true
  5723. }
  5724. // ClearStatus clears the value of the "status" field.
  5725. func (m *BatchMsgMutation) ClearStatus() {
  5726. m.status = nil
  5727. m.addstatus = nil
  5728. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5729. }
  5730. // StatusCleared returns if the "status" field was cleared in this mutation.
  5731. func (m *BatchMsgMutation) StatusCleared() bool {
  5732. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5733. return ok
  5734. }
  5735. // ResetStatus resets all changes to the "status" field.
  5736. func (m *BatchMsgMutation) ResetStatus() {
  5737. m.status = nil
  5738. m.addstatus = nil
  5739. delete(m.clearedFields, batchmsg.FieldStatus)
  5740. }
  5741. // SetBatchNo sets the "batch_no" field.
  5742. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5743. m.batch_no = &s
  5744. }
  5745. // BatchNo returns the value of the "batch_no" field in the mutation.
  5746. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5747. v := m.batch_no
  5748. if v == nil {
  5749. return
  5750. }
  5751. return *v, true
  5752. }
  5753. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5756. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5757. if !m.op.Is(OpUpdateOne) {
  5758. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5759. }
  5760. if m.id == nil || m.oldValue == nil {
  5761. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5762. }
  5763. oldValue, err := m.oldValue(ctx)
  5764. if err != nil {
  5765. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5766. }
  5767. return oldValue.BatchNo, nil
  5768. }
  5769. // ClearBatchNo clears the value of the "batch_no" field.
  5770. func (m *BatchMsgMutation) ClearBatchNo() {
  5771. m.batch_no = nil
  5772. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5773. }
  5774. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5775. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5776. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5777. return ok
  5778. }
  5779. // ResetBatchNo resets all changes to the "batch_no" field.
  5780. func (m *BatchMsgMutation) ResetBatchNo() {
  5781. m.batch_no = nil
  5782. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5783. }
  5784. // SetTaskName sets the "task_name" field.
  5785. func (m *BatchMsgMutation) SetTaskName(s string) {
  5786. m.task_name = &s
  5787. }
  5788. // TaskName returns the value of the "task_name" field in the mutation.
  5789. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5790. v := m.task_name
  5791. if v == nil {
  5792. return
  5793. }
  5794. return *v, true
  5795. }
  5796. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5797. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5799. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5800. if !m.op.Is(OpUpdateOne) {
  5801. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5802. }
  5803. if m.id == nil || m.oldValue == nil {
  5804. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5805. }
  5806. oldValue, err := m.oldValue(ctx)
  5807. if err != nil {
  5808. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5809. }
  5810. return oldValue.TaskName, nil
  5811. }
  5812. // ClearTaskName clears the value of the "task_name" field.
  5813. func (m *BatchMsgMutation) ClearTaskName() {
  5814. m.task_name = nil
  5815. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5816. }
  5817. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5818. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5819. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5820. return ok
  5821. }
  5822. // ResetTaskName resets all changes to the "task_name" field.
  5823. func (m *BatchMsgMutation) ResetTaskName() {
  5824. m.task_name = nil
  5825. delete(m.clearedFields, batchmsg.FieldTaskName)
  5826. }
  5827. // SetFromwxid sets the "fromwxid" field.
  5828. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5829. m.fromwxid = &s
  5830. }
  5831. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5832. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5833. v := m.fromwxid
  5834. if v == nil {
  5835. return
  5836. }
  5837. return *v, true
  5838. }
  5839. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5840. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5842. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5843. if !m.op.Is(OpUpdateOne) {
  5844. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5845. }
  5846. if m.id == nil || m.oldValue == nil {
  5847. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5848. }
  5849. oldValue, err := m.oldValue(ctx)
  5850. if err != nil {
  5851. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5852. }
  5853. return oldValue.Fromwxid, nil
  5854. }
  5855. // ClearFromwxid clears the value of the "fromwxid" field.
  5856. func (m *BatchMsgMutation) ClearFromwxid() {
  5857. m.fromwxid = nil
  5858. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5859. }
  5860. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5861. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5862. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5863. return ok
  5864. }
  5865. // ResetFromwxid resets all changes to the "fromwxid" field.
  5866. func (m *BatchMsgMutation) ResetFromwxid() {
  5867. m.fromwxid = nil
  5868. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5869. }
  5870. // SetMsg sets the "msg" field.
  5871. func (m *BatchMsgMutation) SetMsg(s string) {
  5872. m.msg = &s
  5873. }
  5874. // Msg returns the value of the "msg" field in the mutation.
  5875. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5876. v := m.msg
  5877. if v == nil {
  5878. return
  5879. }
  5880. return *v, true
  5881. }
  5882. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5883. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5885. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5886. if !m.op.Is(OpUpdateOne) {
  5887. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5888. }
  5889. if m.id == nil || m.oldValue == nil {
  5890. return v, errors.New("OldMsg requires an ID field in the mutation")
  5891. }
  5892. oldValue, err := m.oldValue(ctx)
  5893. if err != nil {
  5894. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5895. }
  5896. return oldValue.Msg, nil
  5897. }
  5898. // ClearMsg clears the value of the "msg" field.
  5899. func (m *BatchMsgMutation) ClearMsg() {
  5900. m.msg = nil
  5901. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5902. }
  5903. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5904. func (m *BatchMsgMutation) MsgCleared() bool {
  5905. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5906. return ok
  5907. }
  5908. // ResetMsg resets all changes to the "msg" field.
  5909. func (m *BatchMsgMutation) ResetMsg() {
  5910. m.msg = nil
  5911. delete(m.clearedFields, batchmsg.FieldMsg)
  5912. }
  5913. // SetTag sets the "tag" field.
  5914. func (m *BatchMsgMutation) SetTag(s string) {
  5915. m.tag = &s
  5916. }
  5917. // Tag returns the value of the "tag" field in the mutation.
  5918. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5919. v := m.tag
  5920. if v == nil {
  5921. return
  5922. }
  5923. return *v, true
  5924. }
  5925. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5926. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5928. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5929. if !m.op.Is(OpUpdateOne) {
  5930. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5931. }
  5932. if m.id == nil || m.oldValue == nil {
  5933. return v, errors.New("OldTag requires an ID field in the mutation")
  5934. }
  5935. oldValue, err := m.oldValue(ctx)
  5936. if err != nil {
  5937. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5938. }
  5939. return oldValue.Tag, nil
  5940. }
  5941. // ClearTag clears the value of the "tag" field.
  5942. func (m *BatchMsgMutation) ClearTag() {
  5943. m.tag = nil
  5944. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5945. }
  5946. // TagCleared returns if the "tag" field was cleared in this mutation.
  5947. func (m *BatchMsgMutation) TagCleared() bool {
  5948. _, ok := m.clearedFields[batchmsg.FieldTag]
  5949. return ok
  5950. }
  5951. // ResetTag resets all changes to the "tag" field.
  5952. func (m *BatchMsgMutation) ResetTag() {
  5953. m.tag = nil
  5954. delete(m.clearedFields, batchmsg.FieldTag)
  5955. }
  5956. // SetTagids sets the "tagids" field.
  5957. func (m *BatchMsgMutation) SetTagids(s string) {
  5958. m.tagids = &s
  5959. }
  5960. // Tagids returns the value of the "tagids" field in the mutation.
  5961. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5962. v := m.tagids
  5963. if v == nil {
  5964. return
  5965. }
  5966. return *v, true
  5967. }
  5968. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5969. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5971. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5972. if !m.op.Is(OpUpdateOne) {
  5973. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5974. }
  5975. if m.id == nil || m.oldValue == nil {
  5976. return v, errors.New("OldTagids requires an ID field in the mutation")
  5977. }
  5978. oldValue, err := m.oldValue(ctx)
  5979. if err != nil {
  5980. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5981. }
  5982. return oldValue.Tagids, nil
  5983. }
  5984. // ClearTagids clears the value of the "tagids" field.
  5985. func (m *BatchMsgMutation) ClearTagids() {
  5986. m.tagids = nil
  5987. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5988. }
  5989. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5990. func (m *BatchMsgMutation) TagidsCleared() bool {
  5991. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5992. return ok
  5993. }
  5994. // ResetTagids resets all changes to the "tagids" field.
  5995. func (m *BatchMsgMutation) ResetTagids() {
  5996. m.tagids = nil
  5997. delete(m.clearedFields, batchmsg.FieldTagids)
  5998. }
  5999. // SetTotal sets the "total" field.
  6000. func (m *BatchMsgMutation) SetTotal(i int32) {
  6001. m.total = &i
  6002. m.addtotal = nil
  6003. }
  6004. // Total returns the value of the "total" field in the mutation.
  6005. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  6006. v := m.total
  6007. if v == nil {
  6008. return
  6009. }
  6010. return *v, true
  6011. }
  6012. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  6013. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6015. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  6016. if !m.op.Is(OpUpdateOne) {
  6017. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  6018. }
  6019. if m.id == nil || m.oldValue == nil {
  6020. return v, errors.New("OldTotal requires an ID field in the mutation")
  6021. }
  6022. oldValue, err := m.oldValue(ctx)
  6023. if err != nil {
  6024. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  6025. }
  6026. return oldValue.Total, nil
  6027. }
  6028. // AddTotal adds i to the "total" field.
  6029. func (m *BatchMsgMutation) AddTotal(i int32) {
  6030. if m.addtotal != nil {
  6031. *m.addtotal += i
  6032. } else {
  6033. m.addtotal = &i
  6034. }
  6035. }
  6036. // AddedTotal returns the value that was added to the "total" field in this mutation.
  6037. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  6038. v := m.addtotal
  6039. if v == nil {
  6040. return
  6041. }
  6042. return *v, true
  6043. }
  6044. // ClearTotal clears the value of the "total" field.
  6045. func (m *BatchMsgMutation) ClearTotal() {
  6046. m.total = nil
  6047. m.addtotal = nil
  6048. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  6049. }
  6050. // TotalCleared returns if the "total" field was cleared in this mutation.
  6051. func (m *BatchMsgMutation) TotalCleared() bool {
  6052. _, ok := m.clearedFields[batchmsg.FieldTotal]
  6053. return ok
  6054. }
  6055. // ResetTotal resets all changes to the "total" field.
  6056. func (m *BatchMsgMutation) ResetTotal() {
  6057. m.total = nil
  6058. m.addtotal = nil
  6059. delete(m.clearedFields, batchmsg.FieldTotal)
  6060. }
  6061. // SetSuccess sets the "success" field.
  6062. func (m *BatchMsgMutation) SetSuccess(i int32) {
  6063. m.success = &i
  6064. m.addsuccess = nil
  6065. }
  6066. // Success returns the value of the "success" field in the mutation.
  6067. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  6068. v := m.success
  6069. if v == nil {
  6070. return
  6071. }
  6072. return *v, true
  6073. }
  6074. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  6075. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6077. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6078. if !m.op.Is(OpUpdateOne) {
  6079. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6080. }
  6081. if m.id == nil || m.oldValue == nil {
  6082. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6083. }
  6084. oldValue, err := m.oldValue(ctx)
  6085. if err != nil {
  6086. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6087. }
  6088. return oldValue.Success, nil
  6089. }
  6090. // AddSuccess adds i to the "success" field.
  6091. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6092. if m.addsuccess != nil {
  6093. *m.addsuccess += i
  6094. } else {
  6095. m.addsuccess = &i
  6096. }
  6097. }
  6098. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6099. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6100. v := m.addsuccess
  6101. if v == nil {
  6102. return
  6103. }
  6104. return *v, true
  6105. }
  6106. // ClearSuccess clears the value of the "success" field.
  6107. func (m *BatchMsgMutation) ClearSuccess() {
  6108. m.success = nil
  6109. m.addsuccess = nil
  6110. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6111. }
  6112. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6113. func (m *BatchMsgMutation) SuccessCleared() bool {
  6114. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6115. return ok
  6116. }
  6117. // ResetSuccess resets all changes to the "success" field.
  6118. func (m *BatchMsgMutation) ResetSuccess() {
  6119. m.success = nil
  6120. m.addsuccess = nil
  6121. delete(m.clearedFields, batchmsg.FieldSuccess)
  6122. }
  6123. // SetFail sets the "fail" field.
  6124. func (m *BatchMsgMutation) SetFail(i int32) {
  6125. m.fail = &i
  6126. m.addfail = nil
  6127. }
  6128. // Fail returns the value of the "fail" field in the mutation.
  6129. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6130. v := m.fail
  6131. if v == nil {
  6132. return
  6133. }
  6134. return *v, true
  6135. }
  6136. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6137. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6139. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6140. if !m.op.Is(OpUpdateOne) {
  6141. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6142. }
  6143. if m.id == nil || m.oldValue == nil {
  6144. return v, errors.New("OldFail requires an ID field in the mutation")
  6145. }
  6146. oldValue, err := m.oldValue(ctx)
  6147. if err != nil {
  6148. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6149. }
  6150. return oldValue.Fail, nil
  6151. }
  6152. // AddFail adds i to the "fail" field.
  6153. func (m *BatchMsgMutation) AddFail(i int32) {
  6154. if m.addfail != nil {
  6155. *m.addfail += i
  6156. } else {
  6157. m.addfail = &i
  6158. }
  6159. }
  6160. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6161. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6162. v := m.addfail
  6163. if v == nil {
  6164. return
  6165. }
  6166. return *v, true
  6167. }
  6168. // ClearFail clears the value of the "fail" field.
  6169. func (m *BatchMsgMutation) ClearFail() {
  6170. m.fail = nil
  6171. m.addfail = nil
  6172. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6173. }
  6174. // FailCleared returns if the "fail" field was cleared in this mutation.
  6175. func (m *BatchMsgMutation) FailCleared() bool {
  6176. _, ok := m.clearedFields[batchmsg.FieldFail]
  6177. return ok
  6178. }
  6179. // ResetFail resets all changes to the "fail" field.
  6180. func (m *BatchMsgMutation) ResetFail() {
  6181. m.fail = nil
  6182. m.addfail = nil
  6183. delete(m.clearedFields, batchmsg.FieldFail)
  6184. }
  6185. // SetStartTime sets the "start_time" field.
  6186. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6187. m.start_time = &t
  6188. }
  6189. // StartTime returns the value of the "start_time" field in the mutation.
  6190. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6191. v := m.start_time
  6192. if v == nil {
  6193. return
  6194. }
  6195. return *v, true
  6196. }
  6197. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6198. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6200. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6201. if !m.op.Is(OpUpdateOne) {
  6202. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6203. }
  6204. if m.id == nil || m.oldValue == nil {
  6205. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6206. }
  6207. oldValue, err := m.oldValue(ctx)
  6208. if err != nil {
  6209. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6210. }
  6211. return oldValue.StartTime, nil
  6212. }
  6213. // ClearStartTime clears the value of the "start_time" field.
  6214. func (m *BatchMsgMutation) ClearStartTime() {
  6215. m.start_time = nil
  6216. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6217. }
  6218. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6219. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6220. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6221. return ok
  6222. }
  6223. // ResetStartTime resets all changes to the "start_time" field.
  6224. func (m *BatchMsgMutation) ResetStartTime() {
  6225. m.start_time = nil
  6226. delete(m.clearedFields, batchmsg.FieldStartTime)
  6227. }
  6228. // SetStopTime sets the "stop_time" field.
  6229. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6230. m.stop_time = &t
  6231. }
  6232. // StopTime returns the value of the "stop_time" field in the mutation.
  6233. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6234. v := m.stop_time
  6235. if v == nil {
  6236. return
  6237. }
  6238. return *v, true
  6239. }
  6240. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6241. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6243. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6244. if !m.op.Is(OpUpdateOne) {
  6245. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6246. }
  6247. if m.id == nil || m.oldValue == nil {
  6248. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6249. }
  6250. oldValue, err := m.oldValue(ctx)
  6251. if err != nil {
  6252. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6253. }
  6254. return oldValue.StopTime, nil
  6255. }
  6256. // ClearStopTime clears the value of the "stop_time" field.
  6257. func (m *BatchMsgMutation) ClearStopTime() {
  6258. m.stop_time = nil
  6259. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6260. }
  6261. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6262. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6263. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6264. return ok
  6265. }
  6266. // ResetStopTime resets all changes to the "stop_time" field.
  6267. func (m *BatchMsgMutation) ResetStopTime() {
  6268. m.stop_time = nil
  6269. delete(m.clearedFields, batchmsg.FieldStopTime)
  6270. }
  6271. // SetSendTime sets the "send_time" field.
  6272. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6273. m.send_time = &t
  6274. }
  6275. // SendTime returns the value of the "send_time" field in the mutation.
  6276. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6277. v := m.send_time
  6278. if v == nil {
  6279. return
  6280. }
  6281. return *v, true
  6282. }
  6283. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6284. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6286. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6287. if !m.op.Is(OpUpdateOne) {
  6288. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6289. }
  6290. if m.id == nil || m.oldValue == nil {
  6291. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6292. }
  6293. oldValue, err := m.oldValue(ctx)
  6294. if err != nil {
  6295. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6296. }
  6297. return oldValue.SendTime, nil
  6298. }
  6299. // ClearSendTime clears the value of the "send_time" field.
  6300. func (m *BatchMsgMutation) ClearSendTime() {
  6301. m.send_time = nil
  6302. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6303. }
  6304. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6305. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6306. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6307. return ok
  6308. }
  6309. // ResetSendTime resets all changes to the "send_time" field.
  6310. func (m *BatchMsgMutation) ResetSendTime() {
  6311. m.send_time = nil
  6312. delete(m.clearedFields, batchmsg.FieldSendTime)
  6313. }
  6314. // SetType sets the "type" field.
  6315. func (m *BatchMsgMutation) SetType(i int32) {
  6316. m._type = &i
  6317. m.add_type = nil
  6318. }
  6319. // GetType returns the value of the "type" field in the mutation.
  6320. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6321. v := m._type
  6322. if v == nil {
  6323. return
  6324. }
  6325. return *v, true
  6326. }
  6327. // OldType returns the old "type" field's value of the BatchMsg entity.
  6328. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6330. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6331. if !m.op.Is(OpUpdateOne) {
  6332. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6333. }
  6334. if m.id == nil || m.oldValue == nil {
  6335. return v, errors.New("OldType requires an ID field in the mutation")
  6336. }
  6337. oldValue, err := m.oldValue(ctx)
  6338. if err != nil {
  6339. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6340. }
  6341. return oldValue.Type, nil
  6342. }
  6343. // AddType adds i to the "type" field.
  6344. func (m *BatchMsgMutation) AddType(i int32) {
  6345. if m.add_type != nil {
  6346. *m.add_type += i
  6347. } else {
  6348. m.add_type = &i
  6349. }
  6350. }
  6351. // AddedType returns the value that was added to the "type" field in this mutation.
  6352. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6353. v := m.add_type
  6354. if v == nil {
  6355. return
  6356. }
  6357. return *v, true
  6358. }
  6359. // ClearType clears the value of the "type" field.
  6360. func (m *BatchMsgMutation) ClearType() {
  6361. m._type = nil
  6362. m.add_type = nil
  6363. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6364. }
  6365. // TypeCleared returns if the "type" field was cleared in this mutation.
  6366. func (m *BatchMsgMutation) TypeCleared() bool {
  6367. _, ok := m.clearedFields[batchmsg.FieldType]
  6368. return ok
  6369. }
  6370. // ResetType resets all changes to the "type" field.
  6371. func (m *BatchMsgMutation) ResetType() {
  6372. m._type = nil
  6373. m.add_type = nil
  6374. delete(m.clearedFields, batchmsg.FieldType)
  6375. }
  6376. // SetOrganizationID sets the "organization_id" field.
  6377. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6378. m.organization_id = &u
  6379. m.addorganization_id = nil
  6380. }
  6381. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6382. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6383. v := m.organization_id
  6384. if v == nil {
  6385. return
  6386. }
  6387. return *v, true
  6388. }
  6389. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6390. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6392. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6393. if !m.op.Is(OpUpdateOne) {
  6394. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6395. }
  6396. if m.id == nil || m.oldValue == nil {
  6397. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6398. }
  6399. oldValue, err := m.oldValue(ctx)
  6400. if err != nil {
  6401. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6402. }
  6403. return oldValue.OrganizationID, nil
  6404. }
  6405. // AddOrganizationID adds u to the "organization_id" field.
  6406. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6407. if m.addorganization_id != nil {
  6408. *m.addorganization_id += u
  6409. } else {
  6410. m.addorganization_id = &u
  6411. }
  6412. }
  6413. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6414. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6415. v := m.addorganization_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // ResetOrganizationID resets all changes to the "organization_id" field.
  6422. func (m *BatchMsgMutation) ResetOrganizationID() {
  6423. m.organization_id = nil
  6424. m.addorganization_id = nil
  6425. }
  6426. // SetCtype sets the "ctype" field.
  6427. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6428. m.ctype = &u
  6429. m.addctype = nil
  6430. }
  6431. // Ctype returns the value of the "ctype" field in the mutation.
  6432. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6433. v := m.ctype
  6434. if v == nil {
  6435. return
  6436. }
  6437. return *v, true
  6438. }
  6439. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6440. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6442. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6443. if !m.op.Is(OpUpdateOne) {
  6444. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6445. }
  6446. if m.id == nil || m.oldValue == nil {
  6447. return v, errors.New("OldCtype requires an ID field in the mutation")
  6448. }
  6449. oldValue, err := m.oldValue(ctx)
  6450. if err != nil {
  6451. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6452. }
  6453. return oldValue.Ctype, nil
  6454. }
  6455. // AddCtype adds u to the "ctype" field.
  6456. func (m *BatchMsgMutation) AddCtype(u int64) {
  6457. if m.addctype != nil {
  6458. *m.addctype += u
  6459. } else {
  6460. m.addctype = &u
  6461. }
  6462. }
  6463. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6464. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6465. v := m.addctype
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // ResetCtype resets all changes to the "ctype" field.
  6472. func (m *BatchMsgMutation) ResetCtype() {
  6473. m.ctype = nil
  6474. m.addctype = nil
  6475. }
  6476. // SetCc sets the "cc" field.
  6477. func (m *BatchMsgMutation) SetCc(s string) {
  6478. m.cc = &s
  6479. }
  6480. // Cc returns the value of the "cc" field in the mutation.
  6481. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6482. v := m.cc
  6483. if v == nil {
  6484. return
  6485. }
  6486. return *v, true
  6487. }
  6488. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6489. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6491. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6492. if !m.op.Is(OpUpdateOne) {
  6493. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6494. }
  6495. if m.id == nil || m.oldValue == nil {
  6496. return v, errors.New("OldCc requires an ID field in the mutation")
  6497. }
  6498. oldValue, err := m.oldValue(ctx)
  6499. if err != nil {
  6500. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6501. }
  6502. return oldValue.Cc, nil
  6503. }
  6504. // ClearCc clears the value of the "cc" field.
  6505. func (m *BatchMsgMutation) ClearCc() {
  6506. m.cc = nil
  6507. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6508. }
  6509. // CcCleared returns if the "cc" field was cleared in this mutation.
  6510. func (m *BatchMsgMutation) CcCleared() bool {
  6511. _, ok := m.clearedFields[batchmsg.FieldCc]
  6512. return ok
  6513. }
  6514. // ResetCc resets all changes to the "cc" field.
  6515. func (m *BatchMsgMutation) ResetCc() {
  6516. m.cc = nil
  6517. delete(m.clearedFields, batchmsg.FieldCc)
  6518. }
  6519. // SetPhone sets the "phone" field.
  6520. func (m *BatchMsgMutation) SetPhone(s string) {
  6521. m.phone = &s
  6522. }
  6523. // Phone returns the value of the "phone" field in the mutation.
  6524. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6525. v := m.phone
  6526. if v == nil {
  6527. return
  6528. }
  6529. return *v, true
  6530. }
  6531. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6532. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6534. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6535. if !m.op.Is(OpUpdateOne) {
  6536. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6537. }
  6538. if m.id == nil || m.oldValue == nil {
  6539. return v, errors.New("OldPhone requires an ID field in the mutation")
  6540. }
  6541. oldValue, err := m.oldValue(ctx)
  6542. if err != nil {
  6543. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6544. }
  6545. return oldValue.Phone, nil
  6546. }
  6547. // ClearPhone clears the value of the "phone" field.
  6548. func (m *BatchMsgMutation) ClearPhone() {
  6549. m.phone = nil
  6550. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6551. }
  6552. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6553. func (m *BatchMsgMutation) PhoneCleared() bool {
  6554. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6555. return ok
  6556. }
  6557. // ResetPhone resets all changes to the "phone" field.
  6558. func (m *BatchMsgMutation) ResetPhone() {
  6559. m.phone = nil
  6560. delete(m.clearedFields, batchmsg.FieldPhone)
  6561. }
  6562. // SetTemplateName sets the "template_name" field.
  6563. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6564. m.template_name = &s
  6565. }
  6566. // TemplateName returns the value of the "template_name" field in the mutation.
  6567. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6568. v := m.template_name
  6569. if v == nil {
  6570. return
  6571. }
  6572. return *v, true
  6573. }
  6574. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6575. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6577. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6578. if !m.op.Is(OpUpdateOne) {
  6579. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6580. }
  6581. if m.id == nil || m.oldValue == nil {
  6582. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6583. }
  6584. oldValue, err := m.oldValue(ctx)
  6585. if err != nil {
  6586. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6587. }
  6588. return oldValue.TemplateName, nil
  6589. }
  6590. // ClearTemplateName clears the value of the "template_name" field.
  6591. func (m *BatchMsgMutation) ClearTemplateName() {
  6592. m.template_name = nil
  6593. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6594. }
  6595. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6596. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6597. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6598. return ok
  6599. }
  6600. // ResetTemplateName resets all changes to the "template_name" field.
  6601. func (m *BatchMsgMutation) ResetTemplateName() {
  6602. m.template_name = nil
  6603. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6604. }
  6605. // SetTemplateCode sets the "template_code" field.
  6606. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6607. m.template_code = &s
  6608. }
  6609. // TemplateCode returns the value of the "template_code" field in the mutation.
  6610. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6611. v := m.template_code
  6612. if v == nil {
  6613. return
  6614. }
  6615. return *v, true
  6616. }
  6617. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6618. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6620. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6621. if !m.op.Is(OpUpdateOne) {
  6622. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6623. }
  6624. if m.id == nil || m.oldValue == nil {
  6625. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6626. }
  6627. oldValue, err := m.oldValue(ctx)
  6628. if err != nil {
  6629. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6630. }
  6631. return oldValue.TemplateCode, nil
  6632. }
  6633. // ClearTemplateCode clears the value of the "template_code" field.
  6634. func (m *BatchMsgMutation) ClearTemplateCode() {
  6635. m.template_code = nil
  6636. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6637. }
  6638. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6639. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6640. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6641. return ok
  6642. }
  6643. // ResetTemplateCode resets all changes to the "template_code" field.
  6644. func (m *BatchMsgMutation) ResetTemplateCode() {
  6645. m.template_code = nil
  6646. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6647. }
  6648. // SetLang sets the "lang" field.
  6649. func (m *BatchMsgMutation) SetLang(s string) {
  6650. m.lang = &s
  6651. }
  6652. // Lang returns the value of the "lang" field in the mutation.
  6653. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6654. v := m.lang
  6655. if v == nil {
  6656. return
  6657. }
  6658. return *v, true
  6659. }
  6660. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6661. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6663. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6664. if !m.op.Is(OpUpdateOne) {
  6665. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6666. }
  6667. if m.id == nil || m.oldValue == nil {
  6668. return v, errors.New("OldLang requires an ID field in the mutation")
  6669. }
  6670. oldValue, err := m.oldValue(ctx)
  6671. if err != nil {
  6672. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6673. }
  6674. return oldValue.Lang, nil
  6675. }
  6676. // ClearLang clears the value of the "lang" field.
  6677. func (m *BatchMsgMutation) ClearLang() {
  6678. m.lang = nil
  6679. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6680. }
  6681. // LangCleared returns if the "lang" field was cleared in this mutation.
  6682. func (m *BatchMsgMutation) LangCleared() bool {
  6683. _, ok := m.clearedFields[batchmsg.FieldLang]
  6684. return ok
  6685. }
  6686. // ResetLang resets all changes to the "lang" field.
  6687. func (m *BatchMsgMutation) ResetLang() {
  6688. m.lang = nil
  6689. delete(m.clearedFields, batchmsg.FieldLang)
  6690. }
  6691. // Where appends a list predicates to the BatchMsgMutation builder.
  6692. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6693. m.predicates = append(m.predicates, ps...)
  6694. }
  6695. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6696. // users can use type-assertion to append predicates that do not depend on any generated package.
  6697. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6698. p := make([]predicate.BatchMsg, len(ps))
  6699. for i := range ps {
  6700. p[i] = ps[i]
  6701. }
  6702. m.Where(p...)
  6703. }
  6704. // Op returns the operation name.
  6705. func (m *BatchMsgMutation) Op() Op {
  6706. return m.op
  6707. }
  6708. // SetOp allows setting the mutation operation.
  6709. func (m *BatchMsgMutation) SetOp(op Op) {
  6710. m.op = op
  6711. }
  6712. // Type returns the node type of this mutation (BatchMsg).
  6713. func (m *BatchMsgMutation) Type() string {
  6714. return m.typ
  6715. }
  6716. // Fields returns all fields that were changed during this mutation. Note that in
  6717. // order to get all numeric fields that were incremented/decremented, call
  6718. // AddedFields().
  6719. func (m *BatchMsgMutation) Fields() []string {
  6720. fields := make([]string, 0, 24)
  6721. if m.created_at != nil {
  6722. fields = append(fields, batchmsg.FieldCreatedAt)
  6723. }
  6724. if m.updated_at != nil {
  6725. fields = append(fields, batchmsg.FieldUpdatedAt)
  6726. }
  6727. if m.deleted_at != nil {
  6728. fields = append(fields, batchmsg.FieldDeletedAt)
  6729. }
  6730. if m.status != nil {
  6731. fields = append(fields, batchmsg.FieldStatus)
  6732. }
  6733. if m.batch_no != nil {
  6734. fields = append(fields, batchmsg.FieldBatchNo)
  6735. }
  6736. if m.task_name != nil {
  6737. fields = append(fields, batchmsg.FieldTaskName)
  6738. }
  6739. if m.fromwxid != nil {
  6740. fields = append(fields, batchmsg.FieldFromwxid)
  6741. }
  6742. if m.msg != nil {
  6743. fields = append(fields, batchmsg.FieldMsg)
  6744. }
  6745. if m.tag != nil {
  6746. fields = append(fields, batchmsg.FieldTag)
  6747. }
  6748. if m.tagids != nil {
  6749. fields = append(fields, batchmsg.FieldTagids)
  6750. }
  6751. if m.total != nil {
  6752. fields = append(fields, batchmsg.FieldTotal)
  6753. }
  6754. if m.success != nil {
  6755. fields = append(fields, batchmsg.FieldSuccess)
  6756. }
  6757. if m.fail != nil {
  6758. fields = append(fields, batchmsg.FieldFail)
  6759. }
  6760. if m.start_time != nil {
  6761. fields = append(fields, batchmsg.FieldStartTime)
  6762. }
  6763. if m.stop_time != nil {
  6764. fields = append(fields, batchmsg.FieldStopTime)
  6765. }
  6766. if m.send_time != nil {
  6767. fields = append(fields, batchmsg.FieldSendTime)
  6768. }
  6769. if m._type != nil {
  6770. fields = append(fields, batchmsg.FieldType)
  6771. }
  6772. if m.organization_id != nil {
  6773. fields = append(fields, batchmsg.FieldOrganizationID)
  6774. }
  6775. if m.ctype != nil {
  6776. fields = append(fields, batchmsg.FieldCtype)
  6777. }
  6778. if m.cc != nil {
  6779. fields = append(fields, batchmsg.FieldCc)
  6780. }
  6781. if m.phone != nil {
  6782. fields = append(fields, batchmsg.FieldPhone)
  6783. }
  6784. if m.template_name != nil {
  6785. fields = append(fields, batchmsg.FieldTemplateName)
  6786. }
  6787. if m.template_code != nil {
  6788. fields = append(fields, batchmsg.FieldTemplateCode)
  6789. }
  6790. if m.lang != nil {
  6791. fields = append(fields, batchmsg.FieldLang)
  6792. }
  6793. return fields
  6794. }
  6795. // Field returns the value of a field with the given name. The second boolean
  6796. // return value indicates that this field was not set, or was not defined in the
  6797. // schema.
  6798. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6799. switch name {
  6800. case batchmsg.FieldCreatedAt:
  6801. return m.CreatedAt()
  6802. case batchmsg.FieldUpdatedAt:
  6803. return m.UpdatedAt()
  6804. case batchmsg.FieldDeletedAt:
  6805. return m.DeletedAt()
  6806. case batchmsg.FieldStatus:
  6807. return m.Status()
  6808. case batchmsg.FieldBatchNo:
  6809. return m.BatchNo()
  6810. case batchmsg.FieldTaskName:
  6811. return m.TaskName()
  6812. case batchmsg.FieldFromwxid:
  6813. return m.Fromwxid()
  6814. case batchmsg.FieldMsg:
  6815. return m.Msg()
  6816. case batchmsg.FieldTag:
  6817. return m.Tag()
  6818. case batchmsg.FieldTagids:
  6819. return m.Tagids()
  6820. case batchmsg.FieldTotal:
  6821. return m.Total()
  6822. case batchmsg.FieldSuccess:
  6823. return m.Success()
  6824. case batchmsg.FieldFail:
  6825. return m.Fail()
  6826. case batchmsg.FieldStartTime:
  6827. return m.StartTime()
  6828. case batchmsg.FieldStopTime:
  6829. return m.StopTime()
  6830. case batchmsg.FieldSendTime:
  6831. return m.SendTime()
  6832. case batchmsg.FieldType:
  6833. return m.GetType()
  6834. case batchmsg.FieldOrganizationID:
  6835. return m.OrganizationID()
  6836. case batchmsg.FieldCtype:
  6837. return m.Ctype()
  6838. case batchmsg.FieldCc:
  6839. return m.Cc()
  6840. case batchmsg.FieldPhone:
  6841. return m.Phone()
  6842. case batchmsg.FieldTemplateName:
  6843. return m.TemplateName()
  6844. case batchmsg.FieldTemplateCode:
  6845. return m.TemplateCode()
  6846. case batchmsg.FieldLang:
  6847. return m.Lang()
  6848. }
  6849. return nil, false
  6850. }
  6851. // OldField returns the old value of the field from the database. An error is
  6852. // returned if the mutation operation is not UpdateOne, or the query to the
  6853. // database failed.
  6854. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6855. switch name {
  6856. case batchmsg.FieldCreatedAt:
  6857. return m.OldCreatedAt(ctx)
  6858. case batchmsg.FieldUpdatedAt:
  6859. return m.OldUpdatedAt(ctx)
  6860. case batchmsg.FieldDeletedAt:
  6861. return m.OldDeletedAt(ctx)
  6862. case batchmsg.FieldStatus:
  6863. return m.OldStatus(ctx)
  6864. case batchmsg.FieldBatchNo:
  6865. return m.OldBatchNo(ctx)
  6866. case batchmsg.FieldTaskName:
  6867. return m.OldTaskName(ctx)
  6868. case batchmsg.FieldFromwxid:
  6869. return m.OldFromwxid(ctx)
  6870. case batchmsg.FieldMsg:
  6871. return m.OldMsg(ctx)
  6872. case batchmsg.FieldTag:
  6873. return m.OldTag(ctx)
  6874. case batchmsg.FieldTagids:
  6875. return m.OldTagids(ctx)
  6876. case batchmsg.FieldTotal:
  6877. return m.OldTotal(ctx)
  6878. case batchmsg.FieldSuccess:
  6879. return m.OldSuccess(ctx)
  6880. case batchmsg.FieldFail:
  6881. return m.OldFail(ctx)
  6882. case batchmsg.FieldStartTime:
  6883. return m.OldStartTime(ctx)
  6884. case batchmsg.FieldStopTime:
  6885. return m.OldStopTime(ctx)
  6886. case batchmsg.FieldSendTime:
  6887. return m.OldSendTime(ctx)
  6888. case batchmsg.FieldType:
  6889. return m.OldType(ctx)
  6890. case batchmsg.FieldOrganizationID:
  6891. return m.OldOrganizationID(ctx)
  6892. case batchmsg.FieldCtype:
  6893. return m.OldCtype(ctx)
  6894. case batchmsg.FieldCc:
  6895. return m.OldCc(ctx)
  6896. case batchmsg.FieldPhone:
  6897. return m.OldPhone(ctx)
  6898. case batchmsg.FieldTemplateName:
  6899. return m.OldTemplateName(ctx)
  6900. case batchmsg.FieldTemplateCode:
  6901. return m.OldTemplateCode(ctx)
  6902. case batchmsg.FieldLang:
  6903. return m.OldLang(ctx)
  6904. }
  6905. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6906. }
  6907. // SetField sets the value of a field with the given name. It returns an error if
  6908. // the field is not defined in the schema, or if the type mismatched the field
  6909. // type.
  6910. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6911. switch name {
  6912. case batchmsg.FieldCreatedAt:
  6913. v, ok := value.(time.Time)
  6914. if !ok {
  6915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6916. }
  6917. m.SetCreatedAt(v)
  6918. return nil
  6919. case batchmsg.FieldUpdatedAt:
  6920. v, ok := value.(time.Time)
  6921. if !ok {
  6922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6923. }
  6924. m.SetUpdatedAt(v)
  6925. return nil
  6926. case batchmsg.FieldDeletedAt:
  6927. v, ok := value.(time.Time)
  6928. if !ok {
  6929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6930. }
  6931. m.SetDeletedAt(v)
  6932. return nil
  6933. case batchmsg.FieldStatus:
  6934. v, ok := value.(uint8)
  6935. if !ok {
  6936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6937. }
  6938. m.SetStatus(v)
  6939. return nil
  6940. case batchmsg.FieldBatchNo:
  6941. v, ok := value.(string)
  6942. if !ok {
  6943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6944. }
  6945. m.SetBatchNo(v)
  6946. return nil
  6947. case batchmsg.FieldTaskName:
  6948. v, ok := value.(string)
  6949. if !ok {
  6950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6951. }
  6952. m.SetTaskName(v)
  6953. return nil
  6954. case batchmsg.FieldFromwxid:
  6955. v, ok := value.(string)
  6956. if !ok {
  6957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6958. }
  6959. m.SetFromwxid(v)
  6960. return nil
  6961. case batchmsg.FieldMsg:
  6962. v, ok := value.(string)
  6963. if !ok {
  6964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6965. }
  6966. m.SetMsg(v)
  6967. return nil
  6968. case batchmsg.FieldTag:
  6969. v, ok := value.(string)
  6970. if !ok {
  6971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6972. }
  6973. m.SetTag(v)
  6974. return nil
  6975. case batchmsg.FieldTagids:
  6976. v, ok := value.(string)
  6977. if !ok {
  6978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6979. }
  6980. m.SetTagids(v)
  6981. return nil
  6982. case batchmsg.FieldTotal:
  6983. v, ok := value.(int32)
  6984. if !ok {
  6985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6986. }
  6987. m.SetTotal(v)
  6988. return nil
  6989. case batchmsg.FieldSuccess:
  6990. v, ok := value.(int32)
  6991. if !ok {
  6992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6993. }
  6994. m.SetSuccess(v)
  6995. return nil
  6996. case batchmsg.FieldFail:
  6997. v, ok := value.(int32)
  6998. if !ok {
  6999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7000. }
  7001. m.SetFail(v)
  7002. return nil
  7003. case batchmsg.FieldStartTime:
  7004. v, ok := value.(time.Time)
  7005. if !ok {
  7006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7007. }
  7008. m.SetStartTime(v)
  7009. return nil
  7010. case batchmsg.FieldStopTime:
  7011. v, ok := value.(time.Time)
  7012. if !ok {
  7013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7014. }
  7015. m.SetStopTime(v)
  7016. return nil
  7017. case batchmsg.FieldSendTime:
  7018. v, ok := value.(time.Time)
  7019. if !ok {
  7020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7021. }
  7022. m.SetSendTime(v)
  7023. return nil
  7024. case batchmsg.FieldType:
  7025. v, ok := value.(int32)
  7026. if !ok {
  7027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7028. }
  7029. m.SetType(v)
  7030. return nil
  7031. case batchmsg.FieldOrganizationID:
  7032. v, ok := value.(uint64)
  7033. if !ok {
  7034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7035. }
  7036. m.SetOrganizationID(v)
  7037. return nil
  7038. case batchmsg.FieldCtype:
  7039. v, ok := value.(uint64)
  7040. if !ok {
  7041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7042. }
  7043. m.SetCtype(v)
  7044. return nil
  7045. case batchmsg.FieldCc:
  7046. v, ok := value.(string)
  7047. if !ok {
  7048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7049. }
  7050. m.SetCc(v)
  7051. return nil
  7052. case batchmsg.FieldPhone:
  7053. v, ok := value.(string)
  7054. if !ok {
  7055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7056. }
  7057. m.SetPhone(v)
  7058. return nil
  7059. case batchmsg.FieldTemplateName:
  7060. v, ok := value.(string)
  7061. if !ok {
  7062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7063. }
  7064. m.SetTemplateName(v)
  7065. return nil
  7066. case batchmsg.FieldTemplateCode:
  7067. v, ok := value.(string)
  7068. if !ok {
  7069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7070. }
  7071. m.SetTemplateCode(v)
  7072. return nil
  7073. case batchmsg.FieldLang:
  7074. v, ok := value.(string)
  7075. if !ok {
  7076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7077. }
  7078. m.SetLang(v)
  7079. return nil
  7080. }
  7081. return fmt.Errorf("unknown BatchMsg field %s", name)
  7082. }
  7083. // AddedFields returns all numeric fields that were incremented/decremented during
  7084. // this mutation.
  7085. func (m *BatchMsgMutation) AddedFields() []string {
  7086. var fields []string
  7087. if m.addstatus != nil {
  7088. fields = append(fields, batchmsg.FieldStatus)
  7089. }
  7090. if m.addtotal != nil {
  7091. fields = append(fields, batchmsg.FieldTotal)
  7092. }
  7093. if m.addsuccess != nil {
  7094. fields = append(fields, batchmsg.FieldSuccess)
  7095. }
  7096. if m.addfail != nil {
  7097. fields = append(fields, batchmsg.FieldFail)
  7098. }
  7099. if m.add_type != nil {
  7100. fields = append(fields, batchmsg.FieldType)
  7101. }
  7102. if m.addorganization_id != nil {
  7103. fields = append(fields, batchmsg.FieldOrganizationID)
  7104. }
  7105. if m.addctype != nil {
  7106. fields = append(fields, batchmsg.FieldCtype)
  7107. }
  7108. return fields
  7109. }
  7110. // AddedField returns the numeric value that was incremented/decremented on a field
  7111. // with the given name. The second boolean return value indicates that this field
  7112. // was not set, or was not defined in the schema.
  7113. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7114. switch name {
  7115. case batchmsg.FieldStatus:
  7116. return m.AddedStatus()
  7117. case batchmsg.FieldTotal:
  7118. return m.AddedTotal()
  7119. case batchmsg.FieldSuccess:
  7120. return m.AddedSuccess()
  7121. case batchmsg.FieldFail:
  7122. return m.AddedFail()
  7123. case batchmsg.FieldType:
  7124. return m.AddedType()
  7125. case batchmsg.FieldOrganizationID:
  7126. return m.AddedOrganizationID()
  7127. case batchmsg.FieldCtype:
  7128. return m.AddedCtype()
  7129. }
  7130. return nil, false
  7131. }
  7132. // AddField adds the value to the field with the given name. It returns an error if
  7133. // the field is not defined in the schema, or if the type mismatched the field
  7134. // type.
  7135. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7136. switch name {
  7137. case batchmsg.FieldStatus:
  7138. v, ok := value.(int8)
  7139. if !ok {
  7140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7141. }
  7142. m.AddStatus(v)
  7143. return nil
  7144. case batchmsg.FieldTotal:
  7145. v, ok := value.(int32)
  7146. if !ok {
  7147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7148. }
  7149. m.AddTotal(v)
  7150. return nil
  7151. case batchmsg.FieldSuccess:
  7152. v, ok := value.(int32)
  7153. if !ok {
  7154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7155. }
  7156. m.AddSuccess(v)
  7157. return nil
  7158. case batchmsg.FieldFail:
  7159. v, ok := value.(int32)
  7160. if !ok {
  7161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7162. }
  7163. m.AddFail(v)
  7164. return nil
  7165. case batchmsg.FieldType:
  7166. v, ok := value.(int32)
  7167. if !ok {
  7168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7169. }
  7170. m.AddType(v)
  7171. return nil
  7172. case batchmsg.FieldOrganizationID:
  7173. v, ok := value.(int64)
  7174. if !ok {
  7175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7176. }
  7177. m.AddOrganizationID(v)
  7178. return nil
  7179. case batchmsg.FieldCtype:
  7180. v, ok := value.(int64)
  7181. if !ok {
  7182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7183. }
  7184. m.AddCtype(v)
  7185. return nil
  7186. }
  7187. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7188. }
  7189. // ClearedFields returns all nullable fields that were cleared during this
  7190. // mutation.
  7191. func (m *BatchMsgMutation) ClearedFields() []string {
  7192. var fields []string
  7193. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7194. fields = append(fields, batchmsg.FieldDeletedAt)
  7195. }
  7196. if m.FieldCleared(batchmsg.FieldStatus) {
  7197. fields = append(fields, batchmsg.FieldStatus)
  7198. }
  7199. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7200. fields = append(fields, batchmsg.FieldBatchNo)
  7201. }
  7202. if m.FieldCleared(batchmsg.FieldTaskName) {
  7203. fields = append(fields, batchmsg.FieldTaskName)
  7204. }
  7205. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7206. fields = append(fields, batchmsg.FieldFromwxid)
  7207. }
  7208. if m.FieldCleared(batchmsg.FieldMsg) {
  7209. fields = append(fields, batchmsg.FieldMsg)
  7210. }
  7211. if m.FieldCleared(batchmsg.FieldTag) {
  7212. fields = append(fields, batchmsg.FieldTag)
  7213. }
  7214. if m.FieldCleared(batchmsg.FieldTagids) {
  7215. fields = append(fields, batchmsg.FieldTagids)
  7216. }
  7217. if m.FieldCleared(batchmsg.FieldTotal) {
  7218. fields = append(fields, batchmsg.FieldTotal)
  7219. }
  7220. if m.FieldCleared(batchmsg.FieldSuccess) {
  7221. fields = append(fields, batchmsg.FieldSuccess)
  7222. }
  7223. if m.FieldCleared(batchmsg.FieldFail) {
  7224. fields = append(fields, batchmsg.FieldFail)
  7225. }
  7226. if m.FieldCleared(batchmsg.FieldStartTime) {
  7227. fields = append(fields, batchmsg.FieldStartTime)
  7228. }
  7229. if m.FieldCleared(batchmsg.FieldStopTime) {
  7230. fields = append(fields, batchmsg.FieldStopTime)
  7231. }
  7232. if m.FieldCleared(batchmsg.FieldSendTime) {
  7233. fields = append(fields, batchmsg.FieldSendTime)
  7234. }
  7235. if m.FieldCleared(batchmsg.FieldType) {
  7236. fields = append(fields, batchmsg.FieldType)
  7237. }
  7238. if m.FieldCleared(batchmsg.FieldCc) {
  7239. fields = append(fields, batchmsg.FieldCc)
  7240. }
  7241. if m.FieldCleared(batchmsg.FieldPhone) {
  7242. fields = append(fields, batchmsg.FieldPhone)
  7243. }
  7244. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7245. fields = append(fields, batchmsg.FieldTemplateName)
  7246. }
  7247. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7248. fields = append(fields, batchmsg.FieldTemplateCode)
  7249. }
  7250. if m.FieldCleared(batchmsg.FieldLang) {
  7251. fields = append(fields, batchmsg.FieldLang)
  7252. }
  7253. return fields
  7254. }
  7255. // FieldCleared returns a boolean indicating if a field with the given name was
  7256. // cleared in this mutation.
  7257. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7258. _, ok := m.clearedFields[name]
  7259. return ok
  7260. }
  7261. // ClearField clears the value of the field with the given name. It returns an
  7262. // error if the field is not defined in the schema.
  7263. func (m *BatchMsgMutation) ClearField(name string) error {
  7264. switch name {
  7265. case batchmsg.FieldDeletedAt:
  7266. m.ClearDeletedAt()
  7267. return nil
  7268. case batchmsg.FieldStatus:
  7269. m.ClearStatus()
  7270. return nil
  7271. case batchmsg.FieldBatchNo:
  7272. m.ClearBatchNo()
  7273. return nil
  7274. case batchmsg.FieldTaskName:
  7275. m.ClearTaskName()
  7276. return nil
  7277. case batchmsg.FieldFromwxid:
  7278. m.ClearFromwxid()
  7279. return nil
  7280. case batchmsg.FieldMsg:
  7281. m.ClearMsg()
  7282. return nil
  7283. case batchmsg.FieldTag:
  7284. m.ClearTag()
  7285. return nil
  7286. case batchmsg.FieldTagids:
  7287. m.ClearTagids()
  7288. return nil
  7289. case batchmsg.FieldTotal:
  7290. m.ClearTotal()
  7291. return nil
  7292. case batchmsg.FieldSuccess:
  7293. m.ClearSuccess()
  7294. return nil
  7295. case batchmsg.FieldFail:
  7296. m.ClearFail()
  7297. return nil
  7298. case batchmsg.FieldStartTime:
  7299. m.ClearStartTime()
  7300. return nil
  7301. case batchmsg.FieldStopTime:
  7302. m.ClearStopTime()
  7303. return nil
  7304. case batchmsg.FieldSendTime:
  7305. m.ClearSendTime()
  7306. return nil
  7307. case batchmsg.FieldType:
  7308. m.ClearType()
  7309. return nil
  7310. case batchmsg.FieldCc:
  7311. m.ClearCc()
  7312. return nil
  7313. case batchmsg.FieldPhone:
  7314. m.ClearPhone()
  7315. return nil
  7316. case batchmsg.FieldTemplateName:
  7317. m.ClearTemplateName()
  7318. return nil
  7319. case batchmsg.FieldTemplateCode:
  7320. m.ClearTemplateCode()
  7321. return nil
  7322. case batchmsg.FieldLang:
  7323. m.ClearLang()
  7324. return nil
  7325. }
  7326. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7327. }
  7328. // ResetField resets all changes in the mutation for the field with the given name.
  7329. // It returns an error if the field is not defined in the schema.
  7330. func (m *BatchMsgMutation) ResetField(name string) error {
  7331. switch name {
  7332. case batchmsg.FieldCreatedAt:
  7333. m.ResetCreatedAt()
  7334. return nil
  7335. case batchmsg.FieldUpdatedAt:
  7336. m.ResetUpdatedAt()
  7337. return nil
  7338. case batchmsg.FieldDeletedAt:
  7339. m.ResetDeletedAt()
  7340. return nil
  7341. case batchmsg.FieldStatus:
  7342. m.ResetStatus()
  7343. return nil
  7344. case batchmsg.FieldBatchNo:
  7345. m.ResetBatchNo()
  7346. return nil
  7347. case batchmsg.FieldTaskName:
  7348. m.ResetTaskName()
  7349. return nil
  7350. case batchmsg.FieldFromwxid:
  7351. m.ResetFromwxid()
  7352. return nil
  7353. case batchmsg.FieldMsg:
  7354. m.ResetMsg()
  7355. return nil
  7356. case batchmsg.FieldTag:
  7357. m.ResetTag()
  7358. return nil
  7359. case batchmsg.FieldTagids:
  7360. m.ResetTagids()
  7361. return nil
  7362. case batchmsg.FieldTotal:
  7363. m.ResetTotal()
  7364. return nil
  7365. case batchmsg.FieldSuccess:
  7366. m.ResetSuccess()
  7367. return nil
  7368. case batchmsg.FieldFail:
  7369. m.ResetFail()
  7370. return nil
  7371. case batchmsg.FieldStartTime:
  7372. m.ResetStartTime()
  7373. return nil
  7374. case batchmsg.FieldStopTime:
  7375. m.ResetStopTime()
  7376. return nil
  7377. case batchmsg.FieldSendTime:
  7378. m.ResetSendTime()
  7379. return nil
  7380. case batchmsg.FieldType:
  7381. m.ResetType()
  7382. return nil
  7383. case batchmsg.FieldOrganizationID:
  7384. m.ResetOrganizationID()
  7385. return nil
  7386. case batchmsg.FieldCtype:
  7387. m.ResetCtype()
  7388. return nil
  7389. case batchmsg.FieldCc:
  7390. m.ResetCc()
  7391. return nil
  7392. case batchmsg.FieldPhone:
  7393. m.ResetPhone()
  7394. return nil
  7395. case batchmsg.FieldTemplateName:
  7396. m.ResetTemplateName()
  7397. return nil
  7398. case batchmsg.FieldTemplateCode:
  7399. m.ResetTemplateCode()
  7400. return nil
  7401. case batchmsg.FieldLang:
  7402. m.ResetLang()
  7403. return nil
  7404. }
  7405. return fmt.Errorf("unknown BatchMsg field %s", name)
  7406. }
  7407. // AddedEdges returns all edge names that were set/added in this mutation.
  7408. func (m *BatchMsgMutation) AddedEdges() []string {
  7409. edges := make([]string, 0, 0)
  7410. return edges
  7411. }
  7412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7413. // name in this mutation.
  7414. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7415. return nil
  7416. }
  7417. // RemovedEdges returns all edge names that were removed in this mutation.
  7418. func (m *BatchMsgMutation) RemovedEdges() []string {
  7419. edges := make([]string, 0, 0)
  7420. return edges
  7421. }
  7422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7423. // the given name in this mutation.
  7424. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7425. return nil
  7426. }
  7427. // ClearedEdges returns all edge names that were cleared in this mutation.
  7428. func (m *BatchMsgMutation) ClearedEdges() []string {
  7429. edges := make([]string, 0, 0)
  7430. return edges
  7431. }
  7432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7433. // was cleared in this mutation.
  7434. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7435. return false
  7436. }
  7437. // ClearEdge clears the value of the edge with the given name. It returns an error
  7438. // if that edge is not defined in the schema.
  7439. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7440. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7441. }
  7442. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7443. // It returns an error if the edge is not defined in the schema.
  7444. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7445. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7446. }
  7447. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7448. type CategoryMutation struct {
  7449. config
  7450. op Op
  7451. typ string
  7452. id *uint64
  7453. created_at *time.Time
  7454. updated_at *time.Time
  7455. deleted_at *time.Time
  7456. name *string
  7457. organization_id *uint64
  7458. addorganization_id *int64
  7459. clearedFields map[string]struct{}
  7460. done bool
  7461. oldValue func(context.Context) (*Category, error)
  7462. predicates []predicate.Category
  7463. }
  7464. var _ ent.Mutation = (*CategoryMutation)(nil)
  7465. // categoryOption allows management of the mutation configuration using functional options.
  7466. type categoryOption func(*CategoryMutation)
  7467. // newCategoryMutation creates new mutation for the Category entity.
  7468. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7469. m := &CategoryMutation{
  7470. config: c,
  7471. op: op,
  7472. typ: TypeCategory,
  7473. clearedFields: make(map[string]struct{}),
  7474. }
  7475. for _, opt := range opts {
  7476. opt(m)
  7477. }
  7478. return m
  7479. }
  7480. // withCategoryID sets the ID field of the mutation.
  7481. func withCategoryID(id uint64) categoryOption {
  7482. return func(m *CategoryMutation) {
  7483. var (
  7484. err error
  7485. once sync.Once
  7486. value *Category
  7487. )
  7488. m.oldValue = func(ctx context.Context) (*Category, error) {
  7489. once.Do(func() {
  7490. if m.done {
  7491. err = errors.New("querying old values post mutation is not allowed")
  7492. } else {
  7493. value, err = m.Client().Category.Get(ctx, id)
  7494. }
  7495. })
  7496. return value, err
  7497. }
  7498. m.id = &id
  7499. }
  7500. }
  7501. // withCategory sets the old Category of the mutation.
  7502. func withCategory(node *Category) categoryOption {
  7503. return func(m *CategoryMutation) {
  7504. m.oldValue = func(context.Context) (*Category, error) {
  7505. return node, nil
  7506. }
  7507. m.id = &node.ID
  7508. }
  7509. }
  7510. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7511. // executed in a transaction (ent.Tx), a transactional client is returned.
  7512. func (m CategoryMutation) Client() *Client {
  7513. client := &Client{config: m.config}
  7514. client.init()
  7515. return client
  7516. }
  7517. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7518. // it returns an error otherwise.
  7519. func (m CategoryMutation) Tx() (*Tx, error) {
  7520. if _, ok := m.driver.(*txDriver); !ok {
  7521. return nil, errors.New("ent: mutation is not running in a transaction")
  7522. }
  7523. tx := &Tx{config: m.config}
  7524. tx.init()
  7525. return tx, nil
  7526. }
  7527. // SetID sets the value of the id field. Note that this
  7528. // operation is only accepted on creation of Category entities.
  7529. func (m *CategoryMutation) SetID(id uint64) {
  7530. m.id = &id
  7531. }
  7532. // ID returns the ID value in the mutation. Note that the ID is only available
  7533. // if it was provided to the builder or after it was returned from the database.
  7534. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7535. if m.id == nil {
  7536. return
  7537. }
  7538. return *m.id, true
  7539. }
  7540. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7541. // That means, if the mutation is applied within a transaction with an isolation level such
  7542. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7543. // or updated by the mutation.
  7544. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7545. switch {
  7546. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7547. id, exists := m.ID()
  7548. if exists {
  7549. return []uint64{id}, nil
  7550. }
  7551. fallthrough
  7552. case m.op.Is(OpUpdate | OpDelete):
  7553. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7554. default:
  7555. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7556. }
  7557. }
  7558. // SetCreatedAt sets the "created_at" field.
  7559. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7560. m.created_at = &t
  7561. }
  7562. // CreatedAt returns the value of the "created_at" field in the mutation.
  7563. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7564. v := m.created_at
  7565. if v == nil {
  7566. return
  7567. }
  7568. return *v, true
  7569. }
  7570. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7571. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7573. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7574. if !m.op.Is(OpUpdateOne) {
  7575. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7576. }
  7577. if m.id == nil || m.oldValue == nil {
  7578. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7579. }
  7580. oldValue, err := m.oldValue(ctx)
  7581. if err != nil {
  7582. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7583. }
  7584. return oldValue.CreatedAt, nil
  7585. }
  7586. // ResetCreatedAt resets all changes to the "created_at" field.
  7587. func (m *CategoryMutation) ResetCreatedAt() {
  7588. m.created_at = nil
  7589. }
  7590. // SetUpdatedAt sets the "updated_at" field.
  7591. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7592. m.updated_at = &t
  7593. }
  7594. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7595. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7596. v := m.updated_at
  7597. if v == nil {
  7598. return
  7599. }
  7600. return *v, true
  7601. }
  7602. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7603. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7605. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7606. if !m.op.Is(OpUpdateOne) {
  7607. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7608. }
  7609. if m.id == nil || m.oldValue == nil {
  7610. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7611. }
  7612. oldValue, err := m.oldValue(ctx)
  7613. if err != nil {
  7614. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7615. }
  7616. return oldValue.UpdatedAt, nil
  7617. }
  7618. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7619. func (m *CategoryMutation) ResetUpdatedAt() {
  7620. m.updated_at = nil
  7621. }
  7622. // SetDeletedAt sets the "deleted_at" field.
  7623. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7624. m.deleted_at = &t
  7625. }
  7626. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7627. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7628. v := m.deleted_at
  7629. if v == nil {
  7630. return
  7631. }
  7632. return *v, true
  7633. }
  7634. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7635. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7637. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7638. if !m.op.Is(OpUpdateOne) {
  7639. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7640. }
  7641. if m.id == nil || m.oldValue == nil {
  7642. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7643. }
  7644. oldValue, err := m.oldValue(ctx)
  7645. if err != nil {
  7646. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7647. }
  7648. return oldValue.DeletedAt, nil
  7649. }
  7650. // ClearDeletedAt clears the value of the "deleted_at" field.
  7651. func (m *CategoryMutation) ClearDeletedAt() {
  7652. m.deleted_at = nil
  7653. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7654. }
  7655. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7656. func (m *CategoryMutation) DeletedAtCleared() bool {
  7657. _, ok := m.clearedFields[category.FieldDeletedAt]
  7658. return ok
  7659. }
  7660. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7661. func (m *CategoryMutation) ResetDeletedAt() {
  7662. m.deleted_at = nil
  7663. delete(m.clearedFields, category.FieldDeletedAt)
  7664. }
  7665. // SetName sets the "name" field.
  7666. func (m *CategoryMutation) SetName(s string) {
  7667. m.name = &s
  7668. }
  7669. // Name returns the value of the "name" field in the mutation.
  7670. func (m *CategoryMutation) Name() (r string, exists bool) {
  7671. v := m.name
  7672. if v == nil {
  7673. return
  7674. }
  7675. return *v, true
  7676. }
  7677. // OldName returns the old "name" field's value of the Category entity.
  7678. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7680. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7681. if !m.op.Is(OpUpdateOne) {
  7682. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7683. }
  7684. if m.id == nil || m.oldValue == nil {
  7685. return v, errors.New("OldName requires an ID field in the mutation")
  7686. }
  7687. oldValue, err := m.oldValue(ctx)
  7688. if err != nil {
  7689. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7690. }
  7691. return oldValue.Name, nil
  7692. }
  7693. // ResetName resets all changes to the "name" field.
  7694. func (m *CategoryMutation) ResetName() {
  7695. m.name = nil
  7696. }
  7697. // SetOrganizationID sets the "organization_id" field.
  7698. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7699. m.organization_id = &u
  7700. m.addorganization_id = nil
  7701. }
  7702. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7703. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7704. v := m.organization_id
  7705. if v == nil {
  7706. return
  7707. }
  7708. return *v, true
  7709. }
  7710. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7711. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7713. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7714. if !m.op.Is(OpUpdateOne) {
  7715. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7716. }
  7717. if m.id == nil || m.oldValue == nil {
  7718. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7719. }
  7720. oldValue, err := m.oldValue(ctx)
  7721. if err != nil {
  7722. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7723. }
  7724. return oldValue.OrganizationID, nil
  7725. }
  7726. // AddOrganizationID adds u to the "organization_id" field.
  7727. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7728. if m.addorganization_id != nil {
  7729. *m.addorganization_id += u
  7730. } else {
  7731. m.addorganization_id = &u
  7732. }
  7733. }
  7734. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7735. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7736. v := m.addorganization_id
  7737. if v == nil {
  7738. return
  7739. }
  7740. return *v, true
  7741. }
  7742. // ResetOrganizationID resets all changes to the "organization_id" field.
  7743. func (m *CategoryMutation) ResetOrganizationID() {
  7744. m.organization_id = nil
  7745. m.addorganization_id = nil
  7746. }
  7747. // Where appends a list predicates to the CategoryMutation builder.
  7748. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7749. m.predicates = append(m.predicates, ps...)
  7750. }
  7751. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7752. // users can use type-assertion to append predicates that do not depend on any generated package.
  7753. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7754. p := make([]predicate.Category, len(ps))
  7755. for i := range ps {
  7756. p[i] = ps[i]
  7757. }
  7758. m.Where(p...)
  7759. }
  7760. // Op returns the operation name.
  7761. func (m *CategoryMutation) Op() Op {
  7762. return m.op
  7763. }
  7764. // SetOp allows setting the mutation operation.
  7765. func (m *CategoryMutation) SetOp(op Op) {
  7766. m.op = op
  7767. }
  7768. // Type returns the node type of this mutation (Category).
  7769. func (m *CategoryMutation) Type() string {
  7770. return m.typ
  7771. }
  7772. // Fields returns all fields that were changed during this mutation. Note that in
  7773. // order to get all numeric fields that were incremented/decremented, call
  7774. // AddedFields().
  7775. func (m *CategoryMutation) Fields() []string {
  7776. fields := make([]string, 0, 5)
  7777. if m.created_at != nil {
  7778. fields = append(fields, category.FieldCreatedAt)
  7779. }
  7780. if m.updated_at != nil {
  7781. fields = append(fields, category.FieldUpdatedAt)
  7782. }
  7783. if m.deleted_at != nil {
  7784. fields = append(fields, category.FieldDeletedAt)
  7785. }
  7786. if m.name != nil {
  7787. fields = append(fields, category.FieldName)
  7788. }
  7789. if m.organization_id != nil {
  7790. fields = append(fields, category.FieldOrganizationID)
  7791. }
  7792. return fields
  7793. }
  7794. // Field returns the value of a field with the given name. The second boolean
  7795. // return value indicates that this field was not set, or was not defined in the
  7796. // schema.
  7797. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7798. switch name {
  7799. case category.FieldCreatedAt:
  7800. return m.CreatedAt()
  7801. case category.FieldUpdatedAt:
  7802. return m.UpdatedAt()
  7803. case category.FieldDeletedAt:
  7804. return m.DeletedAt()
  7805. case category.FieldName:
  7806. return m.Name()
  7807. case category.FieldOrganizationID:
  7808. return m.OrganizationID()
  7809. }
  7810. return nil, false
  7811. }
  7812. // OldField returns the old value of the field from the database. An error is
  7813. // returned if the mutation operation is not UpdateOne, or the query to the
  7814. // database failed.
  7815. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7816. switch name {
  7817. case category.FieldCreatedAt:
  7818. return m.OldCreatedAt(ctx)
  7819. case category.FieldUpdatedAt:
  7820. return m.OldUpdatedAt(ctx)
  7821. case category.FieldDeletedAt:
  7822. return m.OldDeletedAt(ctx)
  7823. case category.FieldName:
  7824. return m.OldName(ctx)
  7825. case category.FieldOrganizationID:
  7826. return m.OldOrganizationID(ctx)
  7827. }
  7828. return nil, fmt.Errorf("unknown Category field %s", name)
  7829. }
  7830. // SetField sets the value of a field with the given name. It returns an error if
  7831. // the field is not defined in the schema, or if the type mismatched the field
  7832. // type.
  7833. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7834. switch name {
  7835. case category.FieldCreatedAt:
  7836. v, ok := value.(time.Time)
  7837. if !ok {
  7838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7839. }
  7840. m.SetCreatedAt(v)
  7841. return nil
  7842. case category.FieldUpdatedAt:
  7843. v, ok := value.(time.Time)
  7844. if !ok {
  7845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7846. }
  7847. m.SetUpdatedAt(v)
  7848. return nil
  7849. case category.FieldDeletedAt:
  7850. v, ok := value.(time.Time)
  7851. if !ok {
  7852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7853. }
  7854. m.SetDeletedAt(v)
  7855. return nil
  7856. case category.FieldName:
  7857. v, ok := value.(string)
  7858. if !ok {
  7859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7860. }
  7861. m.SetName(v)
  7862. return nil
  7863. case category.FieldOrganizationID:
  7864. v, ok := value.(uint64)
  7865. if !ok {
  7866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7867. }
  7868. m.SetOrganizationID(v)
  7869. return nil
  7870. }
  7871. return fmt.Errorf("unknown Category field %s", name)
  7872. }
  7873. // AddedFields returns all numeric fields that were incremented/decremented during
  7874. // this mutation.
  7875. func (m *CategoryMutation) AddedFields() []string {
  7876. var fields []string
  7877. if m.addorganization_id != nil {
  7878. fields = append(fields, category.FieldOrganizationID)
  7879. }
  7880. return fields
  7881. }
  7882. // AddedField returns the numeric value that was incremented/decremented on a field
  7883. // with the given name. The second boolean return value indicates that this field
  7884. // was not set, or was not defined in the schema.
  7885. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7886. switch name {
  7887. case category.FieldOrganizationID:
  7888. return m.AddedOrganizationID()
  7889. }
  7890. return nil, false
  7891. }
  7892. // AddField adds the value to the field with the given name. It returns an error if
  7893. // the field is not defined in the schema, or if the type mismatched the field
  7894. // type.
  7895. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7896. switch name {
  7897. case category.FieldOrganizationID:
  7898. v, ok := value.(int64)
  7899. if !ok {
  7900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7901. }
  7902. m.AddOrganizationID(v)
  7903. return nil
  7904. }
  7905. return fmt.Errorf("unknown Category numeric field %s", name)
  7906. }
  7907. // ClearedFields returns all nullable fields that were cleared during this
  7908. // mutation.
  7909. func (m *CategoryMutation) ClearedFields() []string {
  7910. var fields []string
  7911. if m.FieldCleared(category.FieldDeletedAt) {
  7912. fields = append(fields, category.FieldDeletedAt)
  7913. }
  7914. return fields
  7915. }
  7916. // FieldCleared returns a boolean indicating if a field with the given name was
  7917. // cleared in this mutation.
  7918. func (m *CategoryMutation) FieldCleared(name string) bool {
  7919. _, ok := m.clearedFields[name]
  7920. return ok
  7921. }
  7922. // ClearField clears the value of the field with the given name. It returns an
  7923. // error if the field is not defined in the schema.
  7924. func (m *CategoryMutation) ClearField(name string) error {
  7925. switch name {
  7926. case category.FieldDeletedAt:
  7927. m.ClearDeletedAt()
  7928. return nil
  7929. }
  7930. return fmt.Errorf("unknown Category nullable field %s", name)
  7931. }
  7932. // ResetField resets all changes in the mutation for the field with the given name.
  7933. // It returns an error if the field is not defined in the schema.
  7934. func (m *CategoryMutation) ResetField(name string) error {
  7935. switch name {
  7936. case category.FieldCreatedAt:
  7937. m.ResetCreatedAt()
  7938. return nil
  7939. case category.FieldUpdatedAt:
  7940. m.ResetUpdatedAt()
  7941. return nil
  7942. case category.FieldDeletedAt:
  7943. m.ResetDeletedAt()
  7944. return nil
  7945. case category.FieldName:
  7946. m.ResetName()
  7947. return nil
  7948. case category.FieldOrganizationID:
  7949. m.ResetOrganizationID()
  7950. return nil
  7951. }
  7952. return fmt.Errorf("unknown Category field %s", name)
  7953. }
  7954. // AddedEdges returns all edge names that were set/added in this mutation.
  7955. func (m *CategoryMutation) AddedEdges() []string {
  7956. edges := make([]string, 0, 0)
  7957. return edges
  7958. }
  7959. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7960. // name in this mutation.
  7961. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7962. return nil
  7963. }
  7964. // RemovedEdges returns all edge names that were removed in this mutation.
  7965. func (m *CategoryMutation) RemovedEdges() []string {
  7966. edges := make([]string, 0, 0)
  7967. return edges
  7968. }
  7969. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7970. // the given name in this mutation.
  7971. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7972. return nil
  7973. }
  7974. // ClearedEdges returns all edge names that were cleared in this mutation.
  7975. func (m *CategoryMutation) ClearedEdges() []string {
  7976. edges := make([]string, 0, 0)
  7977. return edges
  7978. }
  7979. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7980. // was cleared in this mutation.
  7981. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7982. return false
  7983. }
  7984. // ClearEdge clears the value of the edge with the given name. It returns an error
  7985. // if that edge is not defined in the schema.
  7986. func (m *CategoryMutation) ClearEdge(name string) error {
  7987. return fmt.Errorf("unknown Category unique edge %s", name)
  7988. }
  7989. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7990. // It returns an error if the edge is not defined in the schema.
  7991. func (m *CategoryMutation) ResetEdge(name string) error {
  7992. return fmt.Errorf("unknown Category edge %s", name)
  7993. }
  7994. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7995. type ChatRecordsMutation struct {
  7996. config
  7997. op Op
  7998. typ string
  7999. id *uint64
  8000. created_at *time.Time
  8001. updated_at *time.Time
  8002. deleted_at *time.Time
  8003. content *string
  8004. content_type *uint8
  8005. addcontent_type *int8
  8006. session_id *uint64
  8007. addsession_id *int64
  8008. user_id *uint64
  8009. adduser_id *int64
  8010. bot_id *uint64
  8011. addbot_id *int64
  8012. bot_type *uint8
  8013. addbot_type *int8
  8014. clearedFields map[string]struct{}
  8015. done bool
  8016. oldValue func(context.Context) (*ChatRecords, error)
  8017. predicates []predicate.ChatRecords
  8018. }
  8019. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  8020. // chatrecordsOption allows management of the mutation configuration using functional options.
  8021. type chatrecordsOption func(*ChatRecordsMutation)
  8022. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  8023. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  8024. m := &ChatRecordsMutation{
  8025. config: c,
  8026. op: op,
  8027. typ: TypeChatRecords,
  8028. clearedFields: make(map[string]struct{}),
  8029. }
  8030. for _, opt := range opts {
  8031. opt(m)
  8032. }
  8033. return m
  8034. }
  8035. // withChatRecordsID sets the ID field of the mutation.
  8036. func withChatRecordsID(id uint64) chatrecordsOption {
  8037. return func(m *ChatRecordsMutation) {
  8038. var (
  8039. err error
  8040. once sync.Once
  8041. value *ChatRecords
  8042. )
  8043. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  8044. once.Do(func() {
  8045. if m.done {
  8046. err = errors.New("querying old values post mutation is not allowed")
  8047. } else {
  8048. value, err = m.Client().ChatRecords.Get(ctx, id)
  8049. }
  8050. })
  8051. return value, err
  8052. }
  8053. m.id = &id
  8054. }
  8055. }
  8056. // withChatRecords sets the old ChatRecords of the mutation.
  8057. func withChatRecords(node *ChatRecords) chatrecordsOption {
  8058. return func(m *ChatRecordsMutation) {
  8059. m.oldValue = func(context.Context) (*ChatRecords, error) {
  8060. return node, nil
  8061. }
  8062. m.id = &node.ID
  8063. }
  8064. }
  8065. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8066. // executed in a transaction (ent.Tx), a transactional client is returned.
  8067. func (m ChatRecordsMutation) Client() *Client {
  8068. client := &Client{config: m.config}
  8069. client.init()
  8070. return client
  8071. }
  8072. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8073. // it returns an error otherwise.
  8074. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  8075. if _, ok := m.driver.(*txDriver); !ok {
  8076. return nil, errors.New("ent: mutation is not running in a transaction")
  8077. }
  8078. tx := &Tx{config: m.config}
  8079. tx.init()
  8080. return tx, nil
  8081. }
  8082. // SetID sets the value of the id field. Note that this
  8083. // operation is only accepted on creation of ChatRecords entities.
  8084. func (m *ChatRecordsMutation) SetID(id uint64) {
  8085. m.id = &id
  8086. }
  8087. // ID returns the ID value in the mutation. Note that the ID is only available
  8088. // if it was provided to the builder or after it was returned from the database.
  8089. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8090. if m.id == nil {
  8091. return
  8092. }
  8093. return *m.id, true
  8094. }
  8095. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8096. // That means, if the mutation is applied within a transaction with an isolation level such
  8097. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8098. // or updated by the mutation.
  8099. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8100. switch {
  8101. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8102. id, exists := m.ID()
  8103. if exists {
  8104. return []uint64{id}, nil
  8105. }
  8106. fallthrough
  8107. case m.op.Is(OpUpdate | OpDelete):
  8108. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8109. default:
  8110. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8111. }
  8112. }
  8113. // SetCreatedAt sets the "created_at" field.
  8114. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8115. m.created_at = &t
  8116. }
  8117. // CreatedAt returns the value of the "created_at" field in the mutation.
  8118. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8119. v := m.created_at
  8120. if v == nil {
  8121. return
  8122. }
  8123. return *v, true
  8124. }
  8125. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8126. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8128. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8129. if !m.op.Is(OpUpdateOne) {
  8130. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8131. }
  8132. if m.id == nil || m.oldValue == nil {
  8133. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8134. }
  8135. oldValue, err := m.oldValue(ctx)
  8136. if err != nil {
  8137. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8138. }
  8139. return oldValue.CreatedAt, nil
  8140. }
  8141. // ResetCreatedAt resets all changes to the "created_at" field.
  8142. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8143. m.created_at = nil
  8144. }
  8145. // SetUpdatedAt sets the "updated_at" field.
  8146. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8147. m.updated_at = &t
  8148. }
  8149. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8150. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8151. v := m.updated_at
  8152. if v == nil {
  8153. return
  8154. }
  8155. return *v, true
  8156. }
  8157. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8158. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8160. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8161. if !m.op.Is(OpUpdateOne) {
  8162. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8163. }
  8164. if m.id == nil || m.oldValue == nil {
  8165. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8166. }
  8167. oldValue, err := m.oldValue(ctx)
  8168. if err != nil {
  8169. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8170. }
  8171. return oldValue.UpdatedAt, nil
  8172. }
  8173. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8174. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8175. m.updated_at = nil
  8176. }
  8177. // SetDeletedAt sets the "deleted_at" field.
  8178. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8179. m.deleted_at = &t
  8180. }
  8181. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8182. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8183. v := m.deleted_at
  8184. if v == nil {
  8185. return
  8186. }
  8187. return *v, true
  8188. }
  8189. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8190. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8192. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8193. if !m.op.Is(OpUpdateOne) {
  8194. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8195. }
  8196. if m.id == nil || m.oldValue == nil {
  8197. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8198. }
  8199. oldValue, err := m.oldValue(ctx)
  8200. if err != nil {
  8201. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8202. }
  8203. return oldValue.DeletedAt, nil
  8204. }
  8205. // ClearDeletedAt clears the value of the "deleted_at" field.
  8206. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8207. m.deleted_at = nil
  8208. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8209. }
  8210. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8211. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8212. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8213. return ok
  8214. }
  8215. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8216. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8217. m.deleted_at = nil
  8218. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8219. }
  8220. // SetContent sets the "content" field.
  8221. func (m *ChatRecordsMutation) SetContent(s string) {
  8222. m.content = &s
  8223. }
  8224. // Content returns the value of the "content" field in the mutation.
  8225. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8226. v := m.content
  8227. if v == nil {
  8228. return
  8229. }
  8230. return *v, true
  8231. }
  8232. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8233. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8235. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8236. if !m.op.Is(OpUpdateOne) {
  8237. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8238. }
  8239. if m.id == nil || m.oldValue == nil {
  8240. return v, errors.New("OldContent requires an ID field in the mutation")
  8241. }
  8242. oldValue, err := m.oldValue(ctx)
  8243. if err != nil {
  8244. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8245. }
  8246. return oldValue.Content, nil
  8247. }
  8248. // ResetContent resets all changes to the "content" field.
  8249. func (m *ChatRecordsMutation) ResetContent() {
  8250. m.content = nil
  8251. }
  8252. // SetContentType sets the "content_type" field.
  8253. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8254. m.content_type = &u
  8255. m.addcontent_type = nil
  8256. }
  8257. // ContentType returns the value of the "content_type" field in the mutation.
  8258. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8259. v := m.content_type
  8260. if v == nil {
  8261. return
  8262. }
  8263. return *v, true
  8264. }
  8265. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8266. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8268. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8269. if !m.op.Is(OpUpdateOne) {
  8270. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8271. }
  8272. if m.id == nil || m.oldValue == nil {
  8273. return v, errors.New("OldContentType requires an ID field in the mutation")
  8274. }
  8275. oldValue, err := m.oldValue(ctx)
  8276. if err != nil {
  8277. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8278. }
  8279. return oldValue.ContentType, nil
  8280. }
  8281. // AddContentType adds u to the "content_type" field.
  8282. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8283. if m.addcontent_type != nil {
  8284. *m.addcontent_type += u
  8285. } else {
  8286. m.addcontent_type = &u
  8287. }
  8288. }
  8289. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8290. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8291. v := m.addcontent_type
  8292. if v == nil {
  8293. return
  8294. }
  8295. return *v, true
  8296. }
  8297. // ResetContentType resets all changes to the "content_type" field.
  8298. func (m *ChatRecordsMutation) ResetContentType() {
  8299. m.content_type = nil
  8300. m.addcontent_type = nil
  8301. }
  8302. // SetSessionID sets the "session_id" field.
  8303. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8304. m.session_id = &u
  8305. m.addsession_id = nil
  8306. }
  8307. // SessionID returns the value of the "session_id" field in the mutation.
  8308. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8309. v := m.session_id
  8310. if v == nil {
  8311. return
  8312. }
  8313. return *v, true
  8314. }
  8315. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8316. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8318. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8319. if !m.op.Is(OpUpdateOne) {
  8320. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8321. }
  8322. if m.id == nil || m.oldValue == nil {
  8323. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8324. }
  8325. oldValue, err := m.oldValue(ctx)
  8326. if err != nil {
  8327. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8328. }
  8329. return oldValue.SessionID, nil
  8330. }
  8331. // AddSessionID adds u to the "session_id" field.
  8332. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8333. if m.addsession_id != nil {
  8334. *m.addsession_id += u
  8335. } else {
  8336. m.addsession_id = &u
  8337. }
  8338. }
  8339. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8340. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8341. v := m.addsession_id
  8342. if v == nil {
  8343. return
  8344. }
  8345. return *v, true
  8346. }
  8347. // ResetSessionID resets all changes to the "session_id" field.
  8348. func (m *ChatRecordsMutation) ResetSessionID() {
  8349. m.session_id = nil
  8350. m.addsession_id = nil
  8351. }
  8352. // SetUserID sets the "user_id" field.
  8353. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8354. m.user_id = &u
  8355. m.adduser_id = nil
  8356. }
  8357. // UserID returns the value of the "user_id" field in the mutation.
  8358. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8359. v := m.user_id
  8360. if v == nil {
  8361. return
  8362. }
  8363. return *v, true
  8364. }
  8365. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8366. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8368. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8369. if !m.op.Is(OpUpdateOne) {
  8370. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8371. }
  8372. if m.id == nil || m.oldValue == nil {
  8373. return v, errors.New("OldUserID requires an ID field in the mutation")
  8374. }
  8375. oldValue, err := m.oldValue(ctx)
  8376. if err != nil {
  8377. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8378. }
  8379. return oldValue.UserID, nil
  8380. }
  8381. // AddUserID adds u to the "user_id" field.
  8382. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8383. if m.adduser_id != nil {
  8384. *m.adduser_id += u
  8385. } else {
  8386. m.adduser_id = &u
  8387. }
  8388. }
  8389. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8390. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8391. v := m.adduser_id
  8392. if v == nil {
  8393. return
  8394. }
  8395. return *v, true
  8396. }
  8397. // ResetUserID resets all changes to the "user_id" field.
  8398. func (m *ChatRecordsMutation) ResetUserID() {
  8399. m.user_id = nil
  8400. m.adduser_id = nil
  8401. }
  8402. // SetBotID sets the "bot_id" field.
  8403. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8404. m.bot_id = &u
  8405. m.addbot_id = nil
  8406. }
  8407. // BotID returns the value of the "bot_id" field in the mutation.
  8408. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8409. v := m.bot_id
  8410. if v == nil {
  8411. return
  8412. }
  8413. return *v, true
  8414. }
  8415. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8416. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8418. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8419. if !m.op.Is(OpUpdateOne) {
  8420. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8421. }
  8422. if m.id == nil || m.oldValue == nil {
  8423. return v, errors.New("OldBotID requires an ID field in the mutation")
  8424. }
  8425. oldValue, err := m.oldValue(ctx)
  8426. if err != nil {
  8427. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8428. }
  8429. return oldValue.BotID, nil
  8430. }
  8431. // AddBotID adds u to the "bot_id" field.
  8432. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8433. if m.addbot_id != nil {
  8434. *m.addbot_id += u
  8435. } else {
  8436. m.addbot_id = &u
  8437. }
  8438. }
  8439. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8440. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8441. v := m.addbot_id
  8442. if v == nil {
  8443. return
  8444. }
  8445. return *v, true
  8446. }
  8447. // ResetBotID resets all changes to the "bot_id" field.
  8448. func (m *ChatRecordsMutation) ResetBotID() {
  8449. m.bot_id = nil
  8450. m.addbot_id = nil
  8451. }
  8452. // SetBotType sets the "bot_type" field.
  8453. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8454. m.bot_type = &u
  8455. m.addbot_type = nil
  8456. }
  8457. // BotType returns the value of the "bot_type" field in the mutation.
  8458. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8459. v := m.bot_type
  8460. if v == nil {
  8461. return
  8462. }
  8463. return *v, true
  8464. }
  8465. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8466. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8468. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8469. if !m.op.Is(OpUpdateOne) {
  8470. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8471. }
  8472. if m.id == nil || m.oldValue == nil {
  8473. return v, errors.New("OldBotType requires an ID field in the mutation")
  8474. }
  8475. oldValue, err := m.oldValue(ctx)
  8476. if err != nil {
  8477. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8478. }
  8479. return oldValue.BotType, nil
  8480. }
  8481. // AddBotType adds u to the "bot_type" field.
  8482. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8483. if m.addbot_type != nil {
  8484. *m.addbot_type += u
  8485. } else {
  8486. m.addbot_type = &u
  8487. }
  8488. }
  8489. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8490. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8491. v := m.addbot_type
  8492. if v == nil {
  8493. return
  8494. }
  8495. return *v, true
  8496. }
  8497. // ResetBotType resets all changes to the "bot_type" field.
  8498. func (m *ChatRecordsMutation) ResetBotType() {
  8499. m.bot_type = nil
  8500. m.addbot_type = nil
  8501. }
  8502. // Where appends a list predicates to the ChatRecordsMutation builder.
  8503. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8504. m.predicates = append(m.predicates, ps...)
  8505. }
  8506. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8507. // users can use type-assertion to append predicates that do not depend on any generated package.
  8508. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8509. p := make([]predicate.ChatRecords, len(ps))
  8510. for i := range ps {
  8511. p[i] = ps[i]
  8512. }
  8513. m.Where(p...)
  8514. }
  8515. // Op returns the operation name.
  8516. func (m *ChatRecordsMutation) Op() Op {
  8517. return m.op
  8518. }
  8519. // SetOp allows setting the mutation operation.
  8520. func (m *ChatRecordsMutation) SetOp(op Op) {
  8521. m.op = op
  8522. }
  8523. // Type returns the node type of this mutation (ChatRecords).
  8524. func (m *ChatRecordsMutation) Type() string {
  8525. return m.typ
  8526. }
  8527. // Fields returns all fields that were changed during this mutation. Note that in
  8528. // order to get all numeric fields that were incremented/decremented, call
  8529. // AddedFields().
  8530. func (m *ChatRecordsMutation) Fields() []string {
  8531. fields := make([]string, 0, 9)
  8532. if m.created_at != nil {
  8533. fields = append(fields, chatrecords.FieldCreatedAt)
  8534. }
  8535. if m.updated_at != nil {
  8536. fields = append(fields, chatrecords.FieldUpdatedAt)
  8537. }
  8538. if m.deleted_at != nil {
  8539. fields = append(fields, chatrecords.FieldDeletedAt)
  8540. }
  8541. if m.content != nil {
  8542. fields = append(fields, chatrecords.FieldContent)
  8543. }
  8544. if m.content_type != nil {
  8545. fields = append(fields, chatrecords.FieldContentType)
  8546. }
  8547. if m.session_id != nil {
  8548. fields = append(fields, chatrecords.FieldSessionID)
  8549. }
  8550. if m.user_id != nil {
  8551. fields = append(fields, chatrecords.FieldUserID)
  8552. }
  8553. if m.bot_id != nil {
  8554. fields = append(fields, chatrecords.FieldBotID)
  8555. }
  8556. if m.bot_type != nil {
  8557. fields = append(fields, chatrecords.FieldBotType)
  8558. }
  8559. return fields
  8560. }
  8561. // Field returns the value of a field with the given name. The second boolean
  8562. // return value indicates that this field was not set, or was not defined in the
  8563. // schema.
  8564. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8565. switch name {
  8566. case chatrecords.FieldCreatedAt:
  8567. return m.CreatedAt()
  8568. case chatrecords.FieldUpdatedAt:
  8569. return m.UpdatedAt()
  8570. case chatrecords.FieldDeletedAt:
  8571. return m.DeletedAt()
  8572. case chatrecords.FieldContent:
  8573. return m.Content()
  8574. case chatrecords.FieldContentType:
  8575. return m.ContentType()
  8576. case chatrecords.FieldSessionID:
  8577. return m.SessionID()
  8578. case chatrecords.FieldUserID:
  8579. return m.UserID()
  8580. case chatrecords.FieldBotID:
  8581. return m.BotID()
  8582. case chatrecords.FieldBotType:
  8583. return m.BotType()
  8584. }
  8585. return nil, false
  8586. }
  8587. // OldField returns the old value of the field from the database. An error is
  8588. // returned if the mutation operation is not UpdateOne, or the query to the
  8589. // database failed.
  8590. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8591. switch name {
  8592. case chatrecords.FieldCreatedAt:
  8593. return m.OldCreatedAt(ctx)
  8594. case chatrecords.FieldUpdatedAt:
  8595. return m.OldUpdatedAt(ctx)
  8596. case chatrecords.FieldDeletedAt:
  8597. return m.OldDeletedAt(ctx)
  8598. case chatrecords.FieldContent:
  8599. return m.OldContent(ctx)
  8600. case chatrecords.FieldContentType:
  8601. return m.OldContentType(ctx)
  8602. case chatrecords.FieldSessionID:
  8603. return m.OldSessionID(ctx)
  8604. case chatrecords.FieldUserID:
  8605. return m.OldUserID(ctx)
  8606. case chatrecords.FieldBotID:
  8607. return m.OldBotID(ctx)
  8608. case chatrecords.FieldBotType:
  8609. return m.OldBotType(ctx)
  8610. }
  8611. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8612. }
  8613. // SetField sets the value of a field with the given name. It returns an error if
  8614. // the field is not defined in the schema, or if the type mismatched the field
  8615. // type.
  8616. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8617. switch name {
  8618. case chatrecords.FieldCreatedAt:
  8619. v, ok := value.(time.Time)
  8620. if !ok {
  8621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8622. }
  8623. m.SetCreatedAt(v)
  8624. return nil
  8625. case chatrecords.FieldUpdatedAt:
  8626. v, ok := value.(time.Time)
  8627. if !ok {
  8628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8629. }
  8630. m.SetUpdatedAt(v)
  8631. return nil
  8632. case chatrecords.FieldDeletedAt:
  8633. v, ok := value.(time.Time)
  8634. if !ok {
  8635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8636. }
  8637. m.SetDeletedAt(v)
  8638. return nil
  8639. case chatrecords.FieldContent:
  8640. v, ok := value.(string)
  8641. if !ok {
  8642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8643. }
  8644. m.SetContent(v)
  8645. return nil
  8646. case chatrecords.FieldContentType:
  8647. v, ok := value.(uint8)
  8648. if !ok {
  8649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8650. }
  8651. m.SetContentType(v)
  8652. return nil
  8653. case chatrecords.FieldSessionID:
  8654. v, ok := value.(uint64)
  8655. if !ok {
  8656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8657. }
  8658. m.SetSessionID(v)
  8659. return nil
  8660. case chatrecords.FieldUserID:
  8661. v, ok := value.(uint64)
  8662. if !ok {
  8663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8664. }
  8665. m.SetUserID(v)
  8666. return nil
  8667. case chatrecords.FieldBotID:
  8668. v, ok := value.(uint64)
  8669. if !ok {
  8670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8671. }
  8672. m.SetBotID(v)
  8673. return nil
  8674. case chatrecords.FieldBotType:
  8675. v, ok := value.(uint8)
  8676. if !ok {
  8677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8678. }
  8679. m.SetBotType(v)
  8680. return nil
  8681. }
  8682. return fmt.Errorf("unknown ChatRecords field %s", name)
  8683. }
  8684. // AddedFields returns all numeric fields that were incremented/decremented during
  8685. // this mutation.
  8686. func (m *ChatRecordsMutation) AddedFields() []string {
  8687. var fields []string
  8688. if m.addcontent_type != nil {
  8689. fields = append(fields, chatrecords.FieldContentType)
  8690. }
  8691. if m.addsession_id != nil {
  8692. fields = append(fields, chatrecords.FieldSessionID)
  8693. }
  8694. if m.adduser_id != nil {
  8695. fields = append(fields, chatrecords.FieldUserID)
  8696. }
  8697. if m.addbot_id != nil {
  8698. fields = append(fields, chatrecords.FieldBotID)
  8699. }
  8700. if m.addbot_type != nil {
  8701. fields = append(fields, chatrecords.FieldBotType)
  8702. }
  8703. return fields
  8704. }
  8705. // AddedField returns the numeric value that was incremented/decremented on a field
  8706. // with the given name. The second boolean return value indicates that this field
  8707. // was not set, or was not defined in the schema.
  8708. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8709. switch name {
  8710. case chatrecords.FieldContentType:
  8711. return m.AddedContentType()
  8712. case chatrecords.FieldSessionID:
  8713. return m.AddedSessionID()
  8714. case chatrecords.FieldUserID:
  8715. return m.AddedUserID()
  8716. case chatrecords.FieldBotID:
  8717. return m.AddedBotID()
  8718. case chatrecords.FieldBotType:
  8719. return m.AddedBotType()
  8720. }
  8721. return nil, false
  8722. }
  8723. // AddField adds the value to the field with the given name. It returns an error if
  8724. // the field is not defined in the schema, or if the type mismatched the field
  8725. // type.
  8726. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8727. switch name {
  8728. case chatrecords.FieldContentType:
  8729. v, ok := value.(int8)
  8730. if !ok {
  8731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8732. }
  8733. m.AddContentType(v)
  8734. return nil
  8735. case chatrecords.FieldSessionID:
  8736. v, ok := value.(int64)
  8737. if !ok {
  8738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8739. }
  8740. m.AddSessionID(v)
  8741. return nil
  8742. case chatrecords.FieldUserID:
  8743. v, ok := value.(int64)
  8744. if !ok {
  8745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8746. }
  8747. m.AddUserID(v)
  8748. return nil
  8749. case chatrecords.FieldBotID:
  8750. v, ok := value.(int64)
  8751. if !ok {
  8752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8753. }
  8754. m.AddBotID(v)
  8755. return nil
  8756. case chatrecords.FieldBotType:
  8757. v, ok := value.(int8)
  8758. if !ok {
  8759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8760. }
  8761. m.AddBotType(v)
  8762. return nil
  8763. }
  8764. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8765. }
  8766. // ClearedFields returns all nullable fields that were cleared during this
  8767. // mutation.
  8768. func (m *ChatRecordsMutation) ClearedFields() []string {
  8769. var fields []string
  8770. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8771. fields = append(fields, chatrecords.FieldDeletedAt)
  8772. }
  8773. return fields
  8774. }
  8775. // FieldCleared returns a boolean indicating if a field with the given name was
  8776. // cleared in this mutation.
  8777. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8778. _, ok := m.clearedFields[name]
  8779. return ok
  8780. }
  8781. // ClearField clears the value of the field with the given name. It returns an
  8782. // error if the field is not defined in the schema.
  8783. func (m *ChatRecordsMutation) ClearField(name string) error {
  8784. switch name {
  8785. case chatrecords.FieldDeletedAt:
  8786. m.ClearDeletedAt()
  8787. return nil
  8788. }
  8789. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8790. }
  8791. // ResetField resets all changes in the mutation for the field with the given name.
  8792. // It returns an error if the field is not defined in the schema.
  8793. func (m *ChatRecordsMutation) ResetField(name string) error {
  8794. switch name {
  8795. case chatrecords.FieldCreatedAt:
  8796. m.ResetCreatedAt()
  8797. return nil
  8798. case chatrecords.FieldUpdatedAt:
  8799. m.ResetUpdatedAt()
  8800. return nil
  8801. case chatrecords.FieldDeletedAt:
  8802. m.ResetDeletedAt()
  8803. return nil
  8804. case chatrecords.FieldContent:
  8805. m.ResetContent()
  8806. return nil
  8807. case chatrecords.FieldContentType:
  8808. m.ResetContentType()
  8809. return nil
  8810. case chatrecords.FieldSessionID:
  8811. m.ResetSessionID()
  8812. return nil
  8813. case chatrecords.FieldUserID:
  8814. m.ResetUserID()
  8815. return nil
  8816. case chatrecords.FieldBotID:
  8817. m.ResetBotID()
  8818. return nil
  8819. case chatrecords.FieldBotType:
  8820. m.ResetBotType()
  8821. return nil
  8822. }
  8823. return fmt.Errorf("unknown ChatRecords field %s", name)
  8824. }
  8825. // AddedEdges returns all edge names that were set/added in this mutation.
  8826. func (m *ChatRecordsMutation) AddedEdges() []string {
  8827. edges := make([]string, 0, 0)
  8828. return edges
  8829. }
  8830. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8831. // name in this mutation.
  8832. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8833. return nil
  8834. }
  8835. // RemovedEdges returns all edge names that were removed in this mutation.
  8836. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8837. edges := make([]string, 0, 0)
  8838. return edges
  8839. }
  8840. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8841. // the given name in this mutation.
  8842. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8843. return nil
  8844. }
  8845. // ClearedEdges returns all edge names that were cleared in this mutation.
  8846. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8847. edges := make([]string, 0, 0)
  8848. return edges
  8849. }
  8850. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8851. // was cleared in this mutation.
  8852. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8853. return false
  8854. }
  8855. // ClearEdge clears the value of the edge with the given name. It returns an error
  8856. // if that edge is not defined in the schema.
  8857. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8858. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8859. }
  8860. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8861. // It returns an error if the edge is not defined in the schema.
  8862. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8863. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8864. }
  8865. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8866. type ChatSessionMutation struct {
  8867. config
  8868. op Op
  8869. typ string
  8870. id *uint64
  8871. created_at *time.Time
  8872. updated_at *time.Time
  8873. deleted_at *time.Time
  8874. name *string
  8875. user_id *uint64
  8876. adduser_id *int64
  8877. bot_id *uint64
  8878. addbot_id *int64
  8879. bot_type *uint8
  8880. addbot_type *int8
  8881. clearedFields map[string]struct{}
  8882. done bool
  8883. oldValue func(context.Context) (*ChatSession, error)
  8884. predicates []predicate.ChatSession
  8885. }
  8886. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8887. // chatsessionOption allows management of the mutation configuration using functional options.
  8888. type chatsessionOption func(*ChatSessionMutation)
  8889. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8890. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8891. m := &ChatSessionMutation{
  8892. config: c,
  8893. op: op,
  8894. typ: TypeChatSession,
  8895. clearedFields: make(map[string]struct{}),
  8896. }
  8897. for _, opt := range opts {
  8898. opt(m)
  8899. }
  8900. return m
  8901. }
  8902. // withChatSessionID sets the ID field of the mutation.
  8903. func withChatSessionID(id uint64) chatsessionOption {
  8904. return func(m *ChatSessionMutation) {
  8905. var (
  8906. err error
  8907. once sync.Once
  8908. value *ChatSession
  8909. )
  8910. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8911. once.Do(func() {
  8912. if m.done {
  8913. err = errors.New("querying old values post mutation is not allowed")
  8914. } else {
  8915. value, err = m.Client().ChatSession.Get(ctx, id)
  8916. }
  8917. })
  8918. return value, err
  8919. }
  8920. m.id = &id
  8921. }
  8922. }
  8923. // withChatSession sets the old ChatSession of the mutation.
  8924. func withChatSession(node *ChatSession) chatsessionOption {
  8925. return func(m *ChatSessionMutation) {
  8926. m.oldValue = func(context.Context) (*ChatSession, error) {
  8927. return node, nil
  8928. }
  8929. m.id = &node.ID
  8930. }
  8931. }
  8932. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8933. // executed in a transaction (ent.Tx), a transactional client is returned.
  8934. func (m ChatSessionMutation) Client() *Client {
  8935. client := &Client{config: m.config}
  8936. client.init()
  8937. return client
  8938. }
  8939. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8940. // it returns an error otherwise.
  8941. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8942. if _, ok := m.driver.(*txDriver); !ok {
  8943. return nil, errors.New("ent: mutation is not running in a transaction")
  8944. }
  8945. tx := &Tx{config: m.config}
  8946. tx.init()
  8947. return tx, nil
  8948. }
  8949. // SetID sets the value of the id field. Note that this
  8950. // operation is only accepted on creation of ChatSession entities.
  8951. func (m *ChatSessionMutation) SetID(id uint64) {
  8952. m.id = &id
  8953. }
  8954. // ID returns the ID value in the mutation. Note that the ID is only available
  8955. // if it was provided to the builder or after it was returned from the database.
  8956. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8957. if m.id == nil {
  8958. return
  8959. }
  8960. return *m.id, true
  8961. }
  8962. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8963. // That means, if the mutation is applied within a transaction with an isolation level such
  8964. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8965. // or updated by the mutation.
  8966. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8967. switch {
  8968. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8969. id, exists := m.ID()
  8970. if exists {
  8971. return []uint64{id}, nil
  8972. }
  8973. fallthrough
  8974. case m.op.Is(OpUpdate | OpDelete):
  8975. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8976. default:
  8977. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8978. }
  8979. }
  8980. // SetCreatedAt sets the "created_at" field.
  8981. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8982. m.created_at = &t
  8983. }
  8984. // CreatedAt returns the value of the "created_at" field in the mutation.
  8985. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8986. v := m.created_at
  8987. if v == nil {
  8988. return
  8989. }
  8990. return *v, true
  8991. }
  8992. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8993. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8995. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8996. if !m.op.Is(OpUpdateOne) {
  8997. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8998. }
  8999. if m.id == nil || m.oldValue == nil {
  9000. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9001. }
  9002. oldValue, err := m.oldValue(ctx)
  9003. if err != nil {
  9004. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9005. }
  9006. return oldValue.CreatedAt, nil
  9007. }
  9008. // ResetCreatedAt resets all changes to the "created_at" field.
  9009. func (m *ChatSessionMutation) ResetCreatedAt() {
  9010. m.created_at = nil
  9011. }
  9012. // SetUpdatedAt sets the "updated_at" field.
  9013. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  9014. m.updated_at = &t
  9015. }
  9016. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9017. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  9018. v := m.updated_at
  9019. if v == nil {
  9020. return
  9021. }
  9022. return *v, true
  9023. }
  9024. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  9025. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9027. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9028. if !m.op.Is(OpUpdateOne) {
  9029. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9030. }
  9031. if m.id == nil || m.oldValue == nil {
  9032. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9033. }
  9034. oldValue, err := m.oldValue(ctx)
  9035. if err != nil {
  9036. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9037. }
  9038. return oldValue.UpdatedAt, nil
  9039. }
  9040. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9041. func (m *ChatSessionMutation) ResetUpdatedAt() {
  9042. m.updated_at = nil
  9043. }
  9044. // SetDeletedAt sets the "deleted_at" field.
  9045. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  9046. m.deleted_at = &t
  9047. }
  9048. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9049. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  9050. v := m.deleted_at
  9051. if v == nil {
  9052. return
  9053. }
  9054. return *v, true
  9055. }
  9056. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  9057. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9059. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9060. if !m.op.Is(OpUpdateOne) {
  9061. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9062. }
  9063. if m.id == nil || m.oldValue == nil {
  9064. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9065. }
  9066. oldValue, err := m.oldValue(ctx)
  9067. if err != nil {
  9068. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9069. }
  9070. return oldValue.DeletedAt, nil
  9071. }
  9072. // ClearDeletedAt clears the value of the "deleted_at" field.
  9073. func (m *ChatSessionMutation) ClearDeletedAt() {
  9074. m.deleted_at = nil
  9075. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  9076. }
  9077. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9078. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9079. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9080. return ok
  9081. }
  9082. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9083. func (m *ChatSessionMutation) ResetDeletedAt() {
  9084. m.deleted_at = nil
  9085. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9086. }
  9087. // SetName sets the "name" field.
  9088. func (m *ChatSessionMutation) SetName(s string) {
  9089. m.name = &s
  9090. }
  9091. // Name returns the value of the "name" field in the mutation.
  9092. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9093. v := m.name
  9094. if v == nil {
  9095. return
  9096. }
  9097. return *v, true
  9098. }
  9099. // OldName returns the old "name" field's value of the ChatSession entity.
  9100. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9102. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9103. if !m.op.Is(OpUpdateOne) {
  9104. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9105. }
  9106. if m.id == nil || m.oldValue == nil {
  9107. return v, errors.New("OldName requires an ID field in the mutation")
  9108. }
  9109. oldValue, err := m.oldValue(ctx)
  9110. if err != nil {
  9111. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9112. }
  9113. return oldValue.Name, nil
  9114. }
  9115. // ResetName resets all changes to the "name" field.
  9116. func (m *ChatSessionMutation) ResetName() {
  9117. m.name = nil
  9118. }
  9119. // SetUserID sets the "user_id" field.
  9120. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9121. m.user_id = &u
  9122. m.adduser_id = nil
  9123. }
  9124. // UserID returns the value of the "user_id" field in the mutation.
  9125. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9126. v := m.user_id
  9127. if v == nil {
  9128. return
  9129. }
  9130. return *v, true
  9131. }
  9132. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9133. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9135. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9136. if !m.op.Is(OpUpdateOne) {
  9137. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9138. }
  9139. if m.id == nil || m.oldValue == nil {
  9140. return v, errors.New("OldUserID requires an ID field in the mutation")
  9141. }
  9142. oldValue, err := m.oldValue(ctx)
  9143. if err != nil {
  9144. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9145. }
  9146. return oldValue.UserID, nil
  9147. }
  9148. // AddUserID adds u to the "user_id" field.
  9149. func (m *ChatSessionMutation) AddUserID(u int64) {
  9150. if m.adduser_id != nil {
  9151. *m.adduser_id += u
  9152. } else {
  9153. m.adduser_id = &u
  9154. }
  9155. }
  9156. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9157. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9158. v := m.adduser_id
  9159. if v == nil {
  9160. return
  9161. }
  9162. return *v, true
  9163. }
  9164. // ResetUserID resets all changes to the "user_id" field.
  9165. func (m *ChatSessionMutation) ResetUserID() {
  9166. m.user_id = nil
  9167. m.adduser_id = nil
  9168. }
  9169. // SetBotID sets the "bot_id" field.
  9170. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9171. m.bot_id = &u
  9172. m.addbot_id = nil
  9173. }
  9174. // BotID returns the value of the "bot_id" field in the mutation.
  9175. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9176. v := m.bot_id
  9177. if v == nil {
  9178. return
  9179. }
  9180. return *v, true
  9181. }
  9182. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9183. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9185. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9186. if !m.op.Is(OpUpdateOne) {
  9187. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9188. }
  9189. if m.id == nil || m.oldValue == nil {
  9190. return v, errors.New("OldBotID requires an ID field in the mutation")
  9191. }
  9192. oldValue, err := m.oldValue(ctx)
  9193. if err != nil {
  9194. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9195. }
  9196. return oldValue.BotID, nil
  9197. }
  9198. // AddBotID adds u to the "bot_id" field.
  9199. func (m *ChatSessionMutation) AddBotID(u int64) {
  9200. if m.addbot_id != nil {
  9201. *m.addbot_id += u
  9202. } else {
  9203. m.addbot_id = &u
  9204. }
  9205. }
  9206. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9207. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9208. v := m.addbot_id
  9209. if v == nil {
  9210. return
  9211. }
  9212. return *v, true
  9213. }
  9214. // ResetBotID resets all changes to the "bot_id" field.
  9215. func (m *ChatSessionMutation) ResetBotID() {
  9216. m.bot_id = nil
  9217. m.addbot_id = nil
  9218. }
  9219. // SetBotType sets the "bot_type" field.
  9220. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9221. m.bot_type = &u
  9222. m.addbot_type = nil
  9223. }
  9224. // BotType returns the value of the "bot_type" field in the mutation.
  9225. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9226. v := m.bot_type
  9227. if v == nil {
  9228. return
  9229. }
  9230. return *v, true
  9231. }
  9232. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9233. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9235. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9236. if !m.op.Is(OpUpdateOne) {
  9237. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9238. }
  9239. if m.id == nil || m.oldValue == nil {
  9240. return v, errors.New("OldBotType requires an ID field in the mutation")
  9241. }
  9242. oldValue, err := m.oldValue(ctx)
  9243. if err != nil {
  9244. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9245. }
  9246. return oldValue.BotType, nil
  9247. }
  9248. // AddBotType adds u to the "bot_type" field.
  9249. func (m *ChatSessionMutation) AddBotType(u int8) {
  9250. if m.addbot_type != nil {
  9251. *m.addbot_type += u
  9252. } else {
  9253. m.addbot_type = &u
  9254. }
  9255. }
  9256. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9257. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9258. v := m.addbot_type
  9259. if v == nil {
  9260. return
  9261. }
  9262. return *v, true
  9263. }
  9264. // ResetBotType resets all changes to the "bot_type" field.
  9265. func (m *ChatSessionMutation) ResetBotType() {
  9266. m.bot_type = nil
  9267. m.addbot_type = nil
  9268. }
  9269. // Where appends a list predicates to the ChatSessionMutation builder.
  9270. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9271. m.predicates = append(m.predicates, ps...)
  9272. }
  9273. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9274. // users can use type-assertion to append predicates that do not depend on any generated package.
  9275. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9276. p := make([]predicate.ChatSession, len(ps))
  9277. for i := range ps {
  9278. p[i] = ps[i]
  9279. }
  9280. m.Where(p...)
  9281. }
  9282. // Op returns the operation name.
  9283. func (m *ChatSessionMutation) Op() Op {
  9284. return m.op
  9285. }
  9286. // SetOp allows setting the mutation operation.
  9287. func (m *ChatSessionMutation) SetOp(op Op) {
  9288. m.op = op
  9289. }
  9290. // Type returns the node type of this mutation (ChatSession).
  9291. func (m *ChatSessionMutation) Type() string {
  9292. return m.typ
  9293. }
  9294. // Fields returns all fields that were changed during this mutation. Note that in
  9295. // order to get all numeric fields that were incremented/decremented, call
  9296. // AddedFields().
  9297. func (m *ChatSessionMutation) Fields() []string {
  9298. fields := make([]string, 0, 7)
  9299. if m.created_at != nil {
  9300. fields = append(fields, chatsession.FieldCreatedAt)
  9301. }
  9302. if m.updated_at != nil {
  9303. fields = append(fields, chatsession.FieldUpdatedAt)
  9304. }
  9305. if m.deleted_at != nil {
  9306. fields = append(fields, chatsession.FieldDeletedAt)
  9307. }
  9308. if m.name != nil {
  9309. fields = append(fields, chatsession.FieldName)
  9310. }
  9311. if m.user_id != nil {
  9312. fields = append(fields, chatsession.FieldUserID)
  9313. }
  9314. if m.bot_id != nil {
  9315. fields = append(fields, chatsession.FieldBotID)
  9316. }
  9317. if m.bot_type != nil {
  9318. fields = append(fields, chatsession.FieldBotType)
  9319. }
  9320. return fields
  9321. }
  9322. // Field returns the value of a field with the given name. The second boolean
  9323. // return value indicates that this field was not set, or was not defined in the
  9324. // schema.
  9325. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9326. switch name {
  9327. case chatsession.FieldCreatedAt:
  9328. return m.CreatedAt()
  9329. case chatsession.FieldUpdatedAt:
  9330. return m.UpdatedAt()
  9331. case chatsession.FieldDeletedAt:
  9332. return m.DeletedAt()
  9333. case chatsession.FieldName:
  9334. return m.Name()
  9335. case chatsession.FieldUserID:
  9336. return m.UserID()
  9337. case chatsession.FieldBotID:
  9338. return m.BotID()
  9339. case chatsession.FieldBotType:
  9340. return m.BotType()
  9341. }
  9342. return nil, false
  9343. }
  9344. // OldField returns the old value of the field from the database. An error is
  9345. // returned if the mutation operation is not UpdateOne, or the query to the
  9346. // database failed.
  9347. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9348. switch name {
  9349. case chatsession.FieldCreatedAt:
  9350. return m.OldCreatedAt(ctx)
  9351. case chatsession.FieldUpdatedAt:
  9352. return m.OldUpdatedAt(ctx)
  9353. case chatsession.FieldDeletedAt:
  9354. return m.OldDeletedAt(ctx)
  9355. case chatsession.FieldName:
  9356. return m.OldName(ctx)
  9357. case chatsession.FieldUserID:
  9358. return m.OldUserID(ctx)
  9359. case chatsession.FieldBotID:
  9360. return m.OldBotID(ctx)
  9361. case chatsession.FieldBotType:
  9362. return m.OldBotType(ctx)
  9363. }
  9364. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9365. }
  9366. // SetField sets the value of a field with the given name. It returns an error if
  9367. // the field is not defined in the schema, or if the type mismatched the field
  9368. // type.
  9369. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9370. switch name {
  9371. case chatsession.FieldCreatedAt:
  9372. v, ok := value.(time.Time)
  9373. if !ok {
  9374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9375. }
  9376. m.SetCreatedAt(v)
  9377. return nil
  9378. case chatsession.FieldUpdatedAt:
  9379. v, ok := value.(time.Time)
  9380. if !ok {
  9381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9382. }
  9383. m.SetUpdatedAt(v)
  9384. return nil
  9385. case chatsession.FieldDeletedAt:
  9386. v, ok := value.(time.Time)
  9387. if !ok {
  9388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9389. }
  9390. m.SetDeletedAt(v)
  9391. return nil
  9392. case chatsession.FieldName:
  9393. v, ok := value.(string)
  9394. if !ok {
  9395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9396. }
  9397. m.SetName(v)
  9398. return nil
  9399. case chatsession.FieldUserID:
  9400. v, ok := value.(uint64)
  9401. if !ok {
  9402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9403. }
  9404. m.SetUserID(v)
  9405. return nil
  9406. case chatsession.FieldBotID:
  9407. v, ok := value.(uint64)
  9408. if !ok {
  9409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9410. }
  9411. m.SetBotID(v)
  9412. return nil
  9413. case chatsession.FieldBotType:
  9414. v, ok := value.(uint8)
  9415. if !ok {
  9416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9417. }
  9418. m.SetBotType(v)
  9419. return nil
  9420. }
  9421. return fmt.Errorf("unknown ChatSession field %s", name)
  9422. }
  9423. // AddedFields returns all numeric fields that were incremented/decremented during
  9424. // this mutation.
  9425. func (m *ChatSessionMutation) AddedFields() []string {
  9426. var fields []string
  9427. if m.adduser_id != nil {
  9428. fields = append(fields, chatsession.FieldUserID)
  9429. }
  9430. if m.addbot_id != nil {
  9431. fields = append(fields, chatsession.FieldBotID)
  9432. }
  9433. if m.addbot_type != nil {
  9434. fields = append(fields, chatsession.FieldBotType)
  9435. }
  9436. return fields
  9437. }
  9438. // AddedField returns the numeric value that was incremented/decremented on a field
  9439. // with the given name. The second boolean return value indicates that this field
  9440. // was not set, or was not defined in the schema.
  9441. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9442. switch name {
  9443. case chatsession.FieldUserID:
  9444. return m.AddedUserID()
  9445. case chatsession.FieldBotID:
  9446. return m.AddedBotID()
  9447. case chatsession.FieldBotType:
  9448. return m.AddedBotType()
  9449. }
  9450. return nil, false
  9451. }
  9452. // AddField adds the value to the field with the given name. It returns an error if
  9453. // the field is not defined in the schema, or if the type mismatched the field
  9454. // type.
  9455. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9456. switch name {
  9457. case chatsession.FieldUserID:
  9458. v, ok := value.(int64)
  9459. if !ok {
  9460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9461. }
  9462. m.AddUserID(v)
  9463. return nil
  9464. case chatsession.FieldBotID:
  9465. v, ok := value.(int64)
  9466. if !ok {
  9467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9468. }
  9469. m.AddBotID(v)
  9470. return nil
  9471. case chatsession.FieldBotType:
  9472. v, ok := value.(int8)
  9473. if !ok {
  9474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9475. }
  9476. m.AddBotType(v)
  9477. return nil
  9478. }
  9479. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9480. }
  9481. // ClearedFields returns all nullable fields that were cleared during this
  9482. // mutation.
  9483. func (m *ChatSessionMutation) ClearedFields() []string {
  9484. var fields []string
  9485. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9486. fields = append(fields, chatsession.FieldDeletedAt)
  9487. }
  9488. return fields
  9489. }
  9490. // FieldCleared returns a boolean indicating if a field with the given name was
  9491. // cleared in this mutation.
  9492. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9493. _, ok := m.clearedFields[name]
  9494. return ok
  9495. }
  9496. // ClearField clears the value of the field with the given name. It returns an
  9497. // error if the field is not defined in the schema.
  9498. func (m *ChatSessionMutation) ClearField(name string) error {
  9499. switch name {
  9500. case chatsession.FieldDeletedAt:
  9501. m.ClearDeletedAt()
  9502. return nil
  9503. }
  9504. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9505. }
  9506. // ResetField resets all changes in the mutation for the field with the given name.
  9507. // It returns an error if the field is not defined in the schema.
  9508. func (m *ChatSessionMutation) ResetField(name string) error {
  9509. switch name {
  9510. case chatsession.FieldCreatedAt:
  9511. m.ResetCreatedAt()
  9512. return nil
  9513. case chatsession.FieldUpdatedAt:
  9514. m.ResetUpdatedAt()
  9515. return nil
  9516. case chatsession.FieldDeletedAt:
  9517. m.ResetDeletedAt()
  9518. return nil
  9519. case chatsession.FieldName:
  9520. m.ResetName()
  9521. return nil
  9522. case chatsession.FieldUserID:
  9523. m.ResetUserID()
  9524. return nil
  9525. case chatsession.FieldBotID:
  9526. m.ResetBotID()
  9527. return nil
  9528. case chatsession.FieldBotType:
  9529. m.ResetBotType()
  9530. return nil
  9531. }
  9532. return fmt.Errorf("unknown ChatSession field %s", name)
  9533. }
  9534. // AddedEdges returns all edge names that were set/added in this mutation.
  9535. func (m *ChatSessionMutation) AddedEdges() []string {
  9536. edges := make([]string, 0, 0)
  9537. return edges
  9538. }
  9539. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9540. // name in this mutation.
  9541. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9542. return nil
  9543. }
  9544. // RemovedEdges returns all edge names that were removed in this mutation.
  9545. func (m *ChatSessionMutation) RemovedEdges() []string {
  9546. edges := make([]string, 0, 0)
  9547. return edges
  9548. }
  9549. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9550. // the given name in this mutation.
  9551. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9552. return nil
  9553. }
  9554. // ClearedEdges returns all edge names that were cleared in this mutation.
  9555. func (m *ChatSessionMutation) ClearedEdges() []string {
  9556. edges := make([]string, 0, 0)
  9557. return edges
  9558. }
  9559. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9560. // was cleared in this mutation.
  9561. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9562. return false
  9563. }
  9564. // ClearEdge clears the value of the edge with the given name. It returns an error
  9565. // if that edge is not defined in the schema.
  9566. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9567. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9568. }
  9569. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9570. // It returns an error if the edge is not defined in the schema.
  9571. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9572. return fmt.Errorf("unknown ChatSession edge %s", name)
  9573. }
  9574. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9575. type ContactMutation struct {
  9576. config
  9577. op Op
  9578. typ string
  9579. id *uint64
  9580. created_at *time.Time
  9581. updated_at *time.Time
  9582. status *uint8
  9583. addstatus *int8
  9584. deleted_at *time.Time
  9585. wx_wxid *string
  9586. _type *int
  9587. add_type *int
  9588. wxid *string
  9589. account *string
  9590. nickname *string
  9591. markname *string
  9592. headimg *string
  9593. sex *int
  9594. addsex *int
  9595. starrole *string
  9596. dontseeit *int
  9597. adddontseeit *int
  9598. dontseeme *int
  9599. adddontseeme *int
  9600. lag *string
  9601. gid *string
  9602. gname *string
  9603. v3 *string
  9604. organization_id *uint64
  9605. addorganization_id *int64
  9606. ctype *uint64
  9607. addctype *int64
  9608. cage *int
  9609. addcage *int
  9610. cname *string
  9611. carea *string
  9612. cbirthday *string
  9613. cbirtharea *string
  9614. cidcard_no *string
  9615. ctitle *string
  9616. cc *string
  9617. phone *string
  9618. clearedFields map[string]struct{}
  9619. contact_relationships map[uint64]struct{}
  9620. removedcontact_relationships map[uint64]struct{}
  9621. clearedcontact_relationships bool
  9622. contact_fields map[uint64]struct{}
  9623. removedcontact_fields map[uint64]struct{}
  9624. clearedcontact_fields bool
  9625. contact_messages map[uint64]struct{}
  9626. removedcontact_messages map[uint64]struct{}
  9627. clearedcontact_messages bool
  9628. done bool
  9629. oldValue func(context.Context) (*Contact, error)
  9630. predicates []predicate.Contact
  9631. }
  9632. var _ ent.Mutation = (*ContactMutation)(nil)
  9633. // contactOption allows management of the mutation configuration using functional options.
  9634. type contactOption func(*ContactMutation)
  9635. // newContactMutation creates new mutation for the Contact entity.
  9636. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9637. m := &ContactMutation{
  9638. config: c,
  9639. op: op,
  9640. typ: TypeContact,
  9641. clearedFields: make(map[string]struct{}),
  9642. }
  9643. for _, opt := range opts {
  9644. opt(m)
  9645. }
  9646. return m
  9647. }
  9648. // withContactID sets the ID field of the mutation.
  9649. func withContactID(id uint64) contactOption {
  9650. return func(m *ContactMutation) {
  9651. var (
  9652. err error
  9653. once sync.Once
  9654. value *Contact
  9655. )
  9656. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9657. once.Do(func() {
  9658. if m.done {
  9659. err = errors.New("querying old values post mutation is not allowed")
  9660. } else {
  9661. value, err = m.Client().Contact.Get(ctx, id)
  9662. }
  9663. })
  9664. return value, err
  9665. }
  9666. m.id = &id
  9667. }
  9668. }
  9669. // withContact sets the old Contact of the mutation.
  9670. func withContact(node *Contact) contactOption {
  9671. return func(m *ContactMutation) {
  9672. m.oldValue = func(context.Context) (*Contact, error) {
  9673. return node, nil
  9674. }
  9675. m.id = &node.ID
  9676. }
  9677. }
  9678. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9679. // executed in a transaction (ent.Tx), a transactional client is returned.
  9680. func (m ContactMutation) Client() *Client {
  9681. client := &Client{config: m.config}
  9682. client.init()
  9683. return client
  9684. }
  9685. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9686. // it returns an error otherwise.
  9687. func (m ContactMutation) Tx() (*Tx, error) {
  9688. if _, ok := m.driver.(*txDriver); !ok {
  9689. return nil, errors.New("ent: mutation is not running in a transaction")
  9690. }
  9691. tx := &Tx{config: m.config}
  9692. tx.init()
  9693. return tx, nil
  9694. }
  9695. // SetID sets the value of the id field. Note that this
  9696. // operation is only accepted on creation of Contact entities.
  9697. func (m *ContactMutation) SetID(id uint64) {
  9698. m.id = &id
  9699. }
  9700. // ID returns the ID value in the mutation. Note that the ID is only available
  9701. // if it was provided to the builder or after it was returned from the database.
  9702. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9703. if m.id == nil {
  9704. return
  9705. }
  9706. return *m.id, true
  9707. }
  9708. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9709. // That means, if the mutation is applied within a transaction with an isolation level such
  9710. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9711. // or updated by the mutation.
  9712. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9713. switch {
  9714. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9715. id, exists := m.ID()
  9716. if exists {
  9717. return []uint64{id}, nil
  9718. }
  9719. fallthrough
  9720. case m.op.Is(OpUpdate | OpDelete):
  9721. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9722. default:
  9723. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9724. }
  9725. }
  9726. // SetCreatedAt sets the "created_at" field.
  9727. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9728. m.created_at = &t
  9729. }
  9730. // CreatedAt returns the value of the "created_at" field in the mutation.
  9731. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9732. v := m.created_at
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9739. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9741. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9742. if !m.op.Is(OpUpdateOne) {
  9743. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9744. }
  9745. if m.id == nil || m.oldValue == nil {
  9746. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9747. }
  9748. oldValue, err := m.oldValue(ctx)
  9749. if err != nil {
  9750. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9751. }
  9752. return oldValue.CreatedAt, nil
  9753. }
  9754. // ResetCreatedAt resets all changes to the "created_at" field.
  9755. func (m *ContactMutation) ResetCreatedAt() {
  9756. m.created_at = nil
  9757. }
  9758. // SetUpdatedAt sets the "updated_at" field.
  9759. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9760. m.updated_at = &t
  9761. }
  9762. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9763. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9764. v := m.updated_at
  9765. if v == nil {
  9766. return
  9767. }
  9768. return *v, true
  9769. }
  9770. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9771. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9773. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9774. if !m.op.Is(OpUpdateOne) {
  9775. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9776. }
  9777. if m.id == nil || m.oldValue == nil {
  9778. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9779. }
  9780. oldValue, err := m.oldValue(ctx)
  9781. if err != nil {
  9782. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9783. }
  9784. return oldValue.UpdatedAt, nil
  9785. }
  9786. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9787. func (m *ContactMutation) ResetUpdatedAt() {
  9788. m.updated_at = nil
  9789. }
  9790. // SetStatus sets the "status" field.
  9791. func (m *ContactMutation) SetStatus(u uint8) {
  9792. m.status = &u
  9793. m.addstatus = nil
  9794. }
  9795. // Status returns the value of the "status" field in the mutation.
  9796. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9797. v := m.status
  9798. if v == nil {
  9799. return
  9800. }
  9801. return *v, true
  9802. }
  9803. // OldStatus returns the old "status" field's value of the Contact entity.
  9804. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9806. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9807. if !m.op.Is(OpUpdateOne) {
  9808. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9809. }
  9810. if m.id == nil || m.oldValue == nil {
  9811. return v, errors.New("OldStatus requires an ID field in the mutation")
  9812. }
  9813. oldValue, err := m.oldValue(ctx)
  9814. if err != nil {
  9815. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9816. }
  9817. return oldValue.Status, nil
  9818. }
  9819. // AddStatus adds u to the "status" field.
  9820. func (m *ContactMutation) AddStatus(u int8) {
  9821. if m.addstatus != nil {
  9822. *m.addstatus += u
  9823. } else {
  9824. m.addstatus = &u
  9825. }
  9826. }
  9827. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9828. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9829. v := m.addstatus
  9830. if v == nil {
  9831. return
  9832. }
  9833. return *v, true
  9834. }
  9835. // ClearStatus clears the value of the "status" field.
  9836. func (m *ContactMutation) ClearStatus() {
  9837. m.status = nil
  9838. m.addstatus = nil
  9839. m.clearedFields[contact.FieldStatus] = struct{}{}
  9840. }
  9841. // StatusCleared returns if the "status" field was cleared in this mutation.
  9842. func (m *ContactMutation) StatusCleared() bool {
  9843. _, ok := m.clearedFields[contact.FieldStatus]
  9844. return ok
  9845. }
  9846. // ResetStatus resets all changes to the "status" field.
  9847. func (m *ContactMutation) ResetStatus() {
  9848. m.status = nil
  9849. m.addstatus = nil
  9850. delete(m.clearedFields, contact.FieldStatus)
  9851. }
  9852. // SetDeletedAt sets the "deleted_at" field.
  9853. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9854. m.deleted_at = &t
  9855. }
  9856. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9857. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9858. v := m.deleted_at
  9859. if v == nil {
  9860. return
  9861. }
  9862. return *v, true
  9863. }
  9864. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9865. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9867. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9868. if !m.op.Is(OpUpdateOne) {
  9869. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9870. }
  9871. if m.id == nil || m.oldValue == nil {
  9872. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9873. }
  9874. oldValue, err := m.oldValue(ctx)
  9875. if err != nil {
  9876. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9877. }
  9878. return oldValue.DeletedAt, nil
  9879. }
  9880. // ClearDeletedAt clears the value of the "deleted_at" field.
  9881. func (m *ContactMutation) ClearDeletedAt() {
  9882. m.deleted_at = nil
  9883. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9884. }
  9885. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9886. func (m *ContactMutation) DeletedAtCleared() bool {
  9887. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9888. return ok
  9889. }
  9890. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9891. func (m *ContactMutation) ResetDeletedAt() {
  9892. m.deleted_at = nil
  9893. delete(m.clearedFields, contact.FieldDeletedAt)
  9894. }
  9895. // SetWxWxid sets the "wx_wxid" field.
  9896. func (m *ContactMutation) SetWxWxid(s string) {
  9897. m.wx_wxid = &s
  9898. }
  9899. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9900. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9901. v := m.wx_wxid
  9902. if v == nil {
  9903. return
  9904. }
  9905. return *v, true
  9906. }
  9907. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9908. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9910. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9911. if !m.op.Is(OpUpdateOne) {
  9912. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9913. }
  9914. if m.id == nil || m.oldValue == nil {
  9915. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9916. }
  9917. oldValue, err := m.oldValue(ctx)
  9918. if err != nil {
  9919. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9920. }
  9921. return oldValue.WxWxid, nil
  9922. }
  9923. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9924. func (m *ContactMutation) ResetWxWxid() {
  9925. m.wx_wxid = nil
  9926. }
  9927. // SetType sets the "type" field.
  9928. func (m *ContactMutation) SetType(i int) {
  9929. m._type = &i
  9930. m.add_type = nil
  9931. }
  9932. // GetType returns the value of the "type" field in the mutation.
  9933. func (m *ContactMutation) GetType() (r int, exists bool) {
  9934. v := m._type
  9935. if v == nil {
  9936. return
  9937. }
  9938. return *v, true
  9939. }
  9940. // OldType returns the old "type" field's value of the Contact entity.
  9941. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9943. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9944. if !m.op.Is(OpUpdateOne) {
  9945. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9946. }
  9947. if m.id == nil || m.oldValue == nil {
  9948. return v, errors.New("OldType requires an ID field in the mutation")
  9949. }
  9950. oldValue, err := m.oldValue(ctx)
  9951. if err != nil {
  9952. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9953. }
  9954. return oldValue.Type, nil
  9955. }
  9956. // AddType adds i to the "type" field.
  9957. func (m *ContactMutation) AddType(i int) {
  9958. if m.add_type != nil {
  9959. *m.add_type += i
  9960. } else {
  9961. m.add_type = &i
  9962. }
  9963. }
  9964. // AddedType returns the value that was added to the "type" field in this mutation.
  9965. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9966. v := m.add_type
  9967. if v == nil {
  9968. return
  9969. }
  9970. return *v, true
  9971. }
  9972. // ClearType clears the value of the "type" field.
  9973. func (m *ContactMutation) ClearType() {
  9974. m._type = nil
  9975. m.add_type = nil
  9976. m.clearedFields[contact.FieldType] = struct{}{}
  9977. }
  9978. // TypeCleared returns if the "type" field was cleared in this mutation.
  9979. func (m *ContactMutation) TypeCleared() bool {
  9980. _, ok := m.clearedFields[contact.FieldType]
  9981. return ok
  9982. }
  9983. // ResetType resets all changes to the "type" field.
  9984. func (m *ContactMutation) ResetType() {
  9985. m._type = nil
  9986. m.add_type = nil
  9987. delete(m.clearedFields, contact.FieldType)
  9988. }
  9989. // SetWxid sets the "wxid" field.
  9990. func (m *ContactMutation) SetWxid(s string) {
  9991. m.wxid = &s
  9992. }
  9993. // Wxid returns the value of the "wxid" field in the mutation.
  9994. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9995. v := m.wxid
  9996. if v == nil {
  9997. return
  9998. }
  9999. return *v, true
  10000. }
  10001. // OldWxid returns the old "wxid" field's value of the Contact entity.
  10002. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10004. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  10005. if !m.op.Is(OpUpdateOne) {
  10006. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  10007. }
  10008. if m.id == nil || m.oldValue == nil {
  10009. return v, errors.New("OldWxid requires an ID field in the mutation")
  10010. }
  10011. oldValue, err := m.oldValue(ctx)
  10012. if err != nil {
  10013. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  10014. }
  10015. return oldValue.Wxid, nil
  10016. }
  10017. // ResetWxid resets all changes to the "wxid" field.
  10018. func (m *ContactMutation) ResetWxid() {
  10019. m.wxid = nil
  10020. }
  10021. // SetAccount sets the "account" field.
  10022. func (m *ContactMutation) SetAccount(s string) {
  10023. m.account = &s
  10024. }
  10025. // Account returns the value of the "account" field in the mutation.
  10026. func (m *ContactMutation) Account() (r string, exists bool) {
  10027. v := m.account
  10028. if v == nil {
  10029. return
  10030. }
  10031. return *v, true
  10032. }
  10033. // OldAccount returns the old "account" field's value of the Contact entity.
  10034. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10036. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  10037. if !m.op.Is(OpUpdateOne) {
  10038. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  10039. }
  10040. if m.id == nil || m.oldValue == nil {
  10041. return v, errors.New("OldAccount requires an ID field in the mutation")
  10042. }
  10043. oldValue, err := m.oldValue(ctx)
  10044. if err != nil {
  10045. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  10046. }
  10047. return oldValue.Account, nil
  10048. }
  10049. // ResetAccount resets all changes to the "account" field.
  10050. func (m *ContactMutation) ResetAccount() {
  10051. m.account = nil
  10052. }
  10053. // SetNickname sets the "nickname" field.
  10054. func (m *ContactMutation) SetNickname(s string) {
  10055. m.nickname = &s
  10056. }
  10057. // Nickname returns the value of the "nickname" field in the mutation.
  10058. func (m *ContactMutation) Nickname() (r string, exists bool) {
  10059. v := m.nickname
  10060. if v == nil {
  10061. return
  10062. }
  10063. return *v, true
  10064. }
  10065. // OldNickname returns the old "nickname" field's value of the Contact entity.
  10066. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10068. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  10069. if !m.op.Is(OpUpdateOne) {
  10070. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  10071. }
  10072. if m.id == nil || m.oldValue == nil {
  10073. return v, errors.New("OldNickname requires an ID field in the mutation")
  10074. }
  10075. oldValue, err := m.oldValue(ctx)
  10076. if err != nil {
  10077. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  10078. }
  10079. return oldValue.Nickname, nil
  10080. }
  10081. // ResetNickname resets all changes to the "nickname" field.
  10082. func (m *ContactMutation) ResetNickname() {
  10083. m.nickname = nil
  10084. }
  10085. // SetMarkname sets the "markname" field.
  10086. func (m *ContactMutation) SetMarkname(s string) {
  10087. m.markname = &s
  10088. }
  10089. // Markname returns the value of the "markname" field in the mutation.
  10090. func (m *ContactMutation) Markname() (r string, exists bool) {
  10091. v := m.markname
  10092. if v == nil {
  10093. return
  10094. }
  10095. return *v, true
  10096. }
  10097. // OldMarkname returns the old "markname" field's value of the Contact entity.
  10098. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10100. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  10101. if !m.op.Is(OpUpdateOne) {
  10102. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  10103. }
  10104. if m.id == nil || m.oldValue == nil {
  10105. return v, errors.New("OldMarkname requires an ID field in the mutation")
  10106. }
  10107. oldValue, err := m.oldValue(ctx)
  10108. if err != nil {
  10109. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  10110. }
  10111. return oldValue.Markname, nil
  10112. }
  10113. // ResetMarkname resets all changes to the "markname" field.
  10114. func (m *ContactMutation) ResetMarkname() {
  10115. m.markname = nil
  10116. }
  10117. // SetHeadimg sets the "headimg" field.
  10118. func (m *ContactMutation) SetHeadimg(s string) {
  10119. m.headimg = &s
  10120. }
  10121. // Headimg returns the value of the "headimg" field in the mutation.
  10122. func (m *ContactMutation) Headimg() (r string, exists bool) {
  10123. v := m.headimg
  10124. if v == nil {
  10125. return
  10126. }
  10127. return *v, true
  10128. }
  10129. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  10130. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10132. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  10133. if !m.op.Is(OpUpdateOne) {
  10134. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  10135. }
  10136. if m.id == nil || m.oldValue == nil {
  10137. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  10138. }
  10139. oldValue, err := m.oldValue(ctx)
  10140. if err != nil {
  10141. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  10142. }
  10143. return oldValue.Headimg, nil
  10144. }
  10145. // ResetHeadimg resets all changes to the "headimg" field.
  10146. func (m *ContactMutation) ResetHeadimg() {
  10147. m.headimg = nil
  10148. }
  10149. // SetSex sets the "sex" field.
  10150. func (m *ContactMutation) SetSex(i int) {
  10151. m.sex = &i
  10152. m.addsex = nil
  10153. }
  10154. // Sex returns the value of the "sex" field in the mutation.
  10155. func (m *ContactMutation) Sex() (r int, exists bool) {
  10156. v := m.sex
  10157. if v == nil {
  10158. return
  10159. }
  10160. return *v, true
  10161. }
  10162. // OldSex returns the old "sex" field's value of the Contact entity.
  10163. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10165. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  10166. if !m.op.Is(OpUpdateOne) {
  10167. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  10168. }
  10169. if m.id == nil || m.oldValue == nil {
  10170. return v, errors.New("OldSex requires an ID field in the mutation")
  10171. }
  10172. oldValue, err := m.oldValue(ctx)
  10173. if err != nil {
  10174. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  10175. }
  10176. return oldValue.Sex, nil
  10177. }
  10178. // AddSex adds i to the "sex" field.
  10179. func (m *ContactMutation) AddSex(i int) {
  10180. if m.addsex != nil {
  10181. *m.addsex += i
  10182. } else {
  10183. m.addsex = &i
  10184. }
  10185. }
  10186. // AddedSex returns the value that was added to the "sex" field in this mutation.
  10187. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  10188. v := m.addsex
  10189. if v == nil {
  10190. return
  10191. }
  10192. return *v, true
  10193. }
  10194. // ResetSex resets all changes to the "sex" field.
  10195. func (m *ContactMutation) ResetSex() {
  10196. m.sex = nil
  10197. m.addsex = nil
  10198. }
  10199. // SetStarrole sets the "starrole" field.
  10200. func (m *ContactMutation) SetStarrole(s string) {
  10201. m.starrole = &s
  10202. }
  10203. // Starrole returns the value of the "starrole" field in the mutation.
  10204. func (m *ContactMutation) Starrole() (r string, exists bool) {
  10205. v := m.starrole
  10206. if v == nil {
  10207. return
  10208. }
  10209. return *v, true
  10210. }
  10211. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  10212. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10214. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  10215. if !m.op.Is(OpUpdateOne) {
  10216. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  10217. }
  10218. if m.id == nil || m.oldValue == nil {
  10219. return v, errors.New("OldStarrole requires an ID field in the mutation")
  10220. }
  10221. oldValue, err := m.oldValue(ctx)
  10222. if err != nil {
  10223. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  10224. }
  10225. return oldValue.Starrole, nil
  10226. }
  10227. // ResetStarrole resets all changes to the "starrole" field.
  10228. func (m *ContactMutation) ResetStarrole() {
  10229. m.starrole = nil
  10230. }
  10231. // SetDontseeit sets the "dontseeit" field.
  10232. func (m *ContactMutation) SetDontseeit(i int) {
  10233. m.dontseeit = &i
  10234. m.adddontseeit = nil
  10235. }
  10236. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  10237. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  10238. v := m.dontseeit
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  10245. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10247. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  10248. if !m.op.Is(OpUpdateOne) {
  10249. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  10250. }
  10251. if m.id == nil || m.oldValue == nil {
  10252. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  10253. }
  10254. oldValue, err := m.oldValue(ctx)
  10255. if err != nil {
  10256. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  10257. }
  10258. return oldValue.Dontseeit, nil
  10259. }
  10260. // AddDontseeit adds i to the "dontseeit" field.
  10261. func (m *ContactMutation) AddDontseeit(i int) {
  10262. if m.adddontseeit != nil {
  10263. *m.adddontseeit += i
  10264. } else {
  10265. m.adddontseeit = &i
  10266. }
  10267. }
  10268. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  10269. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  10270. v := m.adddontseeit
  10271. if v == nil {
  10272. return
  10273. }
  10274. return *v, true
  10275. }
  10276. // ResetDontseeit resets all changes to the "dontseeit" field.
  10277. func (m *ContactMutation) ResetDontseeit() {
  10278. m.dontseeit = nil
  10279. m.adddontseeit = nil
  10280. }
  10281. // SetDontseeme sets the "dontseeme" field.
  10282. func (m *ContactMutation) SetDontseeme(i int) {
  10283. m.dontseeme = &i
  10284. m.adddontseeme = nil
  10285. }
  10286. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  10287. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  10288. v := m.dontseeme
  10289. if v == nil {
  10290. return
  10291. }
  10292. return *v, true
  10293. }
  10294. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  10295. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10297. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  10298. if !m.op.Is(OpUpdateOne) {
  10299. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  10300. }
  10301. if m.id == nil || m.oldValue == nil {
  10302. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  10303. }
  10304. oldValue, err := m.oldValue(ctx)
  10305. if err != nil {
  10306. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  10307. }
  10308. return oldValue.Dontseeme, nil
  10309. }
  10310. // AddDontseeme adds i to the "dontseeme" field.
  10311. func (m *ContactMutation) AddDontseeme(i int) {
  10312. if m.adddontseeme != nil {
  10313. *m.adddontseeme += i
  10314. } else {
  10315. m.adddontseeme = &i
  10316. }
  10317. }
  10318. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  10319. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  10320. v := m.adddontseeme
  10321. if v == nil {
  10322. return
  10323. }
  10324. return *v, true
  10325. }
  10326. // ResetDontseeme resets all changes to the "dontseeme" field.
  10327. func (m *ContactMutation) ResetDontseeme() {
  10328. m.dontseeme = nil
  10329. m.adddontseeme = nil
  10330. }
  10331. // SetLag sets the "lag" field.
  10332. func (m *ContactMutation) SetLag(s string) {
  10333. m.lag = &s
  10334. }
  10335. // Lag returns the value of the "lag" field in the mutation.
  10336. func (m *ContactMutation) Lag() (r string, exists bool) {
  10337. v := m.lag
  10338. if v == nil {
  10339. return
  10340. }
  10341. return *v, true
  10342. }
  10343. // OldLag returns the old "lag" field's value of the Contact entity.
  10344. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10346. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10347. if !m.op.Is(OpUpdateOne) {
  10348. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10349. }
  10350. if m.id == nil || m.oldValue == nil {
  10351. return v, errors.New("OldLag requires an ID field in the mutation")
  10352. }
  10353. oldValue, err := m.oldValue(ctx)
  10354. if err != nil {
  10355. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10356. }
  10357. return oldValue.Lag, nil
  10358. }
  10359. // ResetLag resets all changes to the "lag" field.
  10360. func (m *ContactMutation) ResetLag() {
  10361. m.lag = nil
  10362. }
  10363. // SetGid sets the "gid" field.
  10364. func (m *ContactMutation) SetGid(s string) {
  10365. m.gid = &s
  10366. }
  10367. // Gid returns the value of the "gid" field in the mutation.
  10368. func (m *ContactMutation) Gid() (r string, exists bool) {
  10369. v := m.gid
  10370. if v == nil {
  10371. return
  10372. }
  10373. return *v, true
  10374. }
  10375. // OldGid returns the old "gid" field's value of the Contact entity.
  10376. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10378. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10379. if !m.op.Is(OpUpdateOne) {
  10380. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10381. }
  10382. if m.id == nil || m.oldValue == nil {
  10383. return v, errors.New("OldGid requires an ID field in the mutation")
  10384. }
  10385. oldValue, err := m.oldValue(ctx)
  10386. if err != nil {
  10387. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10388. }
  10389. return oldValue.Gid, nil
  10390. }
  10391. // ResetGid resets all changes to the "gid" field.
  10392. func (m *ContactMutation) ResetGid() {
  10393. m.gid = nil
  10394. }
  10395. // SetGname sets the "gname" field.
  10396. func (m *ContactMutation) SetGname(s string) {
  10397. m.gname = &s
  10398. }
  10399. // Gname returns the value of the "gname" field in the mutation.
  10400. func (m *ContactMutation) Gname() (r string, exists bool) {
  10401. v := m.gname
  10402. if v == nil {
  10403. return
  10404. }
  10405. return *v, true
  10406. }
  10407. // OldGname returns the old "gname" field's value of the Contact entity.
  10408. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10410. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10411. if !m.op.Is(OpUpdateOne) {
  10412. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10413. }
  10414. if m.id == nil || m.oldValue == nil {
  10415. return v, errors.New("OldGname requires an ID field in the mutation")
  10416. }
  10417. oldValue, err := m.oldValue(ctx)
  10418. if err != nil {
  10419. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10420. }
  10421. return oldValue.Gname, nil
  10422. }
  10423. // ResetGname resets all changes to the "gname" field.
  10424. func (m *ContactMutation) ResetGname() {
  10425. m.gname = nil
  10426. }
  10427. // SetV3 sets the "v3" field.
  10428. func (m *ContactMutation) SetV3(s string) {
  10429. m.v3 = &s
  10430. }
  10431. // V3 returns the value of the "v3" field in the mutation.
  10432. func (m *ContactMutation) V3() (r string, exists bool) {
  10433. v := m.v3
  10434. if v == nil {
  10435. return
  10436. }
  10437. return *v, true
  10438. }
  10439. // OldV3 returns the old "v3" field's value of the Contact entity.
  10440. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10442. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10443. if !m.op.Is(OpUpdateOne) {
  10444. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10445. }
  10446. if m.id == nil || m.oldValue == nil {
  10447. return v, errors.New("OldV3 requires an ID field in the mutation")
  10448. }
  10449. oldValue, err := m.oldValue(ctx)
  10450. if err != nil {
  10451. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10452. }
  10453. return oldValue.V3, nil
  10454. }
  10455. // ResetV3 resets all changes to the "v3" field.
  10456. func (m *ContactMutation) ResetV3() {
  10457. m.v3 = nil
  10458. }
  10459. // SetOrganizationID sets the "organization_id" field.
  10460. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10461. m.organization_id = &u
  10462. m.addorganization_id = nil
  10463. }
  10464. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10465. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10466. v := m.organization_id
  10467. if v == nil {
  10468. return
  10469. }
  10470. return *v, true
  10471. }
  10472. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10473. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10475. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10476. if !m.op.Is(OpUpdateOne) {
  10477. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10478. }
  10479. if m.id == nil || m.oldValue == nil {
  10480. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10481. }
  10482. oldValue, err := m.oldValue(ctx)
  10483. if err != nil {
  10484. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10485. }
  10486. return oldValue.OrganizationID, nil
  10487. }
  10488. // AddOrganizationID adds u to the "organization_id" field.
  10489. func (m *ContactMutation) AddOrganizationID(u int64) {
  10490. if m.addorganization_id != nil {
  10491. *m.addorganization_id += u
  10492. } else {
  10493. m.addorganization_id = &u
  10494. }
  10495. }
  10496. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10497. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10498. v := m.addorganization_id
  10499. if v == nil {
  10500. return
  10501. }
  10502. return *v, true
  10503. }
  10504. // ClearOrganizationID clears the value of the "organization_id" field.
  10505. func (m *ContactMutation) ClearOrganizationID() {
  10506. m.organization_id = nil
  10507. m.addorganization_id = nil
  10508. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10509. }
  10510. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10511. func (m *ContactMutation) OrganizationIDCleared() bool {
  10512. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10513. return ok
  10514. }
  10515. // ResetOrganizationID resets all changes to the "organization_id" field.
  10516. func (m *ContactMutation) ResetOrganizationID() {
  10517. m.organization_id = nil
  10518. m.addorganization_id = nil
  10519. delete(m.clearedFields, contact.FieldOrganizationID)
  10520. }
  10521. // SetCtype sets the "ctype" field.
  10522. func (m *ContactMutation) SetCtype(u uint64) {
  10523. m.ctype = &u
  10524. m.addctype = nil
  10525. }
  10526. // Ctype returns the value of the "ctype" field in the mutation.
  10527. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10528. v := m.ctype
  10529. if v == nil {
  10530. return
  10531. }
  10532. return *v, true
  10533. }
  10534. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10535. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10537. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10538. if !m.op.Is(OpUpdateOne) {
  10539. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10540. }
  10541. if m.id == nil || m.oldValue == nil {
  10542. return v, errors.New("OldCtype requires an ID field in the mutation")
  10543. }
  10544. oldValue, err := m.oldValue(ctx)
  10545. if err != nil {
  10546. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10547. }
  10548. return oldValue.Ctype, nil
  10549. }
  10550. // AddCtype adds u to the "ctype" field.
  10551. func (m *ContactMutation) AddCtype(u int64) {
  10552. if m.addctype != nil {
  10553. *m.addctype += u
  10554. } else {
  10555. m.addctype = &u
  10556. }
  10557. }
  10558. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10559. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10560. v := m.addctype
  10561. if v == nil {
  10562. return
  10563. }
  10564. return *v, true
  10565. }
  10566. // ResetCtype resets all changes to the "ctype" field.
  10567. func (m *ContactMutation) ResetCtype() {
  10568. m.ctype = nil
  10569. m.addctype = nil
  10570. }
  10571. // SetCage sets the "cage" field.
  10572. func (m *ContactMutation) SetCage(i int) {
  10573. m.cage = &i
  10574. m.addcage = nil
  10575. }
  10576. // Cage returns the value of the "cage" field in the mutation.
  10577. func (m *ContactMutation) Cage() (r int, exists bool) {
  10578. v := m.cage
  10579. if v == nil {
  10580. return
  10581. }
  10582. return *v, true
  10583. }
  10584. // OldCage returns the old "cage" field's value of the Contact entity.
  10585. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10587. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10588. if !m.op.Is(OpUpdateOne) {
  10589. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10590. }
  10591. if m.id == nil || m.oldValue == nil {
  10592. return v, errors.New("OldCage requires an ID field in the mutation")
  10593. }
  10594. oldValue, err := m.oldValue(ctx)
  10595. if err != nil {
  10596. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10597. }
  10598. return oldValue.Cage, nil
  10599. }
  10600. // AddCage adds i to the "cage" field.
  10601. func (m *ContactMutation) AddCage(i int) {
  10602. if m.addcage != nil {
  10603. *m.addcage += i
  10604. } else {
  10605. m.addcage = &i
  10606. }
  10607. }
  10608. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10609. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10610. v := m.addcage
  10611. if v == nil {
  10612. return
  10613. }
  10614. return *v, true
  10615. }
  10616. // ResetCage resets all changes to the "cage" field.
  10617. func (m *ContactMutation) ResetCage() {
  10618. m.cage = nil
  10619. m.addcage = nil
  10620. }
  10621. // SetCname sets the "cname" field.
  10622. func (m *ContactMutation) SetCname(s string) {
  10623. m.cname = &s
  10624. }
  10625. // Cname returns the value of the "cname" field in the mutation.
  10626. func (m *ContactMutation) Cname() (r string, exists bool) {
  10627. v := m.cname
  10628. if v == nil {
  10629. return
  10630. }
  10631. return *v, true
  10632. }
  10633. // OldCname returns the old "cname" field's value of the Contact entity.
  10634. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10636. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10637. if !m.op.Is(OpUpdateOne) {
  10638. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10639. }
  10640. if m.id == nil || m.oldValue == nil {
  10641. return v, errors.New("OldCname requires an ID field in the mutation")
  10642. }
  10643. oldValue, err := m.oldValue(ctx)
  10644. if err != nil {
  10645. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10646. }
  10647. return oldValue.Cname, nil
  10648. }
  10649. // ResetCname resets all changes to the "cname" field.
  10650. func (m *ContactMutation) ResetCname() {
  10651. m.cname = nil
  10652. }
  10653. // SetCarea sets the "carea" field.
  10654. func (m *ContactMutation) SetCarea(s string) {
  10655. m.carea = &s
  10656. }
  10657. // Carea returns the value of the "carea" field in the mutation.
  10658. func (m *ContactMutation) Carea() (r string, exists bool) {
  10659. v := m.carea
  10660. if v == nil {
  10661. return
  10662. }
  10663. return *v, true
  10664. }
  10665. // OldCarea returns the old "carea" field's value of the Contact entity.
  10666. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10668. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10669. if !m.op.Is(OpUpdateOne) {
  10670. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10671. }
  10672. if m.id == nil || m.oldValue == nil {
  10673. return v, errors.New("OldCarea requires an ID field in the mutation")
  10674. }
  10675. oldValue, err := m.oldValue(ctx)
  10676. if err != nil {
  10677. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10678. }
  10679. return oldValue.Carea, nil
  10680. }
  10681. // ResetCarea resets all changes to the "carea" field.
  10682. func (m *ContactMutation) ResetCarea() {
  10683. m.carea = nil
  10684. }
  10685. // SetCbirthday sets the "cbirthday" field.
  10686. func (m *ContactMutation) SetCbirthday(s string) {
  10687. m.cbirthday = &s
  10688. }
  10689. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10690. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10691. v := m.cbirthday
  10692. if v == nil {
  10693. return
  10694. }
  10695. return *v, true
  10696. }
  10697. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10698. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10700. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10701. if !m.op.Is(OpUpdateOne) {
  10702. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10703. }
  10704. if m.id == nil || m.oldValue == nil {
  10705. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10706. }
  10707. oldValue, err := m.oldValue(ctx)
  10708. if err != nil {
  10709. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10710. }
  10711. return oldValue.Cbirthday, nil
  10712. }
  10713. // ResetCbirthday resets all changes to the "cbirthday" field.
  10714. func (m *ContactMutation) ResetCbirthday() {
  10715. m.cbirthday = nil
  10716. }
  10717. // SetCbirtharea sets the "cbirtharea" field.
  10718. func (m *ContactMutation) SetCbirtharea(s string) {
  10719. m.cbirtharea = &s
  10720. }
  10721. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10722. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10723. v := m.cbirtharea
  10724. if v == nil {
  10725. return
  10726. }
  10727. return *v, true
  10728. }
  10729. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10730. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10732. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10733. if !m.op.Is(OpUpdateOne) {
  10734. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10735. }
  10736. if m.id == nil || m.oldValue == nil {
  10737. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10738. }
  10739. oldValue, err := m.oldValue(ctx)
  10740. if err != nil {
  10741. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10742. }
  10743. return oldValue.Cbirtharea, nil
  10744. }
  10745. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10746. func (m *ContactMutation) ResetCbirtharea() {
  10747. m.cbirtharea = nil
  10748. }
  10749. // SetCidcardNo sets the "cidcard_no" field.
  10750. func (m *ContactMutation) SetCidcardNo(s string) {
  10751. m.cidcard_no = &s
  10752. }
  10753. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10754. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10755. v := m.cidcard_no
  10756. if v == nil {
  10757. return
  10758. }
  10759. return *v, true
  10760. }
  10761. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10762. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10764. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10765. if !m.op.Is(OpUpdateOne) {
  10766. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10767. }
  10768. if m.id == nil || m.oldValue == nil {
  10769. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10770. }
  10771. oldValue, err := m.oldValue(ctx)
  10772. if err != nil {
  10773. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10774. }
  10775. return oldValue.CidcardNo, nil
  10776. }
  10777. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10778. func (m *ContactMutation) ResetCidcardNo() {
  10779. m.cidcard_no = nil
  10780. }
  10781. // SetCtitle sets the "ctitle" field.
  10782. func (m *ContactMutation) SetCtitle(s string) {
  10783. m.ctitle = &s
  10784. }
  10785. // Ctitle returns the value of the "ctitle" field in the mutation.
  10786. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10787. v := m.ctitle
  10788. if v == nil {
  10789. return
  10790. }
  10791. return *v, true
  10792. }
  10793. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10794. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10796. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10797. if !m.op.Is(OpUpdateOne) {
  10798. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10799. }
  10800. if m.id == nil || m.oldValue == nil {
  10801. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10802. }
  10803. oldValue, err := m.oldValue(ctx)
  10804. if err != nil {
  10805. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10806. }
  10807. return oldValue.Ctitle, nil
  10808. }
  10809. // ResetCtitle resets all changes to the "ctitle" field.
  10810. func (m *ContactMutation) ResetCtitle() {
  10811. m.ctitle = nil
  10812. }
  10813. // SetCc sets the "cc" field.
  10814. func (m *ContactMutation) SetCc(s string) {
  10815. m.cc = &s
  10816. }
  10817. // Cc returns the value of the "cc" field in the mutation.
  10818. func (m *ContactMutation) Cc() (r string, exists bool) {
  10819. v := m.cc
  10820. if v == nil {
  10821. return
  10822. }
  10823. return *v, true
  10824. }
  10825. // OldCc returns the old "cc" field's value of the Contact entity.
  10826. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10828. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10829. if !m.op.Is(OpUpdateOne) {
  10830. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10831. }
  10832. if m.id == nil || m.oldValue == nil {
  10833. return v, errors.New("OldCc requires an ID field in the mutation")
  10834. }
  10835. oldValue, err := m.oldValue(ctx)
  10836. if err != nil {
  10837. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10838. }
  10839. return oldValue.Cc, nil
  10840. }
  10841. // ResetCc resets all changes to the "cc" field.
  10842. func (m *ContactMutation) ResetCc() {
  10843. m.cc = nil
  10844. }
  10845. // SetPhone sets the "phone" field.
  10846. func (m *ContactMutation) SetPhone(s string) {
  10847. m.phone = &s
  10848. }
  10849. // Phone returns the value of the "phone" field in the mutation.
  10850. func (m *ContactMutation) Phone() (r string, exists bool) {
  10851. v := m.phone
  10852. if v == nil {
  10853. return
  10854. }
  10855. return *v, true
  10856. }
  10857. // OldPhone returns the old "phone" field's value of the Contact entity.
  10858. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10860. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10861. if !m.op.Is(OpUpdateOne) {
  10862. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10863. }
  10864. if m.id == nil || m.oldValue == nil {
  10865. return v, errors.New("OldPhone requires an ID field in the mutation")
  10866. }
  10867. oldValue, err := m.oldValue(ctx)
  10868. if err != nil {
  10869. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10870. }
  10871. return oldValue.Phone, nil
  10872. }
  10873. // ResetPhone resets all changes to the "phone" field.
  10874. func (m *ContactMutation) ResetPhone() {
  10875. m.phone = nil
  10876. }
  10877. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10878. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10879. if m.contact_relationships == nil {
  10880. m.contact_relationships = make(map[uint64]struct{})
  10881. }
  10882. for i := range ids {
  10883. m.contact_relationships[ids[i]] = struct{}{}
  10884. }
  10885. }
  10886. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10887. func (m *ContactMutation) ClearContactRelationships() {
  10888. m.clearedcontact_relationships = true
  10889. }
  10890. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10891. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10892. return m.clearedcontact_relationships
  10893. }
  10894. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10895. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10896. if m.removedcontact_relationships == nil {
  10897. m.removedcontact_relationships = make(map[uint64]struct{})
  10898. }
  10899. for i := range ids {
  10900. delete(m.contact_relationships, ids[i])
  10901. m.removedcontact_relationships[ids[i]] = struct{}{}
  10902. }
  10903. }
  10904. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10905. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10906. for id := range m.removedcontact_relationships {
  10907. ids = append(ids, id)
  10908. }
  10909. return
  10910. }
  10911. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10912. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10913. for id := range m.contact_relationships {
  10914. ids = append(ids, id)
  10915. }
  10916. return
  10917. }
  10918. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10919. func (m *ContactMutation) ResetContactRelationships() {
  10920. m.contact_relationships = nil
  10921. m.clearedcontact_relationships = false
  10922. m.removedcontact_relationships = nil
  10923. }
  10924. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  10925. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  10926. if m.contact_fields == nil {
  10927. m.contact_fields = make(map[uint64]struct{})
  10928. }
  10929. for i := range ids {
  10930. m.contact_fields[ids[i]] = struct{}{}
  10931. }
  10932. }
  10933. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  10934. func (m *ContactMutation) ClearContactFields() {
  10935. m.clearedcontact_fields = true
  10936. }
  10937. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  10938. func (m *ContactMutation) ContactFieldsCleared() bool {
  10939. return m.clearedcontact_fields
  10940. }
  10941. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  10942. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  10943. if m.removedcontact_fields == nil {
  10944. m.removedcontact_fields = make(map[uint64]struct{})
  10945. }
  10946. for i := range ids {
  10947. delete(m.contact_fields, ids[i])
  10948. m.removedcontact_fields[ids[i]] = struct{}{}
  10949. }
  10950. }
  10951. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  10952. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  10953. for id := range m.removedcontact_fields {
  10954. ids = append(ids, id)
  10955. }
  10956. return
  10957. }
  10958. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  10959. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  10960. for id := range m.contact_fields {
  10961. ids = append(ids, id)
  10962. }
  10963. return
  10964. }
  10965. // ResetContactFields resets all changes to the "contact_fields" edge.
  10966. func (m *ContactMutation) ResetContactFields() {
  10967. m.contact_fields = nil
  10968. m.clearedcontact_fields = false
  10969. m.removedcontact_fields = nil
  10970. }
  10971. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10972. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10973. if m.contact_messages == nil {
  10974. m.contact_messages = make(map[uint64]struct{})
  10975. }
  10976. for i := range ids {
  10977. m.contact_messages[ids[i]] = struct{}{}
  10978. }
  10979. }
  10980. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10981. func (m *ContactMutation) ClearContactMessages() {
  10982. m.clearedcontact_messages = true
  10983. }
  10984. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10985. func (m *ContactMutation) ContactMessagesCleared() bool {
  10986. return m.clearedcontact_messages
  10987. }
  10988. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10989. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10990. if m.removedcontact_messages == nil {
  10991. m.removedcontact_messages = make(map[uint64]struct{})
  10992. }
  10993. for i := range ids {
  10994. delete(m.contact_messages, ids[i])
  10995. m.removedcontact_messages[ids[i]] = struct{}{}
  10996. }
  10997. }
  10998. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10999. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  11000. for id := range m.removedcontact_messages {
  11001. ids = append(ids, id)
  11002. }
  11003. return
  11004. }
  11005. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  11006. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  11007. for id := range m.contact_messages {
  11008. ids = append(ids, id)
  11009. }
  11010. return
  11011. }
  11012. // ResetContactMessages resets all changes to the "contact_messages" edge.
  11013. func (m *ContactMutation) ResetContactMessages() {
  11014. m.contact_messages = nil
  11015. m.clearedcontact_messages = false
  11016. m.removedcontact_messages = nil
  11017. }
  11018. // Where appends a list predicates to the ContactMutation builder.
  11019. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  11020. m.predicates = append(m.predicates, ps...)
  11021. }
  11022. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  11023. // users can use type-assertion to append predicates that do not depend on any generated package.
  11024. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  11025. p := make([]predicate.Contact, len(ps))
  11026. for i := range ps {
  11027. p[i] = ps[i]
  11028. }
  11029. m.Where(p...)
  11030. }
  11031. // Op returns the operation name.
  11032. func (m *ContactMutation) Op() Op {
  11033. return m.op
  11034. }
  11035. // SetOp allows setting the mutation operation.
  11036. func (m *ContactMutation) SetOp(op Op) {
  11037. m.op = op
  11038. }
  11039. // Type returns the node type of this mutation (Contact).
  11040. func (m *ContactMutation) Type() string {
  11041. return m.typ
  11042. }
  11043. // Fields returns all fields that were changed during this mutation. Note that in
  11044. // order to get all numeric fields that were incremented/decremented, call
  11045. // AddedFields().
  11046. func (m *ContactMutation) Fields() []string {
  11047. fields := make([]string, 0, 30)
  11048. if m.created_at != nil {
  11049. fields = append(fields, contact.FieldCreatedAt)
  11050. }
  11051. if m.updated_at != nil {
  11052. fields = append(fields, contact.FieldUpdatedAt)
  11053. }
  11054. if m.status != nil {
  11055. fields = append(fields, contact.FieldStatus)
  11056. }
  11057. if m.deleted_at != nil {
  11058. fields = append(fields, contact.FieldDeletedAt)
  11059. }
  11060. if m.wx_wxid != nil {
  11061. fields = append(fields, contact.FieldWxWxid)
  11062. }
  11063. if m._type != nil {
  11064. fields = append(fields, contact.FieldType)
  11065. }
  11066. if m.wxid != nil {
  11067. fields = append(fields, contact.FieldWxid)
  11068. }
  11069. if m.account != nil {
  11070. fields = append(fields, contact.FieldAccount)
  11071. }
  11072. if m.nickname != nil {
  11073. fields = append(fields, contact.FieldNickname)
  11074. }
  11075. if m.markname != nil {
  11076. fields = append(fields, contact.FieldMarkname)
  11077. }
  11078. if m.headimg != nil {
  11079. fields = append(fields, contact.FieldHeadimg)
  11080. }
  11081. if m.sex != nil {
  11082. fields = append(fields, contact.FieldSex)
  11083. }
  11084. if m.starrole != nil {
  11085. fields = append(fields, contact.FieldStarrole)
  11086. }
  11087. if m.dontseeit != nil {
  11088. fields = append(fields, contact.FieldDontseeit)
  11089. }
  11090. if m.dontseeme != nil {
  11091. fields = append(fields, contact.FieldDontseeme)
  11092. }
  11093. if m.lag != nil {
  11094. fields = append(fields, contact.FieldLag)
  11095. }
  11096. if m.gid != nil {
  11097. fields = append(fields, contact.FieldGid)
  11098. }
  11099. if m.gname != nil {
  11100. fields = append(fields, contact.FieldGname)
  11101. }
  11102. if m.v3 != nil {
  11103. fields = append(fields, contact.FieldV3)
  11104. }
  11105. if m.organization_id != nil {
  11106. fields = append(fields, contact.FieldOrganizationID)
  11107. }
  11108. if m.ctype != nil {
  11109. fields = append(fields, contact.FieldCtype)
  11110. }
  11111. if m.cage != nil {
  11112. fields = append(fields, contact.FieldCage)
  11113. }
  11114. if m.cname != nil {
  11115. fields = append(fields, contact.FieldCname)
  11116. }
  11117. if m.carea != nil {
  11118. fields = append(fields, contact.FieldCarea)
  11119. }
  11120. if m.cbirthday != nil {
  11121. fields = append(fields, contact.FieldCbirthday)
  11122. }
  11123. if m.cbirtharea != nil {
  11124. fields = append(fields, contact.FieldCbirtharea)
  11125. }
  11126. if m.cidcard_no != nil {
  11127. fields = append(fields, contact.FieldCidcardNo)
  11128. }
  11129. if m.ctitle != nil {
  11130. fields = append(fields, contact.FieldCtitle)
  11131. }
  11132. if m.cc != nil {
  11133. fields = append(fields, contact.FieldCc)
  11134. }
  11135. if m.phone != nil {
  11136. fields = append(fields, contact.FieldPhone)
  11137. }
  11138. return fields
  11139. }
  11140. // Field returns the value of a field with the given name. The second boolean
  11141. // return value indicates that this field was not set, or was not defined in the
  11142. // schema.
  11143. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  11144. switch name {
  11145. case contact.FieldCreatedAt:
  11146. return m.CreatedAt()
  11147. case contact.FieldUpdatedAt:
  11148. return m.UpdatedAt()
  11149. case contact.FieldStatus:
  11150. return m.Status()
  11151. case contact.FieldDeletedAt:
  11152. return m.DeletedAt()
  11153. case contact.FieldWxWxid:
  11154. return m.WxWxid()
  11155. case contact.FieldType:
  11156. return m.GetType()
  11157. case contact.FieldWxid:
  11158. return m.Wxid()
  11159. case contact.FieldAccount:
  11160. return m.Account()
  11161. case contact.FieldNickname:
  11162. return m.Nickname()
  11163. case contact.FieldMarkname:
  11164. return m.Markname()
  11165. case contact.FieldHeadimg:
  11166. return m.Headimg()
  11167. case contact.FieldSex:
  11168. return m.Sex()
  11169. case contact.FieldStarrole:
  11170. return m.Starrole()
  11171. case contact.FieldDontseeit:
  11172. return m.Dontseeit()
  11173. case contact.FieldDontseeme:
  11174. return m.Dontseeme()
  11175. case contact.FieldLag:
  11176. return m.Lag()
  11177. case contact.FieldGid:
  11178. return m.Gid()
  11179. case contact.FieldGname:
  11180. return m.Gname()
  11181. case contact.FieldV3:
  11182. return m.V3()
  11183. case contact.FieldOrganizationID:
  11184. return m.OrganizationID()
  11185. case contact.FieldCtype:
  11186. return m.Ctype()
  11187. case contact.FieldCage:
  11188. return m.Cage()
  11189. case contact.FieldCname:
  11190. return m.Cname()
  11191. case contact.FieldCarea:
  11192. return m.Carea()
  11193. case contact.FieldCbirthday:
  11194. return m.Cbirthday()
  11195. case contact.FieldCbirtharea:
  11196. return m.Cbirtharea()
  11197. case contact.FieldCidcardNo:
  11198. return m.CidcardNo()
  11199. case contact.FieldCtitle:
  11200. return m.Ctitle()
  11201. case contact.FieldCc:
  11202. return m.Cc()
  11203. case contact.FieldPhone:
  11204. return m.Phone()
  11205. }
  11206. return nil, false
  11207. }
  11208. // OldField returns the old value of the field from the database. An error is
  11209. // returned if the mutation operation is not UpdateOne, or the query to the
  11210. // database failed.
  11211. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11212. switch name {
  11213. case contact.FieldCreatedAt:
  11214. return m.OldCreatedAt(ctx)
  11215. case contact.FieldUpdatedAt:
  11216. return m.OldUpdatedAt(ctx)
  11217. case contact.FieldStatus:
  11218. return m.OldStatus(ctx)
  11219. case contact.FieldDeletedAt:
  11220. return m.OldDeletedAt(ctx)
  11221. case contact.FieldWxWxid:
  11222. return m.OldWxWxid(ctx)
  11223. case contact.FieldType:
  11224. return m.OldType(ctx)
  11225. case contact.FieldWxid:
  11226. return m.OldWxid(ctx)
  11227. case contact.FieldAccount:
  11228. return m.OldAccount(ctx)
  11229. case contact.FieldNickname:
  11230. return m.OldNickname(ctx)
  11231. case contact.FieldMarkname:
  11232. return m.OldMarkname(ctx)
  11233. case contact.FieldHeadimg:
  11234. return m.OldHeadimg(ctx)
  11235. case contact.FieldSex:
  11236. return m.OldSex(ctx)
  11237. case contact.FieldStarrole:
  11238. return m.OldStarrole(ctx)
  11239. case contact.FieldDontseeit:
  11240. return m.OldDontseeit(ctx)
  11241. case contact.FieldDontseeme:
  11242. return m.OldDontseeme(ctx)
  11243. case contact.FieldLag:
  11244. return m.OldLag(ctx)
  11245. case contact.FieldGid:
  11246. return m.OldGid(ctx)
  11247. case contact.FieldGname:
  11248. return m.OldGname(ctx)
  11249. case contact.FieldV3:
  11250. return m.OldV3(ctx)
  11251. case contact.FieldOrganizationID:
  11252. return m.OldOrganizationID(ctx)
  11253. case contact.FieldCtype:
  11254. return m.OldCtype(ctx)
  11255. case contact.FieldCage:
  11256. return m.OldCage(ctx)
  11257. case contact.FieldCname:
  11258. return m.OldCname(ctx)
  11259. case contact.FieldCarea:
  11260. return m.OldCarea(ctx)
  11261. case contact.FieldCbirthday:
  11262. return m.OldCbirthday(ctx)
  11263. case contact.FieldCbirtharea:
  11264. return m.OldCbirtharea(ctx)
  11265. case contact.FieldCidcardNo:
  11266. return m.OldCidcardNo(ctx)
  11267. case contact.FieldCtitle:
  11268. return m.OldCtitle(ctx)
  11269. case contact.FieldCc:
  11270. return m.OldCc(ctx)
  11271. case contact.FieldPhone:
  11272. return m.OldPhone(ctx)
  11273. }
  11274. return nil, fmt.Errorf("unknown Contact field %s", name)
  11275. }
  11276. // SetField sets the value of a field with the given name. It returns an error if
  11277. // the field is not defined in the schema, or if the type mismatched the field
  11278. // type.
  11279. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  11280. switch name {
  11281. case contact.FieldCreatedAt:
  11282. v, ok := value.(time.Time)
  11283. if !ok {
  11284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11285. }
  11286. m.SetCreatedAt(v)
  11287. return nil
  11288. case contact.FieldUpdatedAt:
  11289. v, ok := value.(time.Time)
  11290. if !ok {
  11291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11292. }
  11293. m.SetUpdatedAt(v)
  11294. return nil
  11295. case contact.FieldStatus:
  11296. v, ok := value.(uint8)
  11297. if !ok {
  11298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11299. }
  11300. m.SetStatus(v)
  11301. return nil
  11302. case contact.FieldDeletedAt:
  11303. v, ok := value.(time.Time)
  11304. if !ok {
  11305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11306. }
  11307. m.SetDeletedAt(v)
  11308. return nil
  11309. case contact.FieldWxWxid:
  11310. v, ok := value.(string)
  11311. if !ok {
  11312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11313. }
  11314. m.SetWxWxid(v)
  11315. return nil
  11316. case contact.FieldType:
  11317. v, ok := value.(int)
  11318. if !ok {
  11319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11320. }
  11321. m.SetType(v)
  11322. return nil
  11323. case contact.FieldWxid:
  11324. v, ok := value.(string)
  11325. if !ok {
  11326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11327. }
  11328. m.SetWxid(v)
  11329. return nil
  11330. case contact.FieldAccount:
  11331. v, ok := value.(string)
  11332. if !ok {
  11333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11334. }
  11335. m.SetAccount(v)
  11336. return nil
  11337. case contact.FieldNickname:
  11338. v, ok := value.(string)
  11339. if !ok {
  11340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11341. }
  11342. m.SetNickname(v)
  11343. return nil
  11344. case contact.FieldMarkname:
  11345. v, ok := value.(string)
  11346. if !ok {
  11347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11348. }
  11349. m.SetMarkname(v)
  11350. return nil
  11351. case contact.FieldHeadimg:
  11352. v, ok := value.(string)
  11353. if !ok {
  11354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11355. }
  11356. m.SetHeadimg(v)
  11357. return nil
  11358. case contact.FieldSex:
  11359. v, ok := value.(int)
  11360. if !ok {
  11361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11362. }
  11363. m.SetSex(v)
  11364. return nil
  11365. case contact.FieldStarrole:
  11366. v, ok := value.(string)
  11367. if !ok {
  11368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11369. }
  11370. m.SetStarrole(v)
  11371. return nil
  11372. case contact.FieldDontseeit:
  11373. v, ok := value.(int)
  11374. if !ok {
  11375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11376. }
  11377. m.SetDontseeit(v)
  11378. return nil
  11379. case contact.FieldDontseeme:
  11380. v, ok := value.(int)
  11381. if !ok {
  11382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11383. }
  11384. m.SetDontseeme(v)
  11385. return nil
  11386. case contact.FieldLag:
  11387. v, ok := value.(string)
  11388. if !ok {
  11389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11390. }
  11391. m.SetLag(v)
  11392. return nil
  11393. case contact.FieldGid:
  11394. v, ok := value.(string)
  11395. if !ok {
  11396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11397. }
  11398. m.SetGid(v)
  11399. return nil
  11400. case contact.FieldGname:
  11401. v, ok := value.(string)
  11402. if !ok {
  11403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11404. }
  11405. m.SetGname(v)
  11406. return nil
  11407. case contact.FieldV3:
  11408. v, ok := value.(string)
  11409. if !ok {
  11410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11411. }
  11412. m.SetV3(v)
  11413. return nil
  11414. case contact.FieldOrganizationID:
  11415. v, ok := value.(uint64)
  11416. if !ok {
  11417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11418. }
  11419. m.SetOrganizationID(v)
  11420. return nil
  11421. case contact.FieldCtype:
  11422. v, ok := value.(uint64)
  11423. if !ok {
  11424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11425. }
  11426. m.SetCtype(v)
  11427. return nil
  11428. case contact.FieldCage:
  11429. v, ok := value.(int)
  11430. if !ok {
  11431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11432. }
  11433. m.SetCage(v)
  11434. return nil
  11435. case contact.FieldCname:
  11436. v, ok := value.(string)
  11437. if !ok {
  11438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11439. }
  11440. m.SetCname(v)
  11441. return nil
  11442. case contact.FieldCarea:
  11443. v, ok := value.(string)
  11444. if !ok {
  11445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11446. }
  11447. m.SetCarea(v)
  11448. return nil
  11449. case contact.FieldCbirthday:
  11450. v, ok := value.(string)
  11451. if !ok {
  11452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11453. }
  11454. m.SetCbirthday(v)
  11455. return nil
  11456. case contact.FieldCbirtharea:
  11457. v, ok := value.(string)
  11458. if !ok {
  11459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11460. }
  11461. m.SetCbirtharea(v)
  11462. return nil
  11463. case contact.FieldCidcardNo:
  11464. v, ok := value.(string)
  11465. if !ok {
  11466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11467. }
  11468. m.SetCidcardNo(v)
  11469. return nil
  11470. case contact.FieldCtitle:
  11471. v, ok := value.(string)
  11472. if !ok {
  11473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11474. }
  11475. m.SetCtitle(v)
  11476. return nil
  11477. case contact.FieldCc:
  11478. v, ok := value.(string)
  11479. if !ok {
  11480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11481. }
  11482. m.SetCc(v)
  11483. return nil
  11484. case contact.FieldPhone:
  11485. v, ok := value.(string)
  11486. if !ok {
  11487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11488. }
  11489. m.SetPhone(v)
  11490. return nil
  11491. }
  11492. return fmt.Errorf("unknown Contact field %s", name)
  11493. }
  11494. // AddedFields returns all numeric fields that were incremented/decremented during
  11495. // this mutation.
  11496. func (m *ContactMutation) AddedFields() []string {
  11497. var fields []string
  11498. if m.addstatus != nil {
  11499. fields = append(fields, contact.FieldStatus)
  11500. }
  11501. if m.add_type != nil {
  11502. fields = append(fields, contact.FieldType)
  11503. }
  11504. if m.addsex != nil {
  11505. fields = append(fields, contact.FieldSex)
  11506. }
  11507. if m.adddontseeit != nil {
  11508. fields = append(fields, contact.FieldDontseeit)
  11509. }
  11510. if m.adddontseeme != nil {
  11511. fields = append(fields, contact.FieldDontseeme)
  11512. }
  11513. if m.addorganization_id != nil {
  11514. fields = append(fields, contact.FieldOrganizationID)
  11515. }
  11516. if m.addctype != nil {
  11517. fields = append(fields, contact.FieldCtype)
  11518. }
  11519. if m.addcage != nil {
  11520. fields = append(fields, contact.FieldCage)
  11521. }
  11522. return fields
  11523. }
  11524. // AddedField returns the numeric value that was incremented/decremented on a field
  11525. // with the given name. The second boolean return value indicates that this field
  11526. // was not set, or was not defined in the schema.
  11527. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11528. switch name {
  11529. case contact.FieldStatus:
  11530. return m.AddedStatus()
  11531. case contact.FieldType:
  11532. return m.AddedType()
  11533. case contact.FieldSex:
  11534. return m.AddedSex()
  11535. case contact.FieldDontseeit:
  11536. return m.AddedDontseeit()
  11537. case contact.FieldDontseeme:
  11538. return m.AddedDontseeme()
  11539. case contact.FieldOrganizationID:
  11540. return m.AddedOrganizationID()
  11541. case contact.FieldCtype:
  11542. return m.AddedCtype()
  11543. case contact.FieldCage:
  11544. return m.AddedCage()
  11545. }
  11546. return nil, false
  11547. }
  11548. // AddField adds the value to the field with the given name. It returns an error if
  11549. // the field is not defined in the schema, or if the type mismatched the field
  11550. // type.
  11551. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11552. switch name {
  11553. case contact.FieldStatus:
  11554. v, ok := value.(int8)
  11555. if !ok {
  11556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11557. }
  11558. m.AddStatus(v)
  11559. return nil
  11560. case contact.FieldType:
  11561. v, ok := value.(int)
  11562. if !ok {
  11563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11564. }
  11565. m.AddType(v)
  11566. return nil
  11567. case contact.FieldSex:
  11568. v, ok := value.(int)
  11569. if !ok {
  11570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11571. }
  11572. m.AddSex(v)
  11573. return nil
  11574. case contact.FieldDontseeit:
  11575. v, ok := value.(int)
  11576. if !ok {
  11577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11578. }
  11579. m.AddDontseeit(v)
  11580. return nil
  11581. case contact.FieldDontseeme:
  11582. v, ok := value.(int)
  11583. if !ok {
  11584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11585. }
  11586. m.AddDontseeme(v)
  11587. return nil
  11588. case contact.FieldOrganizationID:
  11589. v, ok := value.(int64)
  11590. if !ok {
  11591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11592. }
  11593. m.AddOrganizationID(v)
  11594. return nil
  11595. case contact.FieldCtype:
  11596. v, ok := value.(int64)
  11597. if !ok {
  11598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11599. }
  11600. m.AddCtype(v)
  11601. return nil
  11602. case contact.FieldCage:
  11603. v, ok := value.(int)
  11604. if !ok {
  11605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11606. }
  11607. m.AddCage(v)
  11608. return nil
  11609. }
  11610. return fmt.Errorf("unknown Contact numeric field %s", name)
  11611. }
  11612. // ClearedFields returns all nullable fields that were cleared during this
  11613. // mutation.
  11614. func (m *ContactMutation) ClearedFields() []string {
  11615. var fields []string
  11616. if m.FieldCleared(contact.FieldStatus) {
  11617. fields = append(fields, contact.FieldStatus)
  11618. }
  11619. if m.FieldCleared(contact.FieldDeletedAt) {
  11620. fields = append(fields, contact.FieldDeletedAt)
  11621. }
  11622. if m.FieldCleared(contact.FieldType) {
  11623. fields = append(fields, contact.FieldType)
  11624. }
  11625. if m.FieldCleared(contact.FieldOrganizationID) {
  11626. fields = append(fields, contact.FieldOrganizationID)
  11627. }
  11628. return fields
  11629. }
  11630. // FieldCleared returns a boolean indicating if a field with the given name was
  11631. // cleared in this mutation.
  11632. func (m *ContactMutation) FieldCleared(name string) bool {
  11633. _, ok := m.clearedFields[name]
  11634. return ok
  11635. }
  11636. // ClearField clears the value of the field with the given name. It returns an
  11637. // error if the field is not defined in the schema.
  11638. func (m *ContactMutation) ClearField(name string) error {
  11639. switch name {
  11640. case contact.FieldStatus:
  11641. m.ClearStatus()
  11642. return nil
  11643. case contact.FieldDeletedAt:
  11644. m.ClearDeletedAt()
  11645. return nil
  11646. case contact.FieldType:
  11647. m.ClearType()
  11648. return nil
  11649. case contact.FieldOrganizationID:
  11650. m.ClearOrganizationID()
  11651. return nil
  11652. }
  11653. return fmt.Errorf("unknown Contact nullable field %s", name)
  11654. }
  11655. // ResetField resets all changes in the mutation for the field with the given name.
  11656. // It returns an error if the field is not defined in the schema.
  11657. func (m *ContactMutation) ResetField(name string) error {
  11658. switch name {
  11659. case contact.FieldCreatedAt:
  11660. m.ResetCreatedAt()
  11661. return nil
  11662. case contact.FieldUpdatedAt:
  11663. m.ResetUpdatedAt()
  11664. return nil
  11665. case contact.FieldStatus:
  11666. m.ResetStatus()
  11667. return nil
  11668. case contact.FieldDeletedAt:
  11669. m.ResetDeletedAt()
  11670. return nil
  11671. case contact.FieldWxWxid:
  11672. m.ResetWxWxid()
  11673. return nil
  11674. case contact.FieldType:
  11675. m.ResetType()
  11676. return nil
  11677. case contact.FieldWxid:
  11678. m.ResetWxid()
  11679. return nil
  11680. case contact.FieldAccount:
  11681. m.ResetAccount()
  11682. return nil
  11683. case contact.FieldNickname:
  11684. m.ResetNickname()
  11685. return nil
  11686. case contact.FieldMarkname:
  11687. m.ResetMarkname()
  11688. return nil
  11689. case contact.FieldHeadimg:
  11690. m.ResetHeadimg()
  11691. return nil
  11692. case contact.FieldSex:
  11693. m.ResetSex()
  11694. return nil
  11695. case contact.FieldStarrole:
  11696. m.ResetStarrole()
  11697. return nil
  11698. case contact.FieldDontseeit:
  11699. m.ResetDontseeit()
  11700. return nil
  11701. case contact.FieldDontseeme:
  11702. m.ResetDontseeme()
  11703. return nil
  11704. case contact.FieldLag:
  11705. m.ResetLag()
  11706. return nil
  11707. case contact.FieldGid:
  11708. m.ResetGid()
  11709. return nil
  11710. case contact.FieldGname:
  11711. m.ResetGname()
  11712. return nil
  11713. case contact.FieldV3:
  11714. m.ResetV3()
  11715. return nil
  11716. case contact.FieldOrganizationID:
  11717. m.ResetOrganizationID()
  11718. return nil
  11719. case contact.FieldCtype:
  11720. m.ResetCtype()
  11721. return nil
  11722. case contact.FieldCage:
  11723. m.ResetCage()
  11724. return nil
  11725. case contact.FieldCname:
  11726. m.ResetCname()
  11727. return nil
  11728. case contact.FieldCarea:
  11729. m.ResetCarea()
  11730. return nil
  11731. case contact.FieldCbirthday:
  11732. m.ResetCbirthday()
  11733. return nil
  11734. case contact.FieldCbirtharea:
  11735. m.ResetCbirtharea()
  11736. return nil
  11737. case contact.FieldCidcardNo:
  11738. m.ResetCidcardNo()
  11739. return nil
  11740. case contact.FieldCtitle:
  11741. m.ResetCtitle()
  11742. return nil
  11743. case contact.FieldCc:
  11744. m.ResetCc()
  11745. return nil
  11746. case contact.FieldPhone:
  11747. m.ResetPhone()
  11748. return nil
  11749. }
  11750. return fmt.Errorf("unknown Contact field %s", name)
  11751. }
  11752. // AddedEdges returns all edge names that were set/added in this mutation.
  11753. func (m *ContactMutation) AddedEdges() []string {
  11754. edges := make([]string, 0, 3)
  11755. if m.contact_relationships != nil {
  11756. edges = append(edges, contact.EdgeContactRelationships)
  11757. }
  11758. if m.contact_fields != nil {
  11759. edges = append(edges, contact.EdgeContactFields)
  11760. }
  11761. if m.contact_messages != nil {
  11762. edges = append(edges, contact.EdgeContactMessages)
  11763. }
  11764. return edges
  11765. }
  11766. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11767. // name in this mutation.
  11768. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11769. switch name {
  11770. case contact.EdgeContactRelationships:
  11771. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11772. for id := range m.contact_relationships {
  11773. ids = append(ids, id)
  11774. }
  11775. return ids
  11776. case contact.EdgeContactFields:
  11777. ids := make([]ent.Value, 0, len(m.contact_fields))
  11778. for id := range m.contact_fields {
  11779. ids = append(ids, id)
  11780. }
  11781. return ids
  11782. case contact.EdgeContactMessages:
  11783. ids := make([]ent.Value, 0, len(m.contact_messages))
  11784. for id := range m.contact_messages {
  11785. ids = append(ids, id)
  11786. }
  11787. return ids
  11788. }
  11789. return nil
  11790. }
  11791. // RemovedEdges returns all edge names that were removed in this mutation.
  11792. func (m *ContactMutation) RemovedEdges() []string {
  11793. edges := make([]string, 0, 3)
  11794. if m.removedcontact_relationships != nil {
  11795. edges = append(edges, contact.EdgeContactRelationships)
  11796. }
  11797. if m.removedcontact_fields != nil {
  11798. edges = append(edges, contact.EdgeContactFields)
  11799. }
  11800. if m.removedcontact_messages != nil {
  11801. edges = append(edges, contact.EdgeContactMessages)
  11802. }
  11803. return edges
  11804. }
  11805. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11806. // the given name in this mutation.
  11807. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11808. switch name {
  11809. case contact.EdgeContactRelationships:
  11810. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11811. for id := range m.removedcontact_relationships {
  11812. ids = append(ids, id)
  11813. }
  11814. return ids
  11815. case contact.EdgeContactFields:
  11816. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  11817. for id := range m.removedcontact_fields {
  11818. ids = append(ids, id)
  11819. }
  11820. return ids
  11821. case contact.EdgeContactMessages:
  11822. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11823. for id := range m.removedcontact_messages {
  11824. ids = append(ids, id)
  11825. }
  11826. return ids
  11827. }
  11828. return nil
  11829. }
  11830. // ClearedEdges returns all edge names that were cleared in this mutation.
  11831. func (m *ContactMutation) ClearedEdges() []string {
  11832. edges := make([]string, 0, 3)
  11833. if m.clearedcontact_relationships {
  11834. edges = append(edges, contact.EdgeContactRelationships)
  11835. }
  11836. if m.clearedcontact_fields {
  11837. edges = append(edges, contact.EdgeContactFields)
  11838. }
  11839. if m.clearedcontact_messages {
  11840. edges = append(edges, contact.EdgeContactMessages)
  11841. }
  11842. return edges
  11843. }
  11844. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11845. // was cleared in this mutation.
  11846. func (m *ContactMutation) EdgeCleared(name string) bool {
  11847. switch name {
  11848. case contact.EdgeContactRelationships:
  11849. return m.clearedcontact_relationships
  11850. case contact.EdgeContactFields:
  11851. return m.clearedcontact_fields
  11852. case contact.EdgeContactMessages:
  11853. return m.clearedcontact_messages
  11854. }
  11855. return false
  11856. }
  11857. // ClearEdge clears the value of the edge with the given name. It returns an error
  11858. // if that edge is not defined in the schema.
  11859. func (m *ContactMutation) ClearEdge(name string) error {
  11860. switch name {
  11861. }
  11862. return fmt.Errorf("unknown Contact unique edge %s", name)
  11863. }
  11864. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11865. // It returns an error if the edge is not defined in the schema.
  11866. func (m *ContactMutation) ResetEdge(name string) error {
  11867. switch name {
  11868. case contact.EdgeContactRelationships:
  11869. m.ResetContactRelationships()
  11870. return nil
  11871. case contact.EdgeContactFields:
  11872. m.ResetContactFields()
  11873. return nil
  11874. case contact.EdgeContactMessages:
  11875. m.ResetContactMessages()
  11876. return nil
  11877. }
  11878. return fmt.Errorf("unknown Contact edge %s", name)
  11879. }
  11880. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  11881. type ContactFieldMutation struct {
  11882. config
  11883. op Op
  11884. typ string
  11885. id *uint64
  11886. created_at *time.Time
  11887. updated_at *time.Time
  11888. status *uint8
  11889. addstatus *int8
  11890. deleted_at *time.Time
  11891. form_id *string
  11892. value *[]string
  11893. appendvalue []string
  11894. clearedFields map[string]struct{}
  11895. field_contact *uint64
  11896. clearedfield_contact bool
  11897. done bool
  11898. oldValue func(context.Context) (*ContactField, error)
  11899. predicates []predicate.ContactField
  11900. }
  11901. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  11902. // contactfieldOption allows management of the mutation configuration using functional options.
  11903. type contactfieldOption func(*ContactFieldMutation)
  11904. // newContactFieldMutation creates new mutation for the ContactField entity.
  11905. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  11906. m := &ContactFieldMutation{
  11907. config: c,
  11908. op: op,
  11909. typ: TypeContactField,
  11910. clearedFields: make(map[string]struct{}),
  11911. }
  11912. for _, opt := range opts {
  11913. opt(m)
  11914. }
  11915. return m
  11916. }
  11917. // withContactFieldID sets the ID field of the mutation.
  11918. func withContactFieldID(id uint64) contactfieldOption {
  11919. return func(m *ContactFieldMutation) {
  11920. var (
  11921. err error
  11922. once sync.Once
  11923. value *ContactField
  11924. )
  11925. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  11926. once.Do(func() {
  11927. if m.done {
  11928. err = errors.New("querying old values post mutation is not allowed")
  11929. } else {
  11930. value, err = m.Client().ContactField.Get(ctx, id)
  11931. }
  11932. })
  11933. return value, err
  11934. }
  11935. m.id = &id
  11936. }
  11937. }
  11938. // withContactField sets the old ContactField of the mutation.
  11939. func withContactField(node *ContactField) contactfieldOption {
  11940. return func(m *ContactFieldMutation) {
  11941. m.oldValue = func(context.Context) (*ContactField, error) {
  11942. return node, nil
  11943. }
  11944. m.id = &node.ID
  11945. }
  11946. }
  11947. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11948. // executed in a transaction (ent.Tx), a transactional client is returned.
  11949. func (m ContactFieldMutation) Client() *Client {
  11950. client := &Client{config: m.config}
  11951. client.init()
  11952. return client
  11953. }
  11954. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11955. // it returns an error otherwise.
  11956. func (m ContactFieldMutation) Tx() (*Tx, error) {
  11957. if _, ok := m.driver.(*txDriver); !ok {
  11958. return nil, errors.New("ent: mutation is not running in a transaction")
  11959. }
  11960. tx := &Tx{config: m.config}
  11961. tx.init()
  11962. return tx, nil
  11963. }
  11964. // SetID sets the value of the id field. Note that this
  11965. // operation is only accepted on creation of ContactField entities.
  11966. func (m *ContactFieldMutation) SetID(id uint64) {
  11967. m.id = &id
  11968. }
  11969. // ID returns the ID value in the mutation. Note that the ID is only available
  11970. // if it was provided to the builder or after it was returned from the database.
  11971. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  11972. if m.id == nil {
  11973. return
  11974. }
  11975. return *m.id, true
  11976. }
  11977. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11978. // That means, if the mutation is applied within a transaction with an isolation level such
  11979. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11980. // or updated by the mutation.
  11981. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  11982. switch {
  11983. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11984. id, exists := m.ID()
  11985. if exists {
  11986. return []uint64{id}, nil
  11987. }
  11988. fallthrough
  11989. case m.op.Is(OpUpdate | OpDelete):
  11990. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  11991. default:
  11992. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11993. }
  11994. }
  11995. // SetCreatedAt sets the "created_at" field.
  11996. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  11997. m.created_at = &t
  11998. }
  11999. // CreatedAt returns the value of the "created_at" field in the mutation.
  12000. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  12001. v := m.created_at
  12002. if v == nil {
  12003. return
  12004. }
  12005. return *v, true
  12006. }
  12007. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  12008. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12010. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12011. if !m.op.Is(OpUpdateOne) {
  12012. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12013. }
  12014. if m.id == nil || m.oldValue == nil {
  12015. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12016. }
  12017. oldValue, err := m.oldValue(ctx)
  12018. if err != nil {
  12019. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12020. }
  12021. return oldValue.CreatedAt, nil
  12022. }
  12023. // ResetCreatedAt resets all changes to the "created_at" field.
  12024. func (m *ContactFieldMutation) ResetCreatedAt() {
  12025. m.created_at = nil
  12026. }
  12027. // SetUpdatedAt sets the "updated_at" field.
  12028. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  12029. m.updated_at = &t
  12030. }
  12031. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12032. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  12033. v := m.updated_at
  12034. if v == nil {
  12035. return
  12036. }
  12037. return *v, true
  12038. }
  12039. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  12040. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12042. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12043. if !m.op.Is(OpUpdateOne) {
  12044. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12045. }
  12046. if m.id == nil || m.oldValue == nil {
  12047. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12048. }
  12049. oldValue, err := m.oldValue(ctx)
  12050. if err != nil {
  12051. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12052. }
  12053. return oldValue.UpdatedAt, nil
  12054. }
  12055. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12056. func (m *ContactFieldMutation) ResetUpdatedAt() {
  12057. m.updated_at = nil
  12058. }
  12059. // SetStatus sets the "status" field.
  12060. func (m *ContactFieldMutation) SetStatus(u uint8) {
  12061. m.status = &u
  12062. m.addstatus = nil
  12063. }
  12064. // Status returns the value of the "status" field in the mutation.
  12065. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  12066. v := m.status
  12067. if v == nil {
  12068. return
  12069. }
  12070. return *v, true
  12071. }
  12072. // OldStatus returns the old "status" field's value of the ContactField entity.
  12073. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12075. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12076. if !m.op.Is(OpUpdateOne) {
  12077. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12078. }
  12079. if m.id == nil || m.oldValue == nil {
  12080. return v, errors.New("OldStatus requires an ID field in the mutation")
  12081. }
  12082. oldValue, err := m.oldValue(ctx)
  12083. if err != nil {
  12084. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12085. }
  12086. return oldValue.Status, nil
  12087. }
  12088. // AddStatus adds u to the "status" field.
  12089. func (m *ContactFieldMutation) AddStatus(u int8) {
  12090. if m.addstatus != nil {
  12091. *m.addstatus += u
  12092. } else {
  12093. m.addstatus = &u
  12094. }
  12095. }
  12096. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12097. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  12098. v := m.addstatus
  12099. if v == nil {
  12100. return
  12101. }
  12102. return *v, true
  12103. }
  12104. // ClearStatus clears the value of the "status" field.
  12105. func (m *ContactFieldMutation) ClearStatus() {
  12106. m.status = nil
  12107. m.addstatus = nil
  12108. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  12109. }
  12110. // StatusCleared returns if the "status" field was cleared in this mutation.
  12111. func (m *ContactFieldMutation) StatusCleared() bool {
  12112. _, ok := m.clearedFields[contactfield.FieldStatus]
  12113. return ok
  12114. }
  12115. // ResetStatus resets all changes to the "status" field.
  12116. func (m *ContactFieldMutation) ResetStatus() {
  12117. m.status = nil
  12118. m.addstatus = nil
  12119. delete(m.clearedFields, contactfield.FieldStatus)
  12120. }
  12121. // SetDeletedAt sets the "deleted_at" field.
  12122. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  12123. m.deleted_at = &t
  12124. }
  12125. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12126. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  12127. v := m.deleted_at
  12128. if v == nil {
  12129. return
  12130. }
  12131. return *v, true
  12132. }
  12133. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  12134. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12136. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12137. if !m.op.Is(OpUpdateOne) {
  12138. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12139. }
  12140. if m.id == nil || m.oldValue == nil {
  12141. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12142. }
  12143. oldValue, err := m.oldValue(ctx)
  12144. if err != nil {
  12145. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12146. }
  12147. return oldValue.DeletedAt, nil
  12148. }
  12149. // ClearDeletedAt clears the value of the "deleted_at" field.
  12150. func (m *ContactFieldMutation) ClearDeletedAt() {
  12151. m.deleted_at = nil
  12152. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  12153. }
  12154. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12155. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  12156. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  12157. return ok
  12158. }
  12159. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12160. func (m *ContactFieldMutation) ResetDeletedAt() {
  12161. m.deleted_at = nil
  12162. delete(m.clearedFields, contactfield.FieldDeletedAt)
  12163. }
  12164. // SetContactID sets the "contact_id" field.
  12165. func (m *ContactFieldMutation) SetContactID(u uint64) {
  12166. m.field_contact = &u
  12167. }
  12168. // ContactID returns the value of the "contact_id" field in the mutation.
  12169. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  12170. v := m.field_contact
  12171. if v == nil {
  12172. return
  12173. }
  12174. return *v, true
  12175. }
  12176. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  12177. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12179. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12180. if !m.op.Is(OpUpdateOne) {
  12181. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12182. }
  12183. if m.id == nil || m.oldValue == nil {
  12184. return v, errors.New("OldContactID requires an ID field in the mutation")
  12185. }
  12186. oldValue, err := m.oldValue(ctx)
  12187. if err != nil {
  12188. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12189. }
  12190. return oldValue.ContactID, nil
  12191. }
  12192. // ResetContactID resets all changes to the "contact_id" field.
  12193. func (m *ContactFieldMutation) ResetContactID() {
  12194. m.field_contact = nil
  12195. }
  12196. // SetFormID sets the "form_id" field.
  12197. func (m *ContactFieldMutation) SetFormID(s string) {
  12198. m.form_id = &s
  12199. }
  12200. // FormID returns the value of the "form_id" field in the mutation.
  12201. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  12202. v := m.form_id
  12203. if v == nil {
  12204. return
  12205. }
  12206. return *v, true
  12207. }
  12208. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  12209. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12211. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  12212. if !m.op.Is(OpUpdateOne) {
  12213. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  12214. }
  12215. if m.id == nil || m.oldValue == nil {
  12216. return v, errors.New("OldFormID requires an ID field in the mutation")
  12217. }
  12218. oldValue, err := m.oldValue(ctx)
  12219. if err != nil {
  12220. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  12221. }
  12222. return oldValue.FormID, nil
  12223. }
  12224. // ResetFormID resets all changes to the "form_id" field.
  12225. func (m *ContactFieldMutation) ResetFormID() {
  12226. m.form_id = nil
  12227. }
  12228. // SetValue sets the "value" field.
  12229. func (m *ContactFieldMutation) SetValue(s []string) {
  12230. m.value = &s
  12231. m.appendvalue = nil
  12232. }
  12233. // Value returns the value of the "value" field in the mutation.
  12234. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  12235. v := m.value
  12236. if v == nil {
  12237. return
  12238. }
  12239. return *v, true
  12240. }
  12241. // OldValue returns the old "value" field's value of the ContactField entity.
  12242. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12244. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  12245. if !m.op.Is(OpUpdateOne) {
  12246. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  12247. }
  12248. if m.id == nil || m.oldValue == nil {
  12249. return v, errors.New("OldValue requires an ID field in the mutation")
  12250. }
  12251. oldValue, err := m.oldValue(ctx)
  12252. if err != nil {
  12253. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  12254. }
  12255. return oldValue.Value, nil
  12256. }
  12257. // AppendValue adds s to the "value" field.
  12258. func (m *ContactFieldMutation) AppendValue(s []string) {
  12259. m.appendvalue = append(m.appendvalue, s...)
  12260. }
  12261. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  12262. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  12263. if len(m.appendvalue) == 0 {
  12264. return nil, false
  12265. }
  12266. return m.appendvalue, true
  12267. }
  12268. // ResetValue resets all changes to the "value" field.
  12269. func (m *ContactFieldMutation) ResetValue() {
  12270. m.value = nil
  12271. m.appendvalue = nil
  12272. }
  12273. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  12274. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  12275. m.field_contact = &id
  12276. }
  12277. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  12278. func (m *ContactFieldMutation) ClearFieldContact() {
  12279. m.clearedfield_contact = true
  12280. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  12281. }
  12282. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  12283. func (m *ContactFieldMutation) FieldContactCleared() bool {
  12284. return m.clearedfield_contact
  12285. }
  12286. // FieldContactID returns the "field_contact" edge ID in the mutation.
  12287. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  12288. if m.field_contact != nil {
  12289. return *m.field_contact, true
  12290. }
  12291. return
  12292. }
  12293. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  12294. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12295. // FieldContactID instead. It exists only for internal usage by the builders.
  12296. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  12297. if id := m.field_contact; id != nil {
  12298. ids = append(ids, *id)
  12299. }
  12300. return
  12301. }
  12302. // ResetFieldContact resets all changes to the "field_contact" edge.
  12303. func (m *ContactFieldMutation) ResetFieldContact() {
  12304. m.field_contact = nil
  12305. m.clearedfield_contact = false
  12306. }
  12307. // Where appends a list predicates to the ContactFieldMutation builder.
  12308. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  12309. m.predicates = append(m.predicates, ps...)
  12310. }
  12311. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  12312. // users can use type-assertion to append predicates that do not depend on any generated package.
  12313. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  12314. p := make([]predicate.ContactField, len(ps))
  12315. for i := range ps {
  12316. p[i] = ps[i]
  12317. }
  12318. m.Where(p...)
  12319. }
  12320. // Op returns the operation name.
  12321. func (m *ContactFieldMutation) Op() Op {
  12322. return m.op
  12323. }
  12324. // SetOp allows setting the mutation operation.
  12325. func (m *ContactFieldMutation) SetOp(op Op) {
  12326. m.op = op
  12327. }
  12328. // Type returns the node type of this mutation (ContactField).
  12329. func (m *ContactFieldMutation) Type() string {
  12330. return m.typ
  12331. }
  12332. // Fields returns all fields that were changed during this mutation. Note that in
  12333. // order to get all numeric fields that were incremented/decremented, call
  12334. // AddedFields().
  12335. func (m *ContactFieldMutation) Fields() []string {
  12336. fields := make([]string, 0, 7)
  12337. if m.created_at != nil {
  12338. fields = append(fields, contactfield.FieldCreatedAt)
  12339. }
  12340. if m.updated_at != nil {
  12341. fields = append(fields, contactfield.FieldUpdatedAt)
  12342. }
  12343. if m.status != nil {
  12344. fields = append(fields, contactfield.FieldStatus)
  12345. }
  12346. if m.deleted_at != nil {
  12347. fields = append(fields, contactfield.FieldDeletedAt)
  12348. }
  12349. if m.field_contact != nil {
  12350. fields = append(fields, contactfield.FieldContactID)
  12351. }
  12352. if m.form_id != nil {
  12353. fields = append(fields, contactfield.FieldFormID)
  12354. }
  12355. if m.value != nil {
  12356. fields = append(fields, contactfield.FieldValue)
  12357. }
  12358. return fields
  12359. }
  12360. // Field returns the value of a field with the given name. The second boolean
  12361. // return value indicates that this field was not set, or was not defined in the
  12362. // schema.
  12363. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  12364. switch name {
  12365. case contactfield.FieldCreatedAt:
  12366. return m.CreatedAt()
  12367. case contactfield.FieldUpdatedAt:
  12368. return m.UpdatedAt()
  12369. case contactfield.FieldStatus:
  12370. return m.Status()
  12371. case contactfield.FieldDeletedAt:
  12372. return m.DeletedAt()
  12373. case contactfield.FieldContactID:
  12374. return m.ContactID()
  12375. case contactfield.FieldFormID:
  12376. return m.FormID()
  12377. case contactfield.FieldValue:
  12378. return m.Value()
  12379. }
  12380. return nil, false
  12381. }
  12382. // OldField returns the old value of the field from the database. An error is
  12383. // returned if the mutation operation is not UpdateOne, or the query to the
  12384. // database failed.
  12385. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12386. switch name {
  12387. case contactfield.FieldCreatedAt:
  12388. return m.OldCreatedAt(ctx)
  12389. case contactfield.FieldUpdatedAt:
  12390. return m.OldUpdatedAt(ctx)
  12391. case contactfield.FieldStatus:
  12392. return m.OldStatus(ctx)
  12393. case contactfield.FieldDeletedAt:
  12394. return m.OldDeletedAt(ctx)
  12395. case contactfield.FieldContactID:
  12396. return m.OldContactID(ctx)
  12397. case contactfield.FieldFormID:
  12398. return m.OldFormID(ctx)
  12399. case contactfield.FieldValue:
  12400. return m.OldValue(ctx)
  12401. }
  12402. return nil, fmt.Errorf("unknown ContactField field %s", name)
  12403. }
  12404. // SetField sets the value of a field with the given name. It returns an error if
  12405. // the field is not defined in the schema, or if the type mismatched the field
  12406. // type.
  12407. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  12408. switch name {
  12409. case contactfield.FieldCreatedAt:
  12410. v, ok := value.(time.Time)
  12411. if !ok {
  12412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12413. }
  12414. m.SetCreatedAt(v)
  12415. return nil
  12416. case contactfield.FieldUpdatedAt:
  12417. v, ok := value.(time.Time)
  12418. if !ok {
  12419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12420. }
  12421. m.SetUpdatedAt(v)
  12422. return nil
  12423. case contactfield.FieldStatus:
  12424. v, ok := value.(uint8)
  12425. if !ok {
  12426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12427. }
  12428. m.SetStatus(v)
  12429. return nil
  12430. case contactfield.FieldDeletedAt:
  12431. v, ok := value.(time.Time)
  12432. if !ok {
  12433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12434. }
  12435. m.SetDeletedAt(v)
  12436. return nil
  12437. case contactfield.FieldContactID:
  12438. v, ok := value.(uint64)
  12439. if !ok {
  12440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12441. }
  12442. m.SetContactID(v)
  12443. return nil
  12444. case contactfield.FieldFormID:
  12445. v, ok := value.(string)
  12446. if !ok {
  12447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12448. }
  12449. m.SetFormID(v)
  12450. return nil
  12451. case contactfield.FieldValue:
  12452. v, ok := value.([]string)
  12453. if !ok {
  12454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12455. }
  12456. m.SetValue(v)
  12457. return nil
  12458. }
  12459. return fmt.Errorf("unknown ContactField field %s", name)
  12460. }
  12461. // AddedFields returns all numeric fields that were incremented/decremented during
  12462. // this mutation.
  12463. func (m *ContactFieldMutation) AddedFields() []string {
  12464. var fields []string
  12465. if m.addstatus != nil {
  12466. fields = append(fields, contactfield.FieldStatus)
  12467. }
  12468. return fields
  12469. }
  12470. // AddedField returns the numeric value that was incremented/decremented on a field
  12471. // with the given name. The second boolean return value indicates that this field
  12472. // was not set, or was not defined in the schema.
  12473. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  12474. switch name {
  12475. case contactfield.FieldStatus:
  12476. return m.AddedStatus()
  12477. }
  12478. return nil, false
  12479. }
  12480. // AddField adds the value to the field with the given name. It returns an error if
  12481. // the field is not defined in the schema, or if the type mismatched the field
  12482. // type.
  12483. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  12484. switch name {
  12485. case contactfield.FieldStatus:
  12486. v, ok := value.(int8)
  12487. if !ok {
  12488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12489. }
  12490. m.AddStatus(v)
  12491. return nil
  12492. }
  12493. return fmt.Errorf("unknown ContactField numeric field %s", name)
  12494. }
  12495. // ClearedFields returns all nullable fields that were cleared during this
  12496. // mutation.
  12497. func (m *ContactFieldMutation) ClearedFields() []string {
  12498. var fields []string
  12499. if m.FieldCleared(contactfield.FieldStatus) {
  12500. fields = append(fields, contactfield.FieldStatus)
  12501. }
  12502. if m.FieldCleared(contactfield.FieldDeletedAt) {
  12503. fields = append(fields, contactfield.FieldDeletedAt)
  12504. }
  12505. return fields
  12506. }
  12507. // FieldCleared returns a boolean indicating if a field with the given name was
  12508. // cleared in this mutation.
  12509. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  12510. _, ok := m.clearedFields[name]
  12511. return ok
  12512. }
  12513. // ClearField clears the value of the field with the given name. It returns an
  12514. // error if the field is not defined in the schema.
  12515. func (m *ContactFieldMutation) ClearField(name string) error {
  12516. switch name {
  12517. case contactfield.FieldStatus:
  12518. m.ClearStatus()
  12519. return nil
  12520. case contactfield.FieldDeletedAt:
  12521. m.ClearDeletedAt()
  12522. return nil
  12523. }
  12524. return fmt.Errorf("unknown ContactField nullable field %s", name)
  12525. }
  12526. // ResetField resets all changes in the mutation for the field with the given name.
  12527. // It returns an error if the field is not defined in the schema.
  12528. func (m *ContactFieldMutation) ResetField(name string) error {
  12529. switch name {
  12530. case contactfield.FieldCreatedAt:
  12531. m.ResetCreatedAt()
  12532. return nil
  12533. case contactfield.FieldUpdatedAt:
  12534. m.ResetUpdatedAt()
  12535. return nil
  12536. case contactfield.FieldStatus:
  12537. m.ResetStatus()
  12538. return nil
  12539. case contactfield.FieldDeletedAt:
  12540. m.ResetDeletedAt()
  12541. return nil
  12542. case contactfield.FieldContactID:
  12543. m.ResetContactID()
  12544. return nil
  12545. case contactfield.FieldFormID:
  12546. m.ResetFormID()
  12547. return nil
  12548. case contactfield.FieldValue:
  12549. m.ResetValue()
  12550. return nil
  12551. }
  12552. return fmt.Errorf("unknown ContactField field %s", name)
  12553. }
  12554. // AddedEdges returns all edge names that were set/added in this mutation.
  12555. func (m *ContactFieldMutation) AddedEdges() []string {
  12556. edges := make([]string, 0, 1)
  12557. if m.field_contact != nil {
  12558. edges = append(edges, contactfield.EdgeFieldContact)
  12559. }
  12560. return edges
  12561. }
  12562. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12563. // name in this mutation.
  12564. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  12565. switch name {
  12566. case contactfield.EdgeFieldContact:
  12567. if id := m.field_contact; id != nil {
  12568. return []ent.Value{*id}
  12569. }
  12570. }
  12571. return nil
  12572. }
  12573. // RemovedEdges returns all edge names that were removed in this mutation.
  12574. func (m *ContactFieldMutation) RemovedEdges() []string {
  12575. edges := make([]string, 0, 1)
  12576. return edges
  12577. }
  12578. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12579. // the given name in this mutation.
  12580. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  12581. return nil
  12582. }
  12583. // ClearedEdges returns all edge names that were cleared in this mutation.
  12584. func (m *ContactFieldMutation) ClearedEdges() []string {
  12585. edges := make([]string, 0, 1)
  12586. if m.clearedfield_contact {
  12587. edges = append(edges, contactfield.EdgeFieldContact)
  12588. }
  12589. return edges
  12590. }
  12591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12592. // was cleared in this mutation.
  12593. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  12594. switch name {
  12595. case contactfield.EdgeFieldContact:
  12596. return m.clearedfield_contact
  12597. }
  12598. return false
  12599. }
  12600. // ClearEdge clears the value of the edge with the given name. It returns an error
  12601. // if that edge is not defined in the schema.
  12602. func (m *ContactFieldMutation) ClearEdge(name string) error {
  12603. switch name {
  12604. case contactfield.EdgeFieldContact:
  12605. m.ClearFieldContact()
  12606. return nil
  12607. }
  12608. return fmt.Errorf("unknown ContactField unique edge %s", name)
  12609. }
  12610. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12611. // It returns an error if the edge is not defined in the schema.
  12612. func (m *ContactFieldMutation) ResetEdge(name string) error {
  12613. switch name {
  12614. case contactfield.EdgeFieldContact:
  12615. m.ResetFieldContact()
  12616. return nil
  12617. }
  12618. return fmt.Errorf("unknown ContactField edge %s", name)
  12619. }
  12620. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  12621. type ContactFieldTemplateMutation struct {
  12622. config
  12623. op Op
  12624. typ string
  12625. id *uint64
  12626. created_at *time.Time
  12627. updated_at *time.Time
  12628. status *uint8
  12629. addstatus *int8
  12630. deleted_at *time.Time
  12631. organization_id *uint64
  12632. addorganization_id *int64
  12633. template *[]custom_types.ContactFieldTemplate
  12634. appendtemplate []custom_types.ContactFieldTemplate
  12635. clearedFields map[string]struct{}
  12636. done bool
  12637. oldValue func(context.Context) (*ContactFieldTemplate, error)
  12638. predicates []predicate.ContactFieldTemplate
  12639. }
  12640. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  12641. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  12642. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  12643. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  12644. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  12645. m := &ContactFieldTemplateMutation{
  12646. config: c,
  12647. op: op,
  12648. typ: TypeContactFieldTemplate,
  12649. clearedFields: make(map[string]struct{}),
  12650. }
  12651. for _, opt := range opts {
  12652. opt(m)
  12653. }
  12654. return m
  12655. }
  12656. // withContactFieldTemplateID sets the ID field of the mutation.
  12657. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  12658. return func(m *ContactFieldTemplateMutation) {
  12659. var (
  12660. err error
  12661. once sync.Once
  12662. value *ContactFieldTemplate
  12663. )
  12664. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  12665. once.Do(func() {
  12666. if m.done {
  12667. err = errors.New("querying old values post mutation is not allowed")
  12668. } else {
  12669. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  12670. }
  12671. })
  12672. return value, err
  12673. }
  12674. m.id = &id
  12675. }
  12676. }
  12677. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  12678. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  12679. return func(m *ContactFieldTemplateMutation) {
  12680. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  12681. return node, nil
  12682. }
  12683. m.id = &node.ID
  12684. }
  12685. }
  12686. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12687. // executed in a transaction (ent.Tx), a transactional client is returned.
  12688. func (m ContactFieldTemplateMutation) Client() *Client {
  12689. client := &Client{config: m.config}
  12690. client.init()
  12691. return client
  12692. }
  12693. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12694. // it returns an error otherwise.
  12695. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  12696. if _, ok := m.driver.(*txDriver); !ok {
  12697. return nil, errors.New("ent: mutation is not running in a transaction")
  12698. }
  12699. tx := &Tx{config: m.config}
  12700. tx.init()
  12701. return tx, nil
  12702. }
  12703. // SetID sets the value of the id field. Note that this
  12704. // operation is only accepted on creation of ContactFieldTemplate entities.
  12705. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  12706. m.id = &id
  12707. }
  12708. // ID returns the ID value in the mutation. Note that the ID is only available
  12709. // if it was provided to the builder or after it was returned from the database.
  12710. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  12711. if m.id == nil {
  12712. return
  12713. }
  12714. return *m.id, true
  12715. }
  12716. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12717. // That means, if the mutation is applied within a transaction with an isolation level such
  12718. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12719. // or updated by the mutation.
  12720. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  12721. switch {
  12722. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12723. id, exists := m.ID()
  12724. if exists {
  12725. return []uint64{id}, nil
  12726. }
  12727. fallthrough
  12728. case m.op.Is(OpUpdate | OpDelete):
  12729. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  12730. default:
  12731. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12732. }
  12733. }
  12734. // SetCreatedAt sets the "created_at" field.
  12735. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  12736. m.created_at = &t
  12737. }
  12738. // CreatedAt returns the value of the "created_at" field in the mutation.
  12739. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  12740. v := m.created_at
  12741. if v == nil {
  12742. return
  12743. }
  12744. return *v, true
  12745. }
  12746. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  12747. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12749. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12750. if !m.op.Is(OpUpdateOne) {
  12751. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12752. }
  12753. if m.id == nil || m.oldValue == nil {
  12754. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12755. }
  12756. oldValue, err := m.oldValue(ctx)
  12757. if err != nil {
  12758. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12759. }
  12760. return oldValue.CreatedAt, nil
  12761. }
  12762. // ResetCreatedAt resets all changes to the "created_at" field.
  12763. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  12764. m.created_at = nil
  12765. }
  12766. // SetUpdatedAt sets the "updated_at" field.
  12767. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  12768. m.updated_at = &t
  12769. }
  12770. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12771. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  12772. v := m.updated_at
  12773. if v == nil {
  12774. return
  12775. }
  12776. return *v, true
  12777. }
  12778. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  12779. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12781. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12782. if !m.op.Is(OpUpdateOne) {
  12783. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12784. }
  12785. if m.id == nil || m.oldValue == nil {
  12786. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12787. }
  12788. oldValue, err := m.oldValue(ctx)
  12789. if err != nil {
  12790. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12791. }
  12792. return oldValue.UpdatedAt, nil
  12793. }
  12794. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12795. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  12796. m.updated_at = nil
  12797. }
  12798. // SetStatus sets the "status" field.
  12799. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  12800. m.status = &u
  12801. m.addstatus = nil
  12802. }
  12803. // Status returns the value of the "status" field in the mutation.
  12804. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  12805. v := m.status
  12806. if v == nil {
  12807. return
  12808. }
  12809. return *v, true
  12810. }
  12811. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  12812. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12814. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12815. if !m.op.Is(OpUpdateOne) {
  12816. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12817. }
  12818. if m.id == nil || m.oldValue == nil {
  12819. return v, errors.New("OldStatus requires an ID field in the mutation")
  12820. }
  12821. oldValue, err := m.oldValue(ctx)
  12822. if err != nil {
  12823. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12824. }
  12825. return oldValue.Status, nil
  12826. }
  12827. // AddStatus adds u to the "status" field.
  12828. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  12829. if m.addstatus != nil {
  12830. *m.addstatus += u
  12831. } else {
  12832. m.addstatus = &u
  12833. }
  12834. }
  12835. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12836. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  12837. v := m.addstatus
  12838. if v == nil {
  12839. return
  12840. }
  12841. return *v, true
  12842. }
  12843. // ClearStatus clears the value of the "status" field.
  12844. func (m *ContactFieldTemplateMutation) ClearStatus() {
  12845. m.status = nil
  12846. m.addstatus = nil
  12847. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  12848. }
  12849. // StatusCleared returns if the "status" field was cleared in this mutation.
  12850. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  12851. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  12852. return ok
  12853. }
  12854. // ResetStatus resets all changes to the "status" field.
  12855. func (m *ContactFieldTemplateMutation) ResetStatus() {
  12856. m.status = nil
  12857. m.addstatus = nil
  12858. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  12859. }
  12860. // SetDeletedAt sets the "deleted_at" field.
  12861. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  12862. m.deleted_at = &t
  12863. }
  12864. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12865. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  12866. v := m.deleted_at
  12867. if v == nil {
  12868. return
  12869. }
  12870. return *v, true
  12871. }
  12872. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  12873. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12875. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12876. if !m.op.Is(OpUpdateOne) {
  12877. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12878. }
  12879. if m.id == nil || m.oldValue == nil {
  12880. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12881. }
  12882. oldValue, err := m.oldValue(ctx)
  12883. if err != nil {
  12884. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12885. }
  12886. return oldValue.DeletedAt, nil
  12887. }
  12888. // ClearDeletedAt clears the value of the "deleted_at" field.
  12889. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  12890. m.deleted_at = nil
  12891. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  12892. }
  12893. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12894. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  12895. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  12896. return ok
  12897. }
  12898. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12899. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  12900. m.deleted_at = nil
  12901. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  12902. }
  12903. // SetOrganizationID sets the "organization_id" field.
  12904. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  12905. m.organization_id = &u
  12906. m.addorganization_id = nil
  12907. }
  12908. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12909. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  12910. v := m.organization_id
  12911. if v == nil {
  12912. return
  12913. }
  12914. return *v, true
  12915. }
  12916. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  12917. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12919. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12920. if !m.op.Is(OpUpdateOne) {
  12921. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12922. }
  12923. if m.id == nil || m.oldValue == nil {
  12924. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12925. }
  12926. oldValue, err := m.oldValue(ctx)
  12927. if err != nil {
  12928. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12929. }
  12930. return oldValue.OrganizationID, nil
  12931. }
  12932. // AddOrganizationID adds u to the "organization_id" field.
  12933. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  12934. if m.addorganization_id != nil {
  12935. *m.addorganization_id += u
  12936. } else {
  12937. m.addorganization_id = &u
  12938. }
  12939. }
  12940. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12941. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  12942. v := m.addorganization_id
  12943. if v == nil {
  12944. return
  12945. }
  12946. return *v, true
  12947. }
  12948. // ResetOrganizationID resets all changes to the "organization_id" field.
  12949. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  12950. m.organization_id = nil
  12951. m.addorganization_id = nil
  12952. }
  12953. // SetTemplate sets the "template" field.
  12954. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  12955. m.template = &ctft
  12956. m.appendtemplate = nil
  12957. }
  12958. // Template returns the value of the "template" field in the mutation.
  12959. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  12960. v := m.template
  12961. if v == nil {
  12962. return
  12963. }
  12964. return *v, true
  12965. }
  12966. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  12967. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12969. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  12970. if !m.op.Is(OpUpdateOne) {
  12971. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  12972. }
  12973. if m.id == nil || m.oldValue == nil {
  12974. return v, errors.New("OldTemplate requires an ID field in the mutation")
  12975. }
  12976. oldValue, err := m.oldValue(ctx)
  12977. if err != nil {
  12978. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  12979. }
  12980. return oldValue.Template, nil
  12981. }
  12982. // AppendTemplate adds ctft to the "template" field.
  12983. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  12984. m.appendtemplate = append(m.appendtemplate, ctft...)
  12985. }
  12986. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  12987. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  12988. if len(m.appendtemplate) == 0 {
  12989. return nil, false
  12990. }
  12991. return m.appendtemplate, true
  12992. }
  12993. // ResetTemplate resets all changes to the "template" field.
  12994. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  12995. m.template = nil
  12996. m.appendtemplate = nil
  12997. }
  12998. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  12999. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  13000. m.predicates = append(m.predicates, ps...)
  13001. }
  13002. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  13003. // users can use type-assertion to append predicates that do not depend on any generated package.
  13004. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  13005. p := make([]predicate.ContactFieldTemplate, len(ps))
  13006. for i := range ps {
  13007. p[i] = ps[i]
  13008. }
  13009. m.Where(p...)
  13010. }
  13011. // Op returns the operation name.
  13012. func (m *ContactFieldTemplateMutation) Op() Op {
  13013. return m.op
  13014. }
  13015. // SetOp allows setting the mutation operation.
  13016. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  13017. m.op = op
  13018. }
  13019. // Type returns the node type of this mutation (ContactFieldTemplate).
  13020. func (m *ContactFieldTemplateMutation) Type() string {
  13021. return m.typ
  13022. }
  13023. // Fields returns all fields that were changed during this mutation. Note that in
  13024. // order to get all numeric fields that were incremented/decremented, call
  13025. // AddedFields().
  13026. func (m *ContactFieldTemplateMutation) Fields() []string {
  13027. fields := make([]string, 0, 6)
  13028. if m.created_at != nil {
  13029. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  13030. }
  13031. if m.updated_at != nil {
  13032. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  13033. }
  13034. if m.status != nil {
  13035. fields = append(fields, contactfieldtemplate.FieldStatus)
  13036. }
  13037. if m.deleted_at != nil {
  13038. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  13039. }
  13040. if m.organization_id != nil {
  13041. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  13042. }
  13043. if m.template != nil {
  13044. fields = append(fields, contactfieldtemplate.FieldTemplate)
  13045. }
  13046. return fields
  13047. }
  13048. // Field returns the value of a field with the given name. The second boolean
  13049. // return value indicates that this field was not set, or was not defined in the
  13050. // schema.
  13051. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  13052. switch name {
  13053. case contactfieldtemplate.FieldCreatedAt:
  13054. return m.CreatedAt()
  13055. case contactfieldtemplate.FieldUpdatedAt:
  13056. return m.UpdatedAt()
  13057. case contactfieldtemplate.FieldStatus:
  13058. return m.Status()
  13059. case contactfieldtemplate.FieldDeletedAt:
  13060. return m.DeletedAt()
  13061. case contactfieldtemplate.FieldOrganizationID:
  13062. return m.OrganizationID()
  13063. case contactfieldtemplate.FieldTemplate:
  13064. return m.Template()
  13065. }
  13066. return nil, false
  13067. }
  13068. // OldField returns the old value of the field from the database. An error is
  13069. // returned if the mutation operation is not UpdateOne, or the query to the
  13070. // database failed.
  13071. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13072. switch name {
  13073. case contactfieldtemplate.FieldCreatedAt:
  13074. return m.OldCreatedAt(ctx)
  13075. case contactfieldtemplate.FieldUpdatedAt:
  13076. return m.OldUpdatedAt(ctx)
  13077. case contactfieldtemplate.FieldStatus:
  13078. return m.OldStatus(ctx)
  13079. case contactfieldtemplate.FieldDeletedAt:
  13080. return m.OldDeletedAt(ctx)
  13081. case contactfieldtemplate.FieldOrganizationID:
  13082. return m.OldOrganizationID(ctx)
  13083. case contactfieldtemplate.FieldTemplate:
  13084. return m.OldTemplate(ctx)
  13085. }
  13086. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  13087. }
  13088. // SetField sets the value of a field with the given name. It returns an error if
  13089. // the field is not defined in the schema, or if the type mismatched the field
  13090. // type.
  13091. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  13092. switch name {
  13093. case contactfieldtemplate.FieldCreatedAt:
  13094. v, ok := value.(time.Time)
  13095. if !ok {
  13096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13097. }
  13098. m.SetCreatedAt(v)
  13099. return nil
  13100. case contactfieldtemplate.FieldUpdatedAt:
  13101. v, ok := value.(time.Time)
  13102. if !ok {
  13103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13104. }
  13105. m.SetUpdatedAt(v)
  13106. return nil
  13107. case contactfieldtemplate.FieldStatus:
  13108. v, ok := value.(uint8)
  13109. if !ok {
  13110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13111. }
  13112. m.SetStatus(v)
  13113. return nil
  13114. case contactfieldtemplate.FieldDeletedAt:
  13115. v, ok := value.(time.Time)
  13116. if !ok {
  13117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13118. }
  13119. m.SetDeletedAt(v)
  13120. return nil
  13121. case contactfieldtemplate.FieldOrganizationID:
  13122. v, ok := value.(uint64)
  13123. if !ok {
  13124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13125. }
  13126. m.SetOrganizationID(v)
  13127. return nil
  13128. case contactfieldtemplate.FieldTemplate:
  13129. v, ok := value.([]custom_types.ContactFieldTemplate)
  13130. if !ok {
  13131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13132. }
  13133. m.SetTemplate(v)
  13134. return nil
  13135. }
  13136. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  13137. }
  13138. // AddedFields returns all numeric fields that were incremented/decremented during
  13139. // this mutation.
  13140. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  13141. var fields []string
  13142. if m.addstatus != nil {
  13143. fields = append(fields, contactfieldtemplate.FieldStatus)
  13144. }
  13145. if m.addorganization_id != nil {
  13146. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  13147. }
  13148. return fields
  13149. }
  13150. // AddedField returns the numeric value that was incremented/decremented on a field
  13151. // with the given name. The second boolean return value indicates that this field
  13152. // was not set, or was not defined in the schema.
  13153. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  13154. switch name {
  13155. case contactfieldtemplate.FieldStatus:
  13156. return m.AddedStatus()
  13157. case contactfieldtemplate.FieldOrganizationID:
  13158. return m.AddedOrganizationID()
  13159. }
  13160. return nil, false
  13161. }
  13162. // AddField adds the value to the field with the given name. It returns an error if
  13163. // the field is not defined in the schema, or if the type mismatched the field
  13164. // type.
  13165. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  13166. switch name {
  13167. case contactfieldtemplate.FieldStatus:
  13168. v, ok := value.(int8)
  13169. if !ok {
  13170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13171. }
  13172. m.AddStatus(v)
  13173. return nil
  13174. case contactfieldtemplate.FieldOrganizationID:
  13175. v, ok := value.(int64)
  13176. if !ok {
  13177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13178. }
  13179. m.AddOrganizationID(v)
  13180. return nil
  13181. }
  13182. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  13183. }
  13184. // ClearedFields returns all nullable fields that were cleared during this
  13185. // mutation.
  13186. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  13187. var fields []string
  13188. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  13189. fields = append(fields, contactfieldtemplate.FieldStatus)
  13190. }
  13191. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  13192. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  13193. }
  13194. return fields
  13195. }
  13196. // FieldCleared returns a boolean indicating if a field with the given name was
  13197. // cleared in this mutation.
  13198. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  13199. _, ok := m.clearedFields[name]
  13200. return ok
  13201. }
  13202. // ClearField clears the value of the field with the given name. It returns an
  13203. // error if the field is not defined in the schema.
  13204. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  13205. switch name {
  13206. case contactfieldtemplate.FieldStatus:
  13207. m.ClearStatus()
  13208. return nil
  13209. case contactfieldtemplate.FieldDeletedAt:
  13210. m.ClearDeletedAt()
  13211. return nil
  13212. }
  13213. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  13214. }
  13215. // ResetField resets all changes in the mutation for the field with the given name.
  13216. // It returns an error if the field is not defined in the schema.
  13217. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  13218. switch name {
  13219. case contactfieldtemplate.FieldCreatedAt:
  13220. m.ResetCreatedAt()
  13221. return nil
  13222. case contactfieldtemplate.FieldUpdatedAt:
  13223. m.ResetUpdatedAt()
  13224. return nil
  13225. case contactfieldtemplate.FieldStatus:
  13226. m.ResetStatus()
  13227. return nil
  13228. case contactfieldtemplate.FieldDeletedAt:
  13229. m.ResetDeletedAt()
  13230. return nil
  13231. case contactfieldtemplate.FieldOrganizationID:
  13232. m.ResetOrganizationID()
  13233. return nil
  13234. case contactfieldtemplate.FieldTemplate:
  13235. m.ResetTemplate()
  13236. return nil
  13237. }
  13238. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  13239. }
  13240. // AddedEdges returns all edge names that were set/added in this mutation.
  13241. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  13242. edges := make([]string, 0, 0)
  13243. return edges
  13244. }
  13245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13246. // name in this mutation.
  13247. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  13248. return nil
  13249. }
  13250. // RemovedEdges returns all edge names that were removed in this mutation.
  13251. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  13252. edges := make([]string, 0, 0)
  13253. return edges
  13254. }
  13255. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13256. // the given name in this mutation.
  13257. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  13258. return nil
  13259. }
  13260. // ClearedEdges returns all edge names that were cleared in this mutation.
  13261. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  13262. edges := make([]string, 0, 0)
  13263. return edges
  13264. }
  13265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13266. // was cleared in this mutation.
  13267. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  13268. return false
  13269. }
  13270. // ClearEdge clears the value of the edge with the given name. It returns an error
  13271. // if that edge is not defined in the schema.
  13272. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  13273. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  13274. }
  13275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13276. // It returns an error if the edge is not defined in the schema.
  13277. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  13278. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  13279. }
  13280. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  13281. type CreditBalanceMutation struct {
  13282. config
  13283. op Op
  13284. typ string
  13285. id *uint64
  13286. created_at *time.Time
  13287. updated_at *time.Time
  13288. deleted_at *time.Time
  13289. user_id *string
  13290. balance *float64
  13291. addbalance *float64
  13292. status *int
  13293. addstatus *int
  13294. organization_id *uint64
  13295. addorganization_id *int64
  13296. clearedFields map[string]struct{}
  13297. done bool
  13298. oldValue func(context.Context) (*CreditBalance, error)
  13299. predicates []predicate.CreditBalance
  13300. }
  13301. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  13302. // creditbalanceOption allows management of the mutation configuration using functional options.
  13303. type creditbalanceOption func(*CreditBalanceMutation)
  13304. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  13305. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  13306. m := &CreditBalanceMutation{
  13307. config: c,
  13308. op: op,
  13309. typ: TypeCreditBalance,
  13310. clearedFields: make(map[string]struct{}),
  13311. }
  13312. for _, opt := range opts {
  13313. opt(m)
  13314. }
  13315. return m
  13316. }
  13317. // withCreditBalanceID sets the ID field of the mutation.
  13318. func withCreditBalanceID(id uint64) creditbalanceOption {
  13319. return func(m *CreditBalanceMutation) {
  13320. var (
  13321. err error
  13322. once sync.Once
  13323. value *CreditBalance
  13324. )
  13325. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  13326. once.Do(func() {
  13327. if m.done {
  13328. err = errors.New("querying old values post mutation is not allowed")
  13329. } else {
  13330. value, err = m.Client().CreditBalance.Get(ctx, id)
  13331. }
  13332. })
  13333. return value, err
  13334. }
  13335. m.id = &id
  13336. }
  13337. }
  13338. // withCreditBalance sets the old CreditBalance of the mutation.
  13339. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  13340. return func(m *CreditBalanceMutation) {
  13341. m.oldValue = func(context.Context) (*CreditBalance, error) {
  13342. return node, nil
  13343. }
  13344. m.id = &node.ID
  13345. }
  13346. }
  13347. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13348. // executed in a transaction (ent.Tx), a transactional client is returned.
  13349. func (m CreditBalanceMutation) Client() *Client {
  13350. client := &Client{config: m.config}
  13351. client.init()
  13352. return client
  13353. }
  13354. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13355. // it returns an error otherwise.
  13356. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  13357. if _, ok := m.driver.(*txDriver); !ok {
  13358. return nil, errors.New("ent: mutation is not running in a transaction")
  13359. }
  13360. tx := &Tx{config: m.config}
  13361. tx.init()
  13362. return tx, nil
  13363. }
  13364. // SetID sets the value of the id field. Note that this
  13365. // operation is only accepted on creation of CreditBalance entities.
  13366. func (m *CreditBalanceMutation) SetID(id uint64) {
  13367. m.id = &id
  13368. }
  13369. // ID returns the ID value in the mutation. Note that the ID is only available
  13370. // if it was provided to the builder or after it was returned from the database.
  13371. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  13372. if m.id == nil {
  13373. return
  13374. }
  13375. return *m.id, true
  13376. }
  13377. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13378. // That means, if the mutation is applied within a transaction with an isolation level such
  13379. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13380. // or updated by the mutation.
  13381. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  13382. switch {
  13383. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13384. id, exists := m.ID()
  13385. if exists {
  13386. return []uint64{id}, nil
  13387. }
  13388. fallthrough
  13389. case m.op.Is(OpUpdate | OpDelete):
  13390. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  13391. default:
  13392. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13393. }
  13394. }
  13395. // SetCreatedAt sets the "created_at" field.
  13396. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  13397. m.created_at = &t
  13398. }
  13399. // CreatedAt returns the value of the "created_at" field in the mutation.
  13400. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  13401. v := m.created_at
  13402. if v == nil {
  13403. return
  13404. }
  13405. return *v, true
  13406. }
  13407. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  13408. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13410. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13411. if !m.op.Is(OpUpdateOne) {
  13412. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13413. }
  13414. if m.id == nil || m.oldValue == nil {
  13415. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13416. }
  13417. oldValue, err := m.oldValue(ctx)
  13418. if err != nil {
  13419. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13420. }
  13421. return oldValue.CreatedAt, nil
  13422. }
  13423. // ResetCreatedAt resets all changes to the "created_at" field.
  13424. func (m *CreditBalanceMutation) ResetCreatedAt() {
  13425. m.created_at = nil
  13426. }
  13427. // SetUpdatedAt sets the "updated_at" field.
  13428. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  13429. m.updated_at = &t
  13430. }
  13431. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13432. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  13433. v := m.updated_at
  13434. if v == nil {
  13435. return
  13436. }
  13437. return *v, true
  13438. }
  13439. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  13440. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13442. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13443. if !m.op.Is(OpUpdateOne) {
  13444. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13445. }
  13446. if m.id == nil || m.oldValue == nil {
  13447. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13448. }
  13449. oldValue, err := m.oldValue(ctx)
  13450. if err != nil {
  13451. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13452. }
  13453. return oldValue.UpdatedAt, nil
  13454. }
  13455. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13456. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  13457. m.updated_at = nil
  13458. }
  13459. // SetDeletedAt sets the "deleted_at" field.
  13460. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  13461. m.deleted_at = &t
  13462. }
  13463. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13464. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  13465. v := m.deleted_at
  13466. if v == nil {
  13467. return
  13468. }
  13469. return *v, true
  13470. }
  13471. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  13472. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13474. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13475. if !m.op.Is(OpUpdateOne) {
  13476. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13477. }
  13478. if m.id == nil || m.oldValue == nil {
  13479. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13480. }
  13481. oldValue, err := m.oldValue(ctx)
  13482. if err != nil {
  13483. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13484. }
  13485. return oldValue.DeletedAt, nil
  13486. }
  13487. // ClearDeletedAt clears the value of the "deleted_at" field.
  13488. func (m *CreditBalanceMutation) ClearDeletedAt() {
  13489. m.deleted_at = nil
  13490. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  13491. }
  13492. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13493. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  13494. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  13495. return ok
  13496. }
  13497. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13498. func (m *CreditBalanceMutation) ResetDeletedAt() {
  13499. m.deleted_at = nil
  13500. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  13501. }
  13502. // SetUserID sets the "user_id" field.
  13503. func (m *CreditBalanceMutation) SetUserID(s string) {
  13504. m.user_id = &s
  13505. }
  13506. // UserID returns the value of the "user_id" field in the mutation.
  13507. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  13508. v := m.user_id
  13509. if v == nil {
  13510. return
  13511. }
  13512. return *v, true
  13513. }
  13514. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  13515. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13517. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  13518. if !m.op.Is(OpUpdateOne) {
  13519. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13520. }
  13521. if m.id == nil || m.oldValue == nil {
  13522. return v, errors.New("OldUserID requires an ID field in the mutation")
  13523. }
  13524. oldValue, err := m.oldValue(ctx)
  13525. if err != nil {
  13526. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13527. }
  13528. return oldValue.UserID, nil
  13529. }
  13530. // ClearUserID clears the value of the "user_id" field.
  13531. func (m *CreditBalanceMutation) ClearUserID() {
  13532. m.user_id = nil
  13533. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  13534. }
  13535. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13536. func (m *CreditBalanceMutation) UserIDCleared() bool {
  13537. _, ok := m.clearedFields[creditbalance.FieldUserID]
  13538. return ok
  13539. }
  13540. // ResetUserID resets all changes to the "user_id" field.
  13541. func (m *CreditBalanceMutation) ResetUserID() {
  13542. m.user_id = nil
  13543. delete(m.clearedFields, creditbalance.FieldUserID)
  13544. }
  13545. // SetBalance sets the "balance" field.
  13546. func (m *CreditBalanceMutation) SetBalance(f float64) {
  13547. m.balance = &f
  13548. m.addbalance = nil
  13549. }
  13550. // Balance returns the value of the "balance" field in the mutation.
  13551. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  13552. v := m.balance
  13553. if v == nil {
  13554. return
  13555. }
  13556. return *v, true
  13557. }
  13558. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  13559. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13561. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  13562. if !m.op.Is(OpUpdateOne) {
  13563. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  13564. }
  13565. if m.id == nil || m.oldValue == nil {
  13566. return v, errors.New("OldBalance requires an ID field in the mutation")
  13567. }
  13568. oldValue, err := m.oldValue(ctx)
  13569. if err != nil {
  13570. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  13571. }
  13572. return oldValue.Balance, nil
  13573. }
  13574. // AddBalance adds f to the "balance" field.
  13575. func (m *CreditBalanceMutation) AddBalance(f float64) {
  13576. if m.addbalance != nil {
  13577. *m.addbalance += f
  13578. } else {
  13579. m.addbalance = &f
  13580. }
  13581. }
  13582. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  13583. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  13584. v := m.addbalance
  13585. if v == nil {
  13586. return
  13587. }
  13588. return *v, true
  13589. }
  13590. // ResetBalance resets all changes to the "balance" field.
  13591. func (m *CreditBalanceMutation) ResetBalance() {
  13592. m.balance = nil
  13593. m.addbalance = nil
  13594. }
  13595. // SetStatus sets the "status" field.
  13596. func (m *CreditBalanceMutation) SetStatus(i int) {
  13597. m.status = &i
  13598. m.addstatus = nil
  13599. }
  13600. // Status returns the value of the "status" field in the mutation.
  13601. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  13602. v := m.status
  13603. if v == nil {
  13604. return
  13605. }
  13606. return *v, true
  13607. }
  13608. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  13609. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13611. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  13612. if !m.op.Is(OpUpdateOne) {
  13613. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13614. }
  13615. if m.id == nil || m.oldValue == nil {
  13616. return v, errors.New("OldStatus requires an ID field in the mutation")
  13617. }
  13618. oldValue, err := m.oldValue(ctx)
  13619. if err != nil {
  13620. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13621. }
  13622. return oldValue.Status, nil
  13623. }
  13624. // AddStatus adds i to the "status" field.
  13625. func (m *CreditBalanceMutation) AddStatus(i int) {
  13626. if m.addstatus != nil {
  13627. *m.addstatus += i
  13628. } else {
  13629. m.addstatus = &i
  13630. }
  13631. }
  13632. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13633. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  13634. v := m.addstatus
  13635. if v == nil {
  13636. return
  13637. }
  13638. return *v, true
  13639. }
  13640. // ClearStatus clears the value of the "status" field.
  13641. func (m *CreditBalanceMutation) ClearStatus() {
  13642. m.status = nil
  13643. m.addstatus = nil
  13644. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  13645. }
  13646. // StatusCleared returns if the "status" field was cleared in this mutation.
  13647. func (m *CreditBalanceMutation) StatusCleared() bool {
  13648. _, ok := m.clearedFields[creditbalance.FieldStatus]
  13649. return ok
  13650. }
  13651. // ResetStatus resets all changes to the "status" field.
  13652. func (m *CreditBalanceMutation) ResetStatus() {
  13653. m.status = nil
  13654. m.addstatus = nil
  13655. delete(m.clearedFields, creditbalance.FieldStatus)
  13656. }
  13657. // SetOrganizationID sets the "organization_id" field.
  13658. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  13659. m.organization_id = &u
  13660. m.addorganization_id = nil
  13661. }
  13662. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13663. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  13664. v := m.organization_id
  13665. if v == nil {
  13666. return
  13667. }
  13668. return *v, true
  13669. }
  13670. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  13671. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13673. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13674. if !m.op.Is(OpUpdateOne) {
  13675. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13676. }
  13677. if m.id == nil || m.oldValue == nil {
  13678. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13679. }
  13680. oldValue, err := m.oldValue(ctx)
  13681. if err != nil {
  13682. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13683. }
  13684. return oldValue.OrganizationID, nil
  13685. }
  13686. // AddOrganizationID adds u to the "organization_id" field.
  13687. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  13688. if m.addorganization_id != nil {
  13689. *m.addorganization_id += u
  13690. } else {
  13691. m.addorganization_id = &u
  13692. }
  13693. }
  13694. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13695. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  13696. v := m.addorganization_id
  13697. if v == nil {
  13698. return
  13699. }
  13700. return *v, true
  13701. }
  13702. // ClearOrganizationID clears the value of the "organization_id" field.
  13703. func (m *CreditBalanceMutation) ClearOrganizationID() {
  13704. m.organization_id = nil
  13705. m.addorganization_id = nil
  13706. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  13707. }
  13708. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13709. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  13710. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  13711. return ok
  13712. }
  13713. // ResetOrganizationID resets all changes to the "organization_id" field.
  13714. func (m *CreditBalanceMutation) ResetOrganizationID() {
  13715. m.organization_id = nil
  13716. m.addorganization_id = nil
  13717. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  13718. }
  13719. // Where appends a list predicates to the CreditBalanceMutation builder.
  13720. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  13721. m.predicates = append(m.predicates, ps...)
  13722. }
  13723. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  13724. // users can use type-assertion to append predicates that do not depend on any generated package.
  13725. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  13726. p := make([]predicate.CreditBalance, len(ps))
  13727. for i := range ps {
  13728. p[i] = ps[i]
  13729. }
  13730. m.Where(p...)
  13731. }
  13732. // Op returns the operation name.
  13733. func (m *CreditBalanceMutation) Op() Op {
  13734. return m.op
  13735. }
  13736. // SetOp allows setting the mutation operation.
  13737. func (m *CreditBalanceMutation) SetOp(op Op) {
  13738. m.op = op
  13739. }
  13740. // Type returns the node type of this mutation (CreditBalance).
  13741. func (m *CreditBalanceMutation) Type() string {
  13742. return m.typ
  13743. }
  13744. // Fields returns all fields that were changed during this mutation. Note that in
  13745. // order to get all numeric fields that were incremented/decremented, call
  13746. // AddedFields().
  13747. func (m *CreditBalanceMutation) Fields() []string {
  13748. fields := make([]string, 0, 7)
  13749. if m.created_at != nil {
  13750. fields = append(fields, creditbalance.FieldCreatedAt)
  13751. }
  13752. if m.updated_at != nil {
  13753. fields = append(fields, creditbalance.FieldUpdatedAt)
  13754. }
  13755. if m.deleted_at != nil {
  13756. fields = append(fields, creditbalance.FieldDeletedAt)
  13757. }
  13758. if m.user_id != nil {
  13759. fields = append(fields, creditbalance.FieldUserID)
  13760. }
  13761. if m.balance != nil {
  13762. fields = append(fields, creditbalance.FieldBalance)
  13763. }
  13764. if m.status != nil {
  13765. fields = append(fields, creditbalance.FieldStatus)
  13766. }
  13767. if m.organization_id != nil {
  13768. fields = append(fields, creditbalance.FieldOrganizationID)
  13769. }
  13770. return fields
  13771. }
  13772. // Field returns the value of a field with the given name. The second boolean
  13773. // return value indicates that this field was not set, or was not defined in the
  13774. // schema.
  13775. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  13776. switch name {
  13777. case creditbalance.FieldCreatedAt:
  13778. return m.CreatedAt()
  13779. case creditbalance.FieldUpdatedAt:
  13780. return m.UpdatedAt()
  13781. case creditbalance.FieldDeletedAt:
  13782. return m.DeletedAt()
  13783. case creditbalance.FieldUserID:
  13784. return m.UserID()
  13785. case creditbalance.FieldBalance:
  13786. return m.Balance()
  13787. case creditbalance.FieldStatus:
  13788. return m.Status()
  13789. case creditbalance.FieldOrganizationID:
  13790. return m.OrganizationID()
  13791. }
  13792. return nil, false
  13793. }
  13794. // OldField returns the old value of the field from the database. An error is
  13795. // returned if the mutation operation is not UpdateOne, or the query to the
  13796. // database failed.
  13797. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13798. switch name {
  13799. case creditbalance.FieldCreatedAt:
  13800. return m.OldCreatedAt(ctx)
  13801. case creditbalance.FieldUpdatedAt:
  13802. return m.OldUpdatedAt(ctx)
  13803. case creditbalance.FieldDeletedAt:
  13804. return m.OldDeletedAt(ctx)
  13805. case creditbalance.FieldUserID:
  13806. return m.OldUserID(ctx)
  13807. case creditbalance.FieldBalance:
  13808. return m.OldBalance(ctx)
  13809. case creditbalance.FieldStatus:
  13810. return m.OldStatus(ctx)
  13811. case creditbalance.FieldOrganizationID:
  13812. return m.OldOrganizationID(ctx)
  13813. }
  13814. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  13815. }
  13816. // SetField sets the value of a field with the given name. It returns an error if
  13817. // the field is not defined in the schema, or if the type mismatched the field
  13818. // type.
  13819. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  13820. switch name {
  13821. case creditbalance.FieldCreatedAt:
  13822. v, ok := value.(time.Time)
  13823. if !ok {
  13824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13825. }
  13826. m.SetCreatedAt(v)
  13827. return nil
  13828. case creditbalance.FieldUpdatedAt:
  13829. v, ok := value.(time.Time)
  13830. if !ok {
  13831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13832. }
  13833. m.SetUpdatedAt(v)
  13834. return nil
  13835. case creditbalance.FieldDeletedAt:
  13836. v, ok := value.(time.Time)
  13837. if !ok {
  13838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13839. }
  13840. m.SetDeletedAt(v)
  13841. return nil
  13842. case creditbalance.FieldUserID:
  13843. v, ok := value.(string)
  13844. if !ok {
  13845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13846. }
  13847. m.SetUserID(v)
  13848. return nil
  13849. case creditbalance.FieldBalance:
  13850. v, ok := value.(float64)
  13851. if !ok {
  13852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13853. }
  13854. m.SetBalance(v)
  13855. return nil
  13856. case creditbalance.FieldStatus:
  13857. v, ok := value.(int)
  13858. if !ok {
  13859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13860. }
  13861. m.SetStatus(v)
  13862. return nil
  13863. case creditbalance.FieldOrganizationID:
  13864. v, ok := value.(uint64)
  13865. if !ok {
  13866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13867. }
  13868. m.SetOrganizationID(v)
  13869. return nil
  13870. }
  13871. return fmt.Errorf("unknown CreditBalance field %s", name)
  13872. }
  13873. // AddedFields returns all numeric fields that were incremented/decremented during
  13874. // this mutation.
  13875. func (m *CreditBalanceMutation) AddedFields() []string {
  13876. var fields []string
  13877. if m.addbalance != nil {
  13878. fields = append(fields, creditbalance.FieldBalance)
  13879. }
  13880. if m.addstatus != nil {
  13881. fields = append(fields, creditbalance.FieldStatus)
  13882. }
  13883. if m.addorganization_id != nil {
  13884. fields = append(fields, creditbalance.FieldOrganizationID)
  13885. }
  13886. return fields
  13887. }
  13888. // AddedField returns the numeric value that was incremented/decremented on a field
  13889. // with the given name. The second boolean return value indicates that this field
  13890. // was not set, or was not defined in the schema.
  13891. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  13892. switch name {
  13893. case creditbalance.FieldBalance:
  13894. return m.AddedBalance()
  13895. case creditbalance.FieldStatus:
  13896. return m.AddedStatus()
  13897. case creditbalance.FieldOrganizationID:
  13898. return m.AddedOrganizationID()
  13899. }
  13900. return nil, false
  13901. }
  13902. // AddField adds the value to the field with the given name. It returns an error if
  13903. // the field is not defined in the schema, or if the type mismatched the field
  13904. // type.
  13905. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  13906. switch name {
  13907. case creditbalance.FieldBalance:
  13908. v, ok := value.(float64)
  13909. if !ok {
  13910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13911. }
  13912. m.AddBalance(v)
  13913. return nil
  13914. case creditbalance.FieldStatus:
  13915. v, ok := value.(int)
  13916. if !ok {
  13917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13918. }
  13919. m.AddStatus(v)
  13920. return nil
  13921. case creditbalance.FieldOrganizationID:
  13922. v, ok := value.(int64)
  13923. if !ok {
  13924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13925. }
  13926. m.AddOrganizationID(v)
  13927. return nil
  13928. }
  13929. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  13930. }
  13931. // ClearedFields returns all nullable fields that were cleared during this
  13932. // mutation.
  13933. func (m *CreditBalanceMutation) ClearedFields() []string {
  13934. var fields []string
  13935. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  13936. fields = append(fields, creditbalance.FieldDeletedAt)
  13937. }
  13938. if m.FieldCleared(creditbalance.FieldUserID) {
  13939. fields = append(fields, creditbalance.FieldUserID)
  13940. }
  13941. if m.FieldCleared(creditbalance.FieldStatus) {
  13942. fields = append(fields, creditbalance.FieldStatus)
  13943. }
  13944. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  13945. fields = append(fields, creditbalance.FieldOrganizationID)
  13946. }
  13947. return fields
  13948. }
  13949. // FieldCleared returns a boolean indicating if a field with the given name was
  13950. // cleared in this mutation.
  13951. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  13952. _, ok := m.clearedFields[name]
  13953. return ok
  13954. }
  13955. // ClearField clears the value of the field with the given name. It returns an
  13956. // error if the field is not defined in the schema.
  13957. func (m *CreditBalanceMutation) ClearField(name string) error {
  13958. switch name {
  13959. case creditbalance.FieldDeletedAt:
  13960. m.ClearDeletedAt()
  13961. return nil
  13962. case creditbalance.FieldUserID:
  13963. m.ClearUserID()
  13964. return nil
  13965. case creditbalance.FieldStatus:
  13966. m.ClearStatus()
  13967. return nil
  13968. case creditbalance.FieldOrganizationID:
  13969. m.ClearOrganizationID()
  13970. return nil
  13971. }
  13972. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  13973. }
  13974. // ResetField resets all changes in the mutation for the field with the given name.
  13975. // It returns an error if the field is not defined in the schema.
  13976. func (m *CreditBalanceMutation) ResetField(name string) error {
  13977. switch name {
  13978. case creditbalance.FieldCreatedAt:
  13979. m.ResetCreatedAt()
  13980. return nil
  13981. case creditbalance.FieldUpdatedAt:
  13982. m.ResetUpdatedAt()
  13983. return nil
  13984. case creditbalance.FieldDeletedAt:
  13985. m.ResetDeletedAt()
  13986. return nil
  13987. case creditbalance.FieldUserID:
  13988. m.ResetUserID()
  13989. return nil
  13990. case creditbalance.FieldBalance:
  13991. m.ResetBalance()
  13992. return nil
  13993. case creditbalance.FieldStatus:
  13994. m.ResetStatus()
  13995. return nil
  13996. case creditbalance.FieldOrganizationID:
  13997. m.ResetOrganizationID()
  13998. return nil
  13999. }
  14000. return fmt.Errorf("unknown CreditBalance field %s", name)
  14001. }
  14002. // AddedEdges returns all edge names that were set/added in this mutation.
  14003. func (m *CreditBalanceMutation) AddedEdges() []string {
  14004. edges := make([]string, 0, 0)
  14005. return edges
  14006. }
  14007. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14008. // name in this mutation.
  14009. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  14010. return nil
  14011. }
  14012. // RemovedEdges returns all edge names that were removed in this mutation.
  14013. func (m *CreditBalanceMutation) RemovedEdges() []string {
  14014. edges := make([]string, 0, 0)
  14015. return edges
  14016. }
  14017. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14018. // the given name in this mutation.
  14019. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  14020. return nil
  14021. }
  14022. // ClearedEdges returns all edge names that were cleared in this mutation.
  14023. func (m *CreditBalanceMutation) ClearedEdges() []string {
  14024. edges := make([]string, 0, 0)
  14025. return edges
  14026. }
  14027. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14028. // was cleared in this mutation.
  14029. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  14030. return false
  14031. }
  14032. // ClearEdge clears the value of the edge with the given name. It returns an error
  14033. // if that edge is not defined in the schema.
  14034. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  14035. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  14036. }
  14037. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14038. // It returns an error if the edge is not defined in the schema.
  14039. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  14040. return fmt.Errorf("unknown CreditBalance edge %s", name)
  14041. }
  14042. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  14043. type CreditUsageMutation struct {
  14044. config
  14045. op Op
  14046. typ string
  14047. id *uint64
  14048. created_at *time.Time
  14049. updated_at *time.Time
  14050. deleted_at *time.Time
  14051. user_id *string
  14052. number *float64
  14053. addnumber *float64
  14054. pay_number *float64
  14055. addpay_number *float64
  14056. before_number *float64
  14057. addbefore_number *float64
  14058. after_number *float64
  14059. addafter_number *float64
  14060. pay_method *int
  14061. addpay_method *int
  14062. status *int
  14063. addstatus *int
  14064. ntype *int
  14065. addntype *int
  14066. table *string
  14067. organization_id *uint64
  14068. addorganization_id *int64
  14069. nid *uint64
  14070. addnid *int64
  14071. reason *string
  14072. operator *string
  14073. clearedFields map[string]struct{}
  14074. done bool
  14075. oldValue func(context.Context) (*CreditUsage, error)
  14076. predicates []predicate.CreditUsage
  14077. }
  14078. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  14079. // creditusageOption allows management of the mutation configuration using functional options.
  14080. type creditusageOption func(*CreditUsageMutation)
  14081. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  14082. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  14083. m := &CreditUsageMutation{
  14084. config: c,
  14085. op: op,
  14086. typ: TypeCreditUsage,
  14087. clearedFields: make(map[string]struct{}),
  14088. }
  14089. for _, opt := range opts {
  14090. opt(m)
  14091. }
  14092. return m
  14093. }
  14094. // withCreditUsageID sets the ID field of the mutation.
  14095. func withCreditUsageID(id uint64) creditusageOption {
  14096. return func(m *CreditUsageMutation) {
  14097. var (
  14098. err error
  14099. once sync.Once
  14100. value *CreditUsage
  14101. )
  14102. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  14103. once.Do(func() {
  14104. if m.done {
  14105. err = errors.New("querying old values post mutation is not allowed")
  14106. } else {
  14107. value, err = m.Client().CreditUsage.Get(ctx, id)
  14108. }
  14109. })
  14110. return value, err
  14111. }
  14112. m.id = &id
  14113. }
  14114. }
  14115. // withCreditUsage sets the old CreditUsage of the mutation.
  14116. func withCreditUsage(node *CreditUsage) creditusageOption {
  14117. return func(m *CreditUsageMutation) {
  14118. m.oldValue = func(context.Context) (*CreditUsage, error) {
  14119. return node, nil
  14120. }
  14121. m.id = &node.ID
  14122. }
  14123. }
  14124. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14125. // executed in a transaction (ent.Tx), a transactional client is returned.
  14126. func (m CreditUsageMutation) Client() *Client {
  14127. client := &Client{config: m.config}
  14128. client.init()
  14129. return client
  14130. }
  14131. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14132. // it returns an error otherwise.
  14133. func (m CreditUsageMutation) Tx() (*Tx, error) {
  14134. if _, ok := m.driver.(*txDriver); !ok {
  14135. return nil, errors.New("ent: mutation is not running in a transaction")
  14136. }
  14137. tx := &Tx{config: m.config}
  14138. tx.init()
  14139. return tx, nil
  14140. }
  14141. // SetID sets the value of the id field. Note that this
  14142. // operation is only accepted on creation of CreditUsage entities.
  14143. func (m *CreditUsageMutation) SetID(id uint64) {
  14144. m.id = &id
  14145. }
  14146. // ID returns the ID value in the mutation. Note that the ID is only available
  14147. // if it was provided to the builder or after it was returned from the database.
  14148. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  14149. if m.id == nil {
  14150. return
  14151. }
  14152. return *m.id, true
  14153. }
  14154. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14155. // That means, if the mutation is applied within a transaction with an isolation level such
  14156. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14157. // or updated by the mutation.
  14158. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  14159. switch {
  14160. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14161. id, exists := m.ID()
  14162. if exists {
  14163. return []uint64{id}, nil
  14164. }
  14165. fallthrough
  14166. case m.op.Is(OpUpdate | OpDelete):
  14167. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  14168. default:
  14169. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14170. }
  14171. }
  14172. // SetCreatedAt sets the "created_at" field.
  14173. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  14174. m.created_at = &t
  14175. }
  14176. // CreatedAt returns the value of the "created_at" field in the mutation.
  14177. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  14178. v := m.created_at
  14179. if v == nil {
  14180. return
  14181. }
  14182. return *v, true
  14183. }
  14184. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  14185. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14187. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14188. if !m.op.Is(OpUpdateOne) {
  14189. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14190. }
  14191. if m.id == nil || m.oldValue == nil {
  14192. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14193. }
  14194. oldValue, err := m.oldValue(ctx)
  14195. if err != nil {
  14196. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14197. }
  14198. return oldValue.CreatedAt, nil
  14199. }
  14200. // ResetCreatedAt resets all changes to the "created_at" field.
  14201. func (m *CreditUsageMutation) ResetCreatedAt() {
  14202. m.created_at = nil
  14203. }
  14204. // SetUpdatedAt sets the "updated_at" field.
  14205. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  14206. m.updated_at = &t
  14207. }
  14208. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14209. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  14210. v := m.updated_at
  14211. if v == nil {
  14212. return
  14213. }
  14214. return *v, true
  14215. }
  14216. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  14217. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14219. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14220. if !m.op.Is(OpUpdateOne) {
  14221. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14222. }
  14223. if m.id == nil || m.oldValue == nil {
  14224. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14225. }
  14226. oldValue, err := m.oldValue(ctx)
  14227. if err != nil {
  14228. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14229. }
  14230. return oldValue.UpdatedAt, nil
  14231. }
  14232. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14233. func (m *CreditUsageMutation) ResetUpdatedAt() {
  14234. m.updated_at = nil
  14235. }
  14236. // SetDeletedAt sets the "deleted_at" field.
  14237. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  14238. m.deleted_at = &t
  14239. }
  14240. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14241. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  14242. v := m.deleted_at
  14243. if v == nil {
  14244. return
  14245. }
  14246. return *v, true
  14247. }
  14248. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  14249. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14251. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14252. if !m.op.Is(OpUpdateOne) {
  14253. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14254. }
  14255. if m.id == nil || m.oldValue == nil {
  14256. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14257. }
  14258. oldValue, err := m.oldValue(ctx)
  14259. if err != nil {
  14260. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14261. }
  14262. return oldValue.DeletedAt, nil
  14263. }
  14264. // ClearDeletedAt clears the value of the "deleted_at" field.
  14265. func (m *CreditUsageMutation) ClearDeletedAt() {
  14266. m.deleted_at = nil
  14267. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  14268. }
  14269. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14270. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  14271. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  14272. return ok
  14273. }
  14274. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14275. func (m *CreditUsageMutation) ResetDeletedAt() {
  14276. m.deleted_at = nil
  14277. delete(m.clearedFields, creditusage.FieldDeletedAt)
  14278. }
  14279. // SetUserID sets the "user_id" field.
  14280. func (m *CreditUsageMutation) SetUserID(s string) {
  14281. m.user_id = &s
  14282. }
  14283. // UserID returns the value of the "user_id" field in the mutation.
  14284. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  14285. v := m.user_id
  14286. if v == nil {
  14287. return
  14288. }
  14289. return *v, true
  14290. }
  14291. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  14292. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14294. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  14295. if !m.op.Is(OpUpdateOne) {
  14296. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14297. }
  14298. if m.id == nil || m.oldValue == nil {
  14299. return v, errors.New("OldUserID requires an ID field in the mutation")
  14300. }
  14301. oldValue, err := m.oldValue(ctx)
  14302. if err != nil {
  14303. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14304. }
  14305. return oldValue.UserID, nil
  14306. }
  14307. // ClearUserID clears the value of the "user_id" field.
  14308. func (m *CreditUsageMutation) ClearUserID() {
  14309. m.user_id = nil
  14310. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  14311. }
  14312. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14313. func (m *CreditUsageMutation) UserIDCleared() bool {
  14314. _, ok := m.clearedFields[creditusage.FieldUserID]
  14315. return ok
  14316. }
  14317. // ResetUserID resets all changes to the "user_id" field.
  14318. func (m *CreditUsageMutation) ResetUserID() {
  14319. m.user_id = nil
  14320. delete(m.clearedFields, creditusage.FieldUserID)
  14321. }
  14322. // SetNumber sets the "number" field.
  14323. func (m *CreditUsageMutation) SetNumber(f float64) {
  14324. m.number = &f
  14325. m.addnumber = nil
  14326. }
  14327. // Number returns the value of the "number" field in the mutation.
  14328. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  14329. v := m.number
  14330. if v == nil {
  14331. return
  14332. }
  14333. return *v, true
  14334. }
  14335. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  14336. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14338. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  14339. if !m.op.Is(OpUpdateOne) {
  14340. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  14341. }
  14342. if m.id == nil || m.oldValue == nil {
  14343. return v, errors.New("OldNumber requires an ID field in the mutation")
  14344. }
  14345. oldValue, err := m.oldValue(ctx)
  14346. if err != nil {
  14347. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  14348. }
  14349. return oldValue.Number, nil
  14350. }
  14351. // AddNumber adds f to the "number" field.
  14352. func (m *CreditUsageMutation) AddNumber(f float64) {
  14353. if m.addnumber != nil {
  14354. *m.addnumber += f
  14355. } else {
  14356. m.addnumber = &f
  14357. }
  14358. }
  14359. // AddedNumber returns the value that was added to the "number" field in this mutation.
  14360. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  14361. v := m.addnumber
  14362. if v == nil {
  14363. return
  14364. }
  14365. return *v, true
  14366. }
  14367. // ResetNumber resets all changes to the "number" field.
  14368. func (m *CreditUsageMutation) ResetNumber() {
  14369. m.number = nil
  14370. m.addnumber = nil
  14371. }
  14372. // SetPayNumber sets the "pay_number" field.
  14373. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  14374. m.pay_number = &f
  14375. m.addpay_number = nil
  14376. }
  14377. // PayNumber returns the value of the "pay_number" field in the mutation.
  14378. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  14379. v := m.pay_number
  14380. if v == nil {
  14381. return
  14382. }
  14383. return *v, true
  14384. }
  14385. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  14386. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14388. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  14389. if !m.op.Is(OpUpdateOne) {
  14390. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  14391. }
  14392. if m.id == nil || m.oldValue == nil {
  14393. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  14394. }
  14395. oldValue, err := m.oldValue(ctx)
  14396. if err != nil {
  14397. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  14398. }
  14399. return oldValue.PayNumber, nil
  14400. }
  14401. // AddPayNumber adds f to the "pay_number" field.
  14402. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  14403. if m.addpay_number != nil {
  14404. *m.addpay_number += f
  14405. } else {
  14406. m.addpay_number = &f
  14407. }
  14408. }
  14409. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  14410. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  14411. v := m.addpay_number
  14412. if v == nil {
  14413. return
  14414. }
  14415. return *v, true
  14416. }
  14417. // ClearPayNumber clears the value of the "pay_number" field.
  14418. func (m *CreditUsageMutation) ClearPayNumber() {
  14419. m.pay_number = nil
  14420. m.addpay_number = nil
  14421. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  14422. }
  14423. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  14424. func (m *CreditUsageMutation) PayNumberCleared() bool {
  14425. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  14426. return ok
  14427. }
  14428. // ResetPayNumber resets all changes to the "pay_number" field.
  14429. func (m *CreditUsageMutation) ResetPayNumber() {
  14430. m.pay_number = nil
  14431. m.addpay_number = nil
  14432. delete(m.clearedFields, creditusage.FieldPayNumber)
  14433. }
  14434. // SetBeforeNumber sets the "before_number" field.
  14435. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  14436. m.before_number = &f
  14437. m.addbefore_number = nil
  14438. }
  14439. // BeforeNumber returns the value of the "before_number" field in the mutation.
  14440. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  14441. v := m.before_number
  14442. if v == nil {
  14443. return
  14444. }
  14445. return *v, true
  14446. }
  14447. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  14448. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14450. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  14451. if !m.op.Is(OpUpdateOne) {
  14452. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  14453. }
  14454. if m.id == nil || m.oldValue == nil {
  14455. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  14456. }
  14457. oldValue, err := m.oldValue(ctx)
  14458. if err != nil {
  14459. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  14460. }
  14461. return oldValue.BeforeNumber, nil
  14462. }
  14463. // AddBeforeNumber adds f to the "before_number" field.
  14464. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  14465. if m.addbefore_number != nil {
  14466. *m.addbefore_number += f
  14467. } else {
  14468. m.addbefore_number = &f
  14469. }
  14470. }
  14471. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  14472. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  14473. v := m.addbefore_number
  14474. if v == nil {
  14475. return
  14476. }
  14477. return *v, true
  14478. }
  14479. // ClearBeforeNumber clears the value of the "before_number" field.
  14480. func (m *CreditUsageMutation) ClearBeforeNumber() {
  14481. m.before_number = nil
  14482. m.addbefore_number = nil
  14483. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  14484. }
  14485. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  14486. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  14487. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  14488. return ok
  14489. }
  14490. // ResetBeforeNumber resets all changes to the "before_number" field.
  14491. func (m *CreditUsageMutation) ResetBeforeNumber() {
  14492. m.before_number = nil
  14493. m.addbefore_number = nil
  14494. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  14495. }
  14496. // SetAfterNumber sets the "after_number" field.
  14497. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  14498. m.after_number = &f
  14499. m.addafter_number = nil
  14500. }
  14501. // AfterNumber returns the value of the "after_number" field in the mutation.
  14502. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  14503. v := m.after_number
  14504. if v == nil {
  14505. return
  14506. }
  14507. return *v, true
  14508. }
  14509. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  14510. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14512. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  14513. if !m.op.Is(OpUpdateOne) {
  14514. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  14515. }
  14516. if m.id == nil || m.oldValue == nil {
  14517. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  14518. }
  14519. oldValue, err := m.oldValue(ctx)
  14520. if err != nil {
  14521. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  14522. }
  14523. return oldValue.AfterNumber, nil
  14524. }
  14525. // AddAfterNumber adds f to the "after_number" field.
  14526. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  14527. if m.addafter_number != nil {
  14528. *m.addafter_number += f
  14529. } else {
  14530. m.addafter_number = &f
  14531. }
  14532. }
  14533. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  14534. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  14535. v := m.addafter_number
  14536. if v == nil {
  14537. return
  14538. }
  14539. return *v, true
  14540. }
  14541. // ClearAfterNumber clears the value of the "after_number" field.
  14542. func (m *CreditUsageMutation) ClearAfterNumber() {
  14543. m.after_number = nil
  14544. m.addafter_number = nil
  14545. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  14546. }
  14547. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  14548. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  14549. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  14550. return ok
  14551. }
  14552. // ResetAfterNumber resets all changes to the "after_number" field.
  14553. func (m *CreditUsageMutation) ResetAfterNumber() {
  14554. m.after_number = nil
  14555. m.addafter_number = nil
  14556. delete(m.clearedFields, creditusage.FieldAfterNumber)
  14557. }
  14558. // SetPayMethod sets the "pay_method" field.
  14559. func (m *CreditUsageMutation) SetPayMethod(i int) {
  14560. m.pay_method = &i
  14561. m.addpay_method = nil
  14562. }
  14563. // PayMethod returns the value of the "pay_method" field in the mutation.
  14564. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  14565. v := m.pay_method
  14566. if v == nil {
  14567. return
  14568. }
  14569. return *v, true
  14570. }
  14571. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  14572. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14574. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  14575. if !m.op.Is(OpUpdateOne) {
  14576. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  14577. }
  14578. if m.id == nil || m.oldValue == nil {
  14579. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  14580. }
  14581. oldValue, err := m.oldValue(ctx)
  14582. if err != nil {
  14583. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  14584. }
  14585. return oldValue.PayMethod, nil
  14586. }
  14587. // AddPayMethod adds i to the "pay_method" field.
  14588. func (m *CreditUsageMutation) AddPayMethod(i int) {
  14589. if m.addpay_method != nil {
  14590. *m.addpay_method += i
  14591. } else {
  14592. m.addpay_method = &i
  14593. }
  14594. }
  14595. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  14596. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  14597. v := m.addpay_method
  14598. if v == nil {
  14599. return
  14600. }
  14601. return *v, true
  14602. }
  14603. // ClearPayMethod clears the value of the "pay_method" field.
  14604. func (m *CreditUsageMutation) ClearPayMethod() {
  14605. m.pay_method = nil
  14606. m.addpay_method = nil
  14607. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  14608. }
  14609. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  14610. func (m *CreditUsageMutation) PayMethodCleared() bool {
  14611. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  14612. return ok
  14613. }
  14614. // ResetPayMethod resets all changes to the "pay_method" field.
  14615. func (m *CreditUsageMutation) ResetPayMethod() {
  14616. m.pay_method = nil
  14617. m.addpay_method = nil
  14618. delete(m.clearedFields, creditusage.FieldPayMethod)
  14619. }
  14620. // SetStatus sets the "status" field.
  14621. func (m *CreditUsageMutation) SetStatus(i int) {
  14622. m.status = &i
  14623. m.addstatus = nil
  14624. }
  14625. // Status returns the value of the "status" field in the mutation.
  14626. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  14627. v := m.status
  14628. if v == nil {
  14629. return
  14630. }
  14631. return *v, true
  14632. }
  14633. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  14634. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14636. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  14637. if !m.op.Is(OpUpdateOne) {
  14638. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14639. }
  14640. if m.id == nil || m.oldValue == nil {
  14641. return v, errors.New("OldStatus requires an ID field in the mutation")
  14642. }
  14643. oldValue, err := m.oldValue(ctx)
  14644. if err != nil {
  14645. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14646. }
  14647. return oldValue.Status, nil
  14648. }
  14649. // AddStatus adds i to the "status" field.
  14650. func (m *CreditUsageMutation) AddStatus(i int) {
  14651. if m.addstatus != nil {
  14652. *m.addstatus += i
  14653. } else {
  14654. m.addstatus = &i
  14655. }
  14656. }
  14657. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14658. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  14659. v := m.addstatus
  14660. if v == nil {
  14661. return
  14662. }
  14663. return *v, true
  14664. }
  14665. // ClearStatus clears the value of the "status" field.
  14666. func (m *CreditUsageMutation) ClearStatus() {
  14667. m.status = nil
  14668. m.addstatus = nil
  14669. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  14670. }
  14671. // StatusCleared returns if the "status" field was cleared in this mutation.
  14672. func (m *CreditUsageMutation) StatusCleared() bool {
  14673. _, ok := m.clearedFields[creditusage.FieldStatus]
  14674. return ok
  14675. }
  14676. // ResetStatus resets all changes to the "status" field.
  14677. func (m *CreditUsageMutation) ResetStatus() {
  14678. m.status = nil
  14679. m.addstatus = nil
  14680. delete(m.clearedFields, creditusage.FieldStatus)
  14681. }
  14682. // SetNtype sets the "ntype" field.
  14683. func (m *CreditUsageMutation) SetNtype(i int) {
  14684. m.ntype = &i
  14685. m.addntype = nil
  14686. }
  14687. // Ntype returns the value of the "ntype" field in the mutation.
  14688. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  14689. v := m.ntype
  14690. if v == nil {
  14691. return
  14692. }
  14693. return *v, true
  14694. }
  14695. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  14696. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14698. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  14699. if !m.op.Is(OpUpdateOne) {
  14700. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  14701. }
  14702. if m.id == nil || m.oldValue == nil {
  14703. return v, errors.New("OldNtype requires an ID field in the mutation")
  14704. }
  14705. oldValue, err := m.oldValue(ctx)
  14706. if err != nil {
  14707. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  14708. }
  14709. return oldValue.Ntype, nil
  14710. }
  14711. // AddNtype adds i to the "ntype" field.
  14712. func (m *CreditUsageMutation) AddNtype(i int) {
  14713. if m.addntype != nil {
  14714. *m.addntype += i
  14715. } else {
  14716. m.addntype = &i
  14717. }
  14718. }
  14719. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  14720. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  14721. v := m.addntype
  14722. if v == nil {
  14723. return
  14724. }
  14725. return *v, true
  14726. }
  14727. // ResetNtype resets all changes to the "ntype" field.
  14728. func (m *CreditUsageMutation) ResetNtype() {
  14729. m.ntype = nil
  14730. m.addntype = nil
  14731. }
  14732. // SetTable sets the "table" field.
  14733. func (m *CreditUsageMutation) SetTable(s string) {
  14734. m.table = &s
  14735. }
  14736. // Table returns the value of the "table" field in the mutation.
  14737. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  14738. v := m.table
  14739. if v == nil {
  14740. return
  14741. }
  14742. return *v, true
  14743. }
  14744. // OldTable returns the old "table" field's value of the CreditUsage entity.
  14745. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14747. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  14748. if !m.op.Is(OpUpdateOne) {
  14749. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  14750. }
  14751. if m.id == nil || m.oldValue == nil {
  14752. return v, errors.New("OldTable requires an ID field in the mutation")
  14753. }
  14754. oldValue, err := m.oldValue(ctx)
  14755. if err != nil {
  14756. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  14757. }
  14758. return oldValue.Table, nil
  14759. }
  14760. // ResetTable resets all changes to the "table" field.
  14761. func (m *CreditUsageMutation) ResetTable() {
  14762. m.table = nil
  14763. }
  14764. // SetOrganizationID sets the "organization_id" field.
  14765. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  14766. m.organization_id = &u
  14767. m.addorganization_id = nil
  14768. }
  14769. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14770. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  14771. v := m.organization_id
  14772. if v == nil {
  14773. return
  14774. }
  14775. return *v, true
  14776. }
  14777. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  14778. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14780. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14781. if !m.op.Is(OpUpdateOne) {
  14782. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14783. }
  14784. if m.id == nil || m.oldValue == nil {
  14785. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14786. }
  14787. oldValue, err := m.oldValue(ctx)
  14788. if err != nil {
  14789. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14790. }
  14791. return oldValue.OrganizationID, nil
  14792. }
  14793. // AddOrganizationID adds u to the "organization_id" field.
  14794. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  14795. if m.addorganization_id != nil {
  14796. *m.addorganization_id += u
  14797. } else {
  14798. m.addorganization_id = &u
  14799. }
  14800. }
  14801. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14802. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  14803. v := m.addorganization_id
  14804. if v == nil {
  14805. return
  14806. }
  14807. return *v, true
  14808. }
  14809. // ClearOrganizationID clears the value of the "organization_id" field.
  14810. func (m *CreditUsageMutation) ClearOrganizationID() {
  14811. m.organization_id = nil
  14812. m.addorganization_id = nil
  14813. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  14814. }
  14815. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14816. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  14817. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  14818. return ok
  14819. }
  14820. // ResetOrganizationID resets all changes to the "organization_id" field.
  14821. func (m *CreditUsageMutation) ResetOrganizationID() {
  14822. m.organization_id = nil
  14823. m.addorganization_id = nil
  14824. delete(m.clearedFields, creditusage.FieldOrganizationID)
  14825. }
  14826. // SetNid sets the "nid" field.
  14827. func (m *CreditUsageMutation) SetNid(u uint64) {
  14828. m.nid = &u
  14829. m.addnid = nil
  14830. }
  14831. // Nid returns the value of the "nid" field in the mutation.
  14832. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  14833. v := m.nid
  14834. if v == nil {
  14835. return
  14836. }
  14837. return *v, true
  14838. }
  14839. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  14840. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14842. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  14843. if !m.op.Is(OpUpdateOne) {
  14844. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  14845. }
  14846. if m.id == nil || m.oldValue == nil {
  14847. return v, errors.New("OldNid requires an ID field in the mutation")
  14848. }
  14849. oldValue, err := m.oldValue(ctx)
  14850. if err != nil {
  14851. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  14852. }
  14853. return oldValue.Nid, nil
  14854. }
  14855. // AddNid adds u to the "nid" field.
  14856. func (m *CreditUsageMutation) AddNid(u int64) {
  14857. if m.addnid != nil {
  14858. *m.addnid += u
  14859. } else {
  14860. m.addnid = &u
  14861. }
  14862. }
  14863. // AddedNid returns the value that was added to the "nid" field in this mutation.
  14864. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  14865. v := m.addnid
  14866. if v == nil {
  14867. return
  14868. }
  14869. return *v, true
  14870. }
  14871. // ResetNid resets all changes to the "nid" field.
  14872. func (m *CreditUsageMutation) ResetNid() {
  14873. m.nid = nil
  14874. m.addnid = nil
  14875. }
  14876. // SetReason sets the "reason" field.
  14877. func (m *CreditUsageMutation) SetReason(s string) {
  14878. m.reason = &s
  14879. }
  14880. // Reason returns the value of the "reason" field in the mutation.
  14881. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  14882. v := m.reason
  14883. if v == nil {
  14884. return
  14885. }
  14886. return *v, true
  14887. }
  14888. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  14889. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14891. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  14892. if !m.op.Is(OpUpdateOne) {
  14893. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  14894. }
  14895. if m.id == nil || m.oldValue == nil {
  14896. return v, errors.New("OldReason requires an ID field in the mutation")
  14897. }
  14898. oldValue, err := m.oldValue(ctx)
  14899. if err != nil {
  14900. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  14901. }
  14902. return oldValue.Reason, nil
  14903. }
  14904. // ResetReason resets all changes to the "reason" field.
  14905. func (m *CreditUsageMutation) ResetReason() {
  14906. m.reason = nil
  14907. }
  14908. // SetOperator sets the "operator" field.
  14909. func (m *CreditUsageMutation) SetOperator(s string) {
  14910. m.operator = &s
  14911. }
  14912. // Operator returns the value of the "operator" field in the mutation.
  14913. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  14914. v := m.operator
  14915. if v == nil {
  14916. return
  14917. }
  14918. return *v, true
  14919. }
  14920. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  14921. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14923. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  14924. if !m.op.Is(OpUpdateOne) {
  14925. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  14926. }
  14927. if m.id == nil || m.oldValue == nil {
  14928. return v, errors.New("OldOperator requires an ID field in the mutation")
  14929. }
  14930. oldValue, err := m.oldValue(ctx)
  14931. if err != nil {
  14932. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  14933. }
  14934. return oldValue.Operator, nil
  14935. }
  14936. // ResetOperator resets all changes to the "operator" field.
  14937. func (m *CreditUsageMutation) ResetOperator() {
  14938. m.operator = nil
  14939. }
  14940. // Where appends a list predicates to the CreditUsageMutation builder.
  14941. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  14942. m.predicates = append(m.predicates, ps...)
  14943. }
  14944. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  14945. // users can use type-assertion to append predicates that do not depend on any generated package.
  14946. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  14947. p := make([]predicate.CreditUsage, len(ps))
  14948. for i := range ps {
  14949. p[i] = ps[i]
  14950. }
  14951. m.Where(p...)
  14952. }
  14953. // Op returns the operation name.
  14954. func (m *CreditUsageMutation) Op() Op {
  14955. return m.op
  14956. }
  14957. // SetOp allows setting the mutation operation.
  14958. func (m *CreditUsageMutation) SetOp(op Op) {
  14959. m.op = op
  14960. }
  14961. // Type returns the node type of this mutation (CreditUsage).
  14962. func (m *CreditUsageMutation) Type() string {
  14963. return m.typ
  14964. }
  14965. // Fields returns all fields that were changed during this mutation. Note that in
  14966. // order to get all numeric fields that were incremented/decremented, call
  14967. // AddedFields().
  14968. func (m *CreditUsageMutation) Fields() []string {
  14969. fields := make([]string, 0, 16)
  14970. if m.created_at != nil {
  14971. fields = append(fields, creditusage.FieldCreatedAt)
  14972. }
  14973. if m.updated_at != nil {
  14974. fields = append(fields, creditusage.FieldUpdatedAt)
  14975. }
  14976. if m.deleted_at != nil {
  14977. fields = append(fields, creditusage.FieldDeletedAt)
  14978. }
  14979. if m.user_id != nil {
  14980. fields = append(fields, creditusage.FieldUserID)
  14981. }
  14982. if m.number != nil {
  14983. fields = append(fields, creditusage.FieldNumber)
  14984. }
  14985. if m.pay_number != nil {
  14986. fields = append(fields, creditusage.FieldPayNumber)
  14987. }
  14988. if m.before_number != nil {
  14989. fields = append(fields, creditusage.FieldBeforeNumber)
  14990. }
  14991. if m.after_number != nil {
  14992. fields = append(fields, creditusage.FieldAfterNumber)
  14993. }
  14994. if m.pay_method != nil {
  14995. fields = append(fields, creditusage.FieldPayMethod)
  14996. }
  14997. if m.status != nil {
  14998. fields = append(fields, creditusage.FieldStatus)
  14999. }
  15000. if m.ntype != nil {
  15001. fields = append(fields, creditusage.FieldNtype)
  15002. }
  15003. if m.table != nil {
  15004. fields = append(fields, creditusage.FieldTable)
  15005. }
  15006. if m.organization_id != nil {
  15007. fields = append(fields, creditusage.FieldOrganizationID)
  15008. }
  15009. if m.nid != nil {
  15010. fields = append(fields, creditusage.FieldNid)
  15011. }
  15012. if m.reason != nil {
  15013. fields = append(fields, creditusage.FieldReason)
  15014. }
  15015. if m.operator != nil {
  15016. fields = append(fields, creditusage.FieldOperator)
  15017. }
  15018. return fields
  15019. }
  15020. // Field returns the value of a field with the given name. The second boolean
  15021. // return value indicates that this field was not set, or was not defined in the
  15022. // schema.
  15023. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  15024. switch name {
  15025. case creditusage.FieldCreatedAt:
  15026. return m.CreatedAt()
  15027. case creditusage.FieldUpdatedAt:
  15028. return m.UpdatedAt()
  15029. case creditusage.FieldDeletedAt:
  15030. return m.DeletedAt()
  15031. case creditusage.FieldUserID:
  15032. return m.UserID()
  15033. case creditusage.FieldNumber:
  15034. return m.Number()
  15035. case creditusage.FieldPayNumber:
  15036. return m.PayNumber()
  15037. case creditusage.FieldBeforeNumber:
  15038. return m.BeforeNumber()
  15039. case creditusage.FieldAfterNumber:
  15040. return m.AfterNumber()
  15041. case creditusage.FieldPayMethod:
  15042. return m.PayMethod()
  15043. case creditusage.FieldStatus:
  15044. return m.Status()
  15045. case creditusage.FieldNtype:
  15046. return m.Ntype()
  15047. case creditusage.FieldTable:
  15048. return m.Table()
  15049. case creditusage.FieldOrganizationID:
  15050. return m.OrganizationID()
  15051. case creditusage.FieldNid:
  15052. return m.Nid()
  15053. case creditusage.FieldReason:
  15054. return m.Reason()
  15055. case creditusage.FieldOperator:
  15056. return m.Operator()
  15057. }
  15058. return nil, false
  15059. }
  15060. // OldField returns the old value of the field from the database. An error is
  15061. // returned if the mutation operation is not UpdateOne, or the query to the
  15062. // database failed.
  15063. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15064. switch name {
  15065. case creditusage.FieldCreatedAt:
  15066. return m.OldCreatedAt(ctx)
  15067. case creditusage.FieldUpdatedAt:
  15068. return m.OldUpdatedAt(ctx)
  15069. case creditusage.FieldDeletedAt:
  15070. return m.OldDeletedAt(ctx)
  15071. case creditusage.FieldUserID:
  15072. return m.OldUserID(ctx)
  15073. case creditusage.FieldNumber:
  15074. return m.OldNumber(ctx)
  15075. case creditusage.FieldPayNumber:
  15076. return m.OldPayNumber(ctx)
  15077. case creditusage.FieldBeforeNumber:
  15078. return m.OldBeforeNumber(ctx)
  15079. case creditusage.FieldAfterNumber:
  15080. return m.OldAfterNumber(ctx)
  15081. case creditusage.FieldPayMethod:
  15082. return m.OldPayMethod(ctx)
  15083. case creditusage.FieldStatus:
  15084. return m.OldStatus(ctx)
  15085. case creditusage.FieldNtype:
  15086. return m.OldNtype(ctx)
  15087. case creditusage.FieldTable:
  15088. return m.OldTable(ctx)
  15089. case creditusage.FieldOrganizationID:
  15090. return m.OldOrganizationID(ctx)
  15091. case creditusage.FieldNid:
  15092. return m.OldNid(ctx)
  15093. case creditusage.FieldReason:
  15094. return m.OldReason(ctx)
  15095. case creditusage.FieldOperator:
  15096. return m.OldOperator(ctx)
  15097. }
  15098. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  15099. }
  15100. // SetField sets the value of a field with the given name. It returns an error if
  15101. // the field is not defined in the schema, or if the type mismatched the field
  15102. // type.
  15103. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  15104. switch name {
  15105. case creditusage.FieldCreatedAt:
  15106. v, ok := value.(time.Time)
  15107. if !ok {
  15108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15109. }
  15110. m.SetCreatedAt(v)
  15111. return nil
  15112. case creditusage.FieldUpdatedAt:
  15113. v, ok := value.(time.Time)
  15114. if !ok {
  15115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15116. }
  15117. m.SetUpdatedAt(v)
  15118. return nil
  15119. case creditusage.FieldDeletedAt:
  15120. v, ok := value.(time.Time)
  15121. if !ok {
  15122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15123. }
  15124. m.SetDeletedAt(v)
  15125. return nil
  15126. case creditusage.FieldUserID:
  15127. v, ok := value.(string)
  15128. if !ok {
  15129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15130. }
  15131. m.SetUserID(v)
  15132. return nil
  15133. case creditusage.FieldNumber:
  15134. v, ok := value.(float64)
  15135. if !ok {
  15136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15137. }
  15138. m.SetNumber(v)
  15139. return nil
  15140. case creditusage.FieldPayNumber:
  15141. v, ok := value.(float64)
  15142. if !ok {
  15143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15144. }
  15145. m.SetPayNumber(v)
  15146. return nil
  15147. case creditusage.FieldBeforeNumber:
  15148. v, ok := value.(float64)
  15149. if !ok {
  15150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15151. }
  15152. m.SetBeforeNumber(v)
  15153. return nil
  15154. case creditusage.FieldAfterNumber:
  15155. v, ok := value.(float64)
  15156. if !ok {
  15157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15158. }
  15159. m.SetAfterNumber(v)
  15160. return nil
  15161. case creditusage.FieldPayMethod:
  15162. v, ok := value.(int)
  15163. if !ok {
  15164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15165. }
  15166. m.SetPayMethod(v)
  15167. return nil
  15168. case creditusage.FieldStatus:
  15169. v, ok := value.(int)
  15170. if !ok {
  15171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15172. }
  15173. m.SetStatus(v)
  15174. return nil
  15175. case creditusage.FieldNtype:
  15176. v, ok := value.(int)
  15177. if !ok {
  15178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15179. }
  15180. m.SetNtype(v)
  15181. return nil
  15182. case creditusage.FieldTable:
  15183. v, ok := value.(string)
  15184. if !ok {
  15185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15186. }
  15187. m.SetTable(v)
  15188. return nil
  15189. case creditusage.FieldOrganizationID:
  15190. v, ok := value.(uint64)
  15191. if !ok {
  15192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15193. }
  15194. m.SetOrganizationID(v)
  15195. return nil
  15196. case creditusage.FieldNid:
  15197. v, ok := value.(uint64)
  15198. if !ok {
  15199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15200. }
  15201. m.SetNid(v)
  15202. return nil
  15203. case creditusage.FieldReason:
  15204. v, ok := value.(string)
  15205. if !ok {
  15206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15207. }
  15208. m.SetReason(v)
  15209. return nil
  15210. case creditusage.FieldOperator:
  15211. v, ok := value.(string)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.SetOperator(v)
  15216. return nil
  15217. }
  15218. return fmt.Errorf("unknown CreditUsage field %s", name)
  15219. }
  15220. // AddedFields returns all numeric fields that were incremented/decremented during
  15221. // this mutation.
  15222. func (m *CreditUsageMutation) AddedFields() []string {
  15223. var fields []string
  15224. if m.addnumber != nil {
  15225. fields = append(fields, creditusage.FieldNumber)
  15226. }
  15227. if m.addpay_number != nil {
  15228. fields = append(fields, creditusage.FieldPayNumber)
  15229. }
  15230. if m.addbefore_number != nil {
  15231. fields = append(fields, creditusage.FieldBeforeNumber)
  15232. }
  15233. if m.addafter_number != nil {
  15234. fields = append(fields, creditusage.FieldAfterNumber)
  15235. }
  15236. if m.addpay_method != nil {
  15237. fields = append(fields, creditusage.FieldPayMethod)
  15238. }
  15239. if m.addstatus != nil {
  15240. fields = append(fields, creditusage.FieldStatus)
  15241. }
  15242. if m.addntype != nil {
  15243. fields = append(fields, creditusage.FieldNtype)
  15244. }
  15245. if m.addorganization_id != nil {
  15246. fields = append(fields, creditusage.FieldOrganizationID)
  15247. }
  15248. if m.addnid != nil {
  15249. fields = append(fields, creditusage.FieldNid)
  15250. }
  15251. return fields
  15252. }
  15253. // AddedField returns the numeric value that was incremented/decremented on a field
  15254. // with the given name. The second boolean return value indicates that this field
  15255. // was not set, or was not defined in the schema.
  15256. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  15257. switch name {
  15258. case creditusage.FieldNumber:
  15259. return m.AddedNumber()
  15260. case creditusage.FieldPayNumber:
  15261. return m.AddedPayNumber()
  15262. case creditusage.FieldBeforeNumber:
  15263. return m.AddedBeforeNumber()
  15264. case creditusage.FieldAfterNumber:
  15265. return m.AddedAfterNumber()
  15266. case creditusage.FieldPayMethod:
  15267. return m.AddedPayMethod()
  15268. case creditusage.FieldStatus:
  15269. return m.AddedStatus()
  15270. case creditusage.FieldNtype:
  15271. return m.AddedNtype()
  15272. case creditusage.FieldOrganizationID:
  15273. return m.AddedOrganizationID()
  15274. case creditusage.FieldNid:
  15275. return m.AddedNid()
  15276. }
  15277. return nil, false
  15278. }
  15279. // AddField adds the value to the field with the given name. It returns an error if
  15280. // the field is not defined in the schema, or if the type mismatched the field
  15281. // type.
  15282. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  15283. switch name {
  15284. case creditusage.FieldNumber:
  15285. v, ok := value.(float64)
  15286. if !ok {
  15287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15288. }
  15289. m.AddNumber(v)
  15290. return nil
  15291. case creditusage.FieldPayNumber:
  15292. v, ok := value.(float64)
  15293. if !ok {
  15294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15295. }
  15296. m.AddPayNumber(v)
  15297. return nil
  15298. case creditusage.FieldBeforeNumber:
  15299. v, ok := value.(float64)
  15300. if !ok {
  15301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15302. }
  15303. m.AddBeforeNumber(v)
  15304. return nil
  15305. case creditusage.FieldAfterNumber:
  15306. v, ok := value.(float64)
  15307. if !ok {
  15308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15309. }
  15310. m.AddAfterNumber(v)
  15311. return nil
  15312. case creditusage.FieldPayMethod:
  15313. v, ok := value.(int)
  15314. if !ok {
  15315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15316. }
  15317. m.AddPayMethod(v)
  15318. return nil
  15319. case creditusage.FieldStatus:
  15320. v, ok := value.(int)
  15321. if !ok {
  15322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15323. }
  15324. m.AddStatus(v)
  15325. return nil
  15326. case creditusage.FieldNtype:
  15327. v, ok := value.(int)
  15328. if !ok {
  15329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15330. }
  15331. m.AddNtype(v)
  15332. return nil
  15333. case creditusage.FieldOrganizationID:
  15334. v, ok := value.(int64)
  15335. if !ok {
  15336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15337. }
  15338. m.AddOrganizationID(v)
  15339. return nil
  15340. case creditusage.FieldNid:
  15341. v, ok := value.(int64)
  15342. if !ok {
  15343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15344. }
  15345. m.AddNid(v)
  15346. return nil
  15347. }
  15348. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  15349. }
  15350. // ClearedFields returns all nullable fields that were cleared during this
  15351. // mutation.
  15352. func (m *CreditUsageMutation) ClearedFields() []string {
  15353. var fields []string
  15354. if m.FieldCleared(creditusage.FieldDeletedAt) {
  15355. fields = append(fields, creditusage.FieldDeletedAt)
  15356. }
  15357. if m.FieldCleared(creditusage.FieldUserID) {
  15358. fields = append(fields, creditusage.FieldUserID)
  15359. }
  15360. if m.FieldCleared(creditusage.FieldPayNumber) {
  15361. fields = append(fields, creditusage.FieldPayNumber)
  15362. }
  15363. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  15364. fields = append(fields, creditusage.FieldBeforeNumber)
  15365. }
  15366. if m.FieldCleared(creditusage.FieldAfterNumber) {
  15367. fields = append(fields, creditusage.FieldAfterNumber)
  15368. }
  15369. if m.FieldCleared(creditusage.FieldPayMethod) {
  15370. fields = append(fields, creditusage.FieldPayMethod)
  15371. }
  15372. if m.FieldCleared(creditusage.FieldStatus) {
  15373. fields = append(fields, creditusage.FieldStatus)
  15374. }
  15375. if m.FieldCleared(creditusage.FieldOrganizationID) {
  15376. fields = append(fields, creditusage.FieldOrganizationID)
  15377. }
  15378. return fields
  15379. }
  15380. // FieldCleared returns a boolean indicating if a field with the given name was
  15381. // cleared in this mutation.
  15382. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  15383. _, ok := m.clearedFields[name]
  15384. return ok
  15385. }
  15386. // ClearField clears the value of the field with the given name. It returns an
  15387. // error if the field is not defined in the schema.
  15388. func (m *CreditUsageMutation) ClearField(name string) error {
  15389. switch name {
  15390. case creditusage.FieldDeletedAt:
  15391. m.ClearDeletedAt()
  15392. return nil
  15393. case creditusage.FieldUserID:
  15394. m.ClearUserID()
  15395. return nil
  15396. case creditusage.FieldPayNumber:
  15397. m.ClearPayNumber()
  15398. return nil
  15399. case creditusage.FieldBeforeNumber:
  15400. m.ClearBeforeNumber()
  15401. return nil
  15402. case creditusage.FieldAfterNumber:
  15403. m.ClearAfterNumber()
  15404. return nil
  15405. case creditusage.FieldPayMethod:
  15406. m.ClearPayMethod()
  15407. return nil
  15408. case creditusage.FieldStatus:
  15409. m.ClearStatus()
  15410. return nil
  15411. case creditusage.FieldOrganizationID:
  15412. m.ClearOrganizationID()
  15413. return nil
  15414. }
  15415. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  15416. }
  15417. // ResetField resets all changes in the mutation for the field with the given name.
  15418. // It returns an error if the field is not defined in the schema.
  15419. func (m *CreditUsageMutation) ResetField(name string) error {
  15420. switch name {
  15421. case creditusage.FieldCreatedAt:
  15422. m.ResetCreatedAt()
  15423. return nil
  15424. case creditusage.FieldUpdatedAt:
  15425. m.ResetUpdatedAt()
  15426. return nil
  15427. case creditusage.FieldDeletedAt:
  15428. m.ResetDeletedAt()
  15429. return nil
  15430. case creditusage.FieldUserID:
  15431. m.ResetUserID()
  15432. return nil
  15433. case creditusage.FieldNumber:
  15434. m.ResetNumber()
  15435. return nil
  15436. case creditusage.FieldPayNumber:
  15437. m.ResetPayNumber()
  15438. return nil
  15439. case creditusage.FieldBeforeNumber:
  15440. m.ResetBeforeNumber()
  15441. return nil
  15442. case creditusage.FieldAfterNumber:
  15443. m.ResetAfterNumber()
  15444. return nil
  15445. case creditusage.FieldPayMethod:
  15446. m.ResetPayMethod()
  15447. return nil
  15448. case creditusage.FieldStatus:
  15449. m.ResetStatus()
  15450. return nil
  15451. case creditusage.FieldNtype:
  15452. m.ResetNtype()
  15453. return nil
  15454. case creditusage.FieldTable:
  15455. m.ResetTable()
  15456. return nil
  15457. case creditusage.FieldOrganizationID:
  15458. m.ResetOrganizationID()
  15459. return nil
  15460. case creditusage.FieldNid:
  15461. m.ResetNid()
  15462. return nil
  15463. case creditusage.FieldReason:
  15464. m.ResetReason()
  15465. return nil
  15466. case creditusage.FieldOperator:
  15467. m.ResetOperator()
  15468. return nil
  15469. }
  15470. return fmt.Errorf("unknown CreditUsage field %s", name)
  15471. }
  15472. // AddedEdges returns all edge names that were set/added in this mutation.
  15473. func (m *CreditUsageMutation) AddedEdges() []string {
  15474. edges := make([]string, 0, 0)
  15475. return edges
  15476. }
  15477. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15478. // name in this mutation.
  15479. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  15480. return nil
  15481. }
  15482. // RemovedEdges returns all edge names that were removed in this mutation.
  15483. func (m *CreditUsageMutation) RemovedEdges() []string {
  15484. edges := make([]string, 0, 0)
  15485. return edges
  15486. }
  15487. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15488. // the given name in this mutation.
  15489. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  15490. return nil
  15491. }
  15492. // ClearedEdges returns all edge names that were cleared in this mutation.
  15493. func (m *CreditUsageMutation) ClearedEdges() []string {
  15494. edges := make([]string, 0, 0)
  15495. return edges
  15496. }
  15497. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15498. // was cleared in this mutation.
  15499. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  15500. return false
  15501. }
  15502. // ClearEdge clears the value of the edge with the given name. It returns an error
  15503. // if that edge is not defined in the schema.
  15504. func (m *CreditUsageMutation) ClearEdge(name string) error {
  15505. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  15506. }
  15507. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15508. // It returns an error if the edge is not defined in the schema.
  15509. func (m *CreditUsageMutation) ResetEdge(name string) error {
  15510. return fmt.Errorf("unknown CreditUsage edge %s", name)
  15511. }
  15512. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  15513. type EmployeeMutation struct {
  15514. config
  15515. op Op
  15516. typ string
  15517. id *uint64
  15518. created_at *time.Time
  15519. updated_at *time.Time
  15520. deleted_at *time.Time
  15521. title *string
  15522. avatar *string
  15523. tags *string
  15524. hire_count *int
  15525. addhire_count *int
  15526. service_count *int
  15527. addservice_count *int
  15528. achievement_count *int
  15529. addachievement_count *int
  15530. intro *string
  15531. estimate *string
  15532. skill *string
  15533. ability_type *string
  15534. scene *string
  15535. switch_in *string
  15536. video_url *string
  15537. organization_id *uint64
  15538. addorganization_id *int64
  15539. category_id *uint64
  15540. addcategory_id *int64
  15541. api_base *string
  15542. api_key *string
  15543. ai_info *string
  15544. is_vip *int
  15545. addis_vip *int
  15546. chat_url *string
  15547. clearedFields map[string]struct{}
  15548. em_work_experiences map[uint64]struct{}
  15549. removedem_work_experiences map[uint64]struct{}
  15550. clearedem_work_experiences bool
  15551. em_tutorial map[uint64]struct{}
  15552. removedem_tutorial map[uint64]struct{}
  15553. clearedem_tutorial bool
  15554. done bool
  15555. oldValue func(context.Context) (*Employee, error)
  15556. predicates []predicate.Employee
  15557. }
  15558. var _ ent.Mutation = (*EmployeeMutation)(nil)
  15559. // employeeOption allows management of the mutation configuration using functional options.
  15560. type employeeOption func(*EmployeeMutation)
  15561. // newEmployeeMutation creates new mutation for the Employee entity.
  15562. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  15563. m := &EmployeeMutation{
  15564. config: c,
  15565. op: op,
  15566. typ: TypeEmployee,
  15567. clearedFields: make(map[string]struct{}),
  15568. }
  15569. for _, opt := range opts {
  15570. opt(m)
  15571. }
  15572. return m
  15573. }
  15574. // withEmployeeID sets the ID field of the mutation.
  15575. func withEmployeeID(id uint64) employeeOption {
  15576. return func(m *EmployeeMutation) {
  15577. var (
  15578. err error
  15579. once sync.Once
  15580. value *Employee
  15581. )
  15582. m.oldValue = func(ctx context.Context) (*Employee, error) {
  15583. once.Do(func() {
  15584. if m.done {
  15585. err = errors.New("querying old values post mutation is not allowed")
  15586. } else {
  15587. value, err = m.Client().Employee.Get(ctx, id)
  15588. }
  15589. })
  15590. return value, err
  15591. }
  15592. m.id = &id
  15593. }
  15594. }
  15595. // withEmployee sets the old Employee of the mutation.
  15596. func withEmployee(node *Employee) employeeOption {
  15597. return func(m *EmployeeMutation) {
  15598. m.oldValue = func(context.Context) (*Employee, error) {
  15599. return node, nil
  15600. }
  15601. m.id = &node.ID
  15602. }
  15603. }
  15604. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15605. // executed in a transaction (ent.Tx), a transactional client is returned.
  15606. func (m EmployeeMutation) Client() *Client {
  15607. client := &Client{config: m.config}
  15608. client.init()
  15609. return client
  15610. }
  15611. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15612. // it returns an error otherwise.
  15613. func (m EmployeeMutation) Tx() (*Tx, error) {
  15614. if _, ok := m.driver.(*txDriver); !ok {
  15615. return nil, errors.New("ent: mutation is not running in a transaction")
  15616. }
  15617. tx := &Tx{config: m.config}
  15618. tx.init()
  15619. return tx, nil
  15620. }
  15621. // SetID sets the value of the id field. Note that this
  15622. // operation is only accepted on creation of Employee entities.
  15623. func (m *EmployeeMutation) SetID(id uint64) {
  15624. m.id = &id
  15625. }
  15626. // ID returns the ID value in the mutation. Note that the ID is only available
  15627. // if it was provided to the builder or after it was returned from the database.
  15628. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  15629. if m.id == nil {
  15630. return
  15631. }
  15632. return *m.id, true
  15633. }
  15634. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15635. // That means, if the mutation is applied within a transaction with an isolation level such
  15636. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15637. // or updated by the mutation.
  15638. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15639. switch {
  15640. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15641. id, exists := m.ID()
  15642. if exists {
  15643. return []uint64{id}, nil
  15644. }
  15645. fallthrough
  15646. case m.op.Is(OpUpdate | OpDelete):
  15647. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  15648. default:
  15649. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15650. }
  15651. }
  15652. // SetCreatedAt sets the "created_at" field.
  15653. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  15654. m.created_at = &t
  15655. }
  15656. // CreatedAt returns the value of the "created_at" field in the mutation.
  15657. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  15658. v := m.created_at
  15659. if v == nil {
  15660. return
  15661. }
  15662. return *v, true
  15663. }
  15664. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  15665. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15667. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15668. if !m.op.Is(OpUpdateOne) {
  15669. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15670. }
  15671. if m.id == nil || m.oldValue == nil {
  15672. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15673. }
  15674. oldValue, err := m.oldValue(ctx)
  15675. if err != nil {
  15676. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15677. }
  15678. return oldValue.CreatedAt, nil
  15679. }
  15680. // ResetCreatedAt resets all changes to the "created_at" field.
  15681. func (m *EmployeeMutation) ResetCreatedAt() {
  15682. m.created_at = nil
  15683. }
  15684. // SetUpdatedAt sets the "updated_at" field.
  15685. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  15686. m.updated_at = &t
  15687. }
  15688. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15689. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  15690. v := m.updated_at
  15691. if v == nil {
  15692. return
  15693. }
  15694. return *v, true
  15695. }
  15696. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  15697. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15699. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15700. if !m.op.Is(OpUpdateOne) {
  15701. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15702. }
  15703. if m.id == nil || m.oldValue == nil {
  15704. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15705. }
  15706. oldValue, err := m.oldValue(ctx)
  15707. if err != nil {
  15708. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15709. }
  15710. return oldValue.UpdatedAt, nil
  15711. }
  15712. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15713. func (m *EmployeeMutation) ResetUpdatedAt() {
  15714. m.updated_at = nil
  15715. }
  15716. // SetDeletedAt sets the "deleted_at" field.
  15717. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  15718. m.deleted_at = &t
  15719. }
  15720. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15721. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  15722. v := m.deleted_at
  15723. if v == nil {
  15724. return
  15725. }
  15726. return *v, true
  15727. }
  15728. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  15729. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15731. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15732. if !m.op.Is(OpUpdateOne) {
  15733. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15734. }
  15735. if m.id == nil || m.oldValue == nil {
  15736. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15737. }
  15738. oldValue, err := m.oldValue(ctx)
  15739. if err != nil {
  15740. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15741. }
  15742. return oldValue.DeletedAt, nil
  15743. }
  15744. // ClearDeletedAt clears the value of the "deleted_at" field.
  15745. func (m *EmployeeMutation) ClearDeletedAt() {
  15746. m.deleted_at = nil
  15747. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  15748. }
  15749. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15750. func (m *EmployeeMutation) DeletedAtCleared() bool {
  15751. _, ok := m.clearedFields[employee.FieldDeletedAt]
  15752. return ok
  15753. }
  15754. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15755. func (m *EmployeeMutation) ResetDeletedAt() {
  15756. m.deleted_at = nil
  15757. delete(m.clearedFields, employee.FieldDeletedAt)
  15758. }
  15759. // SetTitle sets the "title" field.
  15760. func (m *EmployeeMutation) SetTitle(s string) {
  15761. m.title = &s
  15762. }
  15763. // Title returns the value of the "title" field in the mutation.
  15764. func (m *EmployeeMutation) Title() (r string, exists bool) {
  15765. v := m.title
  15766. if v == nil {
  15767. return
  15768. }
  15769. return *v, true
  15770. }
  15771. // OldTitle returns the old "title" field's value of the Employee entity.
  15772. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15774. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  15775. if !m.op.Is(OpUpdateOne) {
  15776. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15777. }
  15778. if m.id == nil || m.oldValue == nil {
  15779. return v, errors.New("OldTitle requires an ID field in the mutation")
  15780. }
  15781. oldValue, err := m.oldValue(ctx)
  15782. if err != nil {
  15783. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15784. }
  15785. return oldValue.Title, nil
  15786. }
  15787. // ResetTitle resets all changes to the "title" field.
  15788. func (m *EmployeeMutation) ResetTitle() {
  15789. m.title = nil
  15790. }
  15791. // SetAvatar sets the "avatar" field.
  15792. func (m *EmployeeMutation) SetAvatar(s string) {
  15793. m.avatar = &s
  15794. }
  15795. // Avatar returns the value of the "avatar" field in the mutation.
  15796. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  15797. v := m.avatar
  15798. if v == nil {
  15799. return
  15800. }
  15801. return *v, true
  15802. }
  15803. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  15804. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15806. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  15807. if !m.op.Is(OpUpdateOne) {
  15808. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  15809. }
  15810. if m.id == nil || m.oldValue == nil {
  15811. return v, errors.New("OldAvatar requires an ID field in the mutation")
  15812. }
  15813. oldValue, err := m.oldValue(ctx)
  15814. if err != nil {
  15815. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  15816. }
  15817. return oldValue.Avatar, nil
  15818. }
  15819. // ResetAvatar resets all changes to the "avatar" field.
  15820. func (m *EmployeeMutation) ResetAvatar() {
  15821. m.avatar = nil
  15822. }
  15823. // SetTags sets the "tags" field.
  15824. func (m *EmployeeMutation) SetTags(s string) {
  15825. m.tags = &s
  15826. }
  15827. // Tags returns the value of the "tags" field in the mutation.
  15828. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  15829. v := m.tags
  15830. if v == nil {
  15831. return
  15832. }
  15833. return *v, true
  15834. }
  15835. // OldTags returns the old "tags" field's value of the Employee entity.
  15836. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15838. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  15839. if !m.op.Is(OpUpdateOne) {
  15840. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  15841. }
  15842. if m.id == nil || m.oldValue == nil {
  15843. return v, errors.New("OldTags requires an ID field in the mutation")
  15844. }
  15845. oldValue, err := m.oldValue(ctx)
  15846. if err != nil {
  15847. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  15848. }
  15849. return oldValue.Tags, nil
  15850. }
  15851. // ResetTags resets all changes to the "tags" field.
  15852. func (m *EmployeeMutation) ResetTags() {
  15853. m.tags = nil
  15854. }
  15855. // SetHireCount sets the "hire_count" field.
  15856. func (m *EmployeeMutation) SetHireCount(i int) {
  15857. m.hire_count = &i
  15858. m.addhire_count = nil
  15859. }
  15860. // HireCount returns the value of the "hire_count" field in the mutation.
  15861. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  15862. v := m.hire_count
  15863. if v == nil {
  15864. return
  15865. }
  15866. return *v, true
  15867. }
  15868. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  15869. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15871. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  15872. if !m.op.Is(OpUpdateOne) {
  15873. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  15874. }
  15875. if m.id == nil || m.oldValue == nil {
  15876. return v, errors.New("OldHireCount requires an ID field in the mutation")
  15877. }
  15878. oldValue, err := m.oldValue(ctx)
  15879. if err != nil {
  15880. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  15881. }
  15882. return oldValue.HireCount, nil
  15883. }
  15884. // AddHireCount adds i to the "hire_count" field.
  15885. func (m *EmployeeMutation) AddHireCount(i int) {
  15886. if m.addhire_count != nil {
  15887. *m.addhire_count += i
  15888. } else {
  15889. m.addhire_count = &i
  15890. }
  15891. }
  15892. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  15893. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  15894. v := m.addhire_count
  15895. if v == nil {
  15896. return
  15897. }
  15898. return *v, true
  15899. }
  15900. // ResetHireCount resets all changes to the "hire_count" field.
  15901. func (m *EmployeeMutation) ResetHireCount() {
  15902. m.hire_count = nil
  15903. m.addhire_count = nil
  15904. }
  15905. // SetServiceCount sets the "service_count" field.
  15906. func (m *EmployeeMutation) SetServiceCount(i int) {
  15907. m.service_count = &i
  15908. m.addservice_count = nil
  15909. }
  15910. // ServiceCount returns the value of the "service_count" field in the mutation.
  15911. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  15912. v := m.service_count
  15913. if v == nil {
  15914. return
  15915. }
  15916. return *v, true
  15917. }
  15918. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  15919. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15921. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  15922. if !m.op.Is(OpUpdateOne) {
  15923. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  15924. }
  15925. if m.id == nil || m.oldValue == nil {
  15926. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  15927. }
  15928. oldValue, err := m.oldValue(ctx)
  15929. if err != nil {
  15930. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  15931. }
  15932. return oldValue.ServiceCount, nil
  15933. }
  15934. // AddServiceCount adds i to the "service_count" field.
  15935. func (m *EmployeeMutation) AddServiceCount(i int) {
  15936. if m.addservice_count != nil {
  15937. *m.addservice_count += i
  15938. } else {
  15939. m.addservice_count = &i
  15940. }
  15941. }
  15942. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  15943. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  15944. v := m.addservice_count
  15945. if v == nil {
  15946. return
  15947. }
  15948. return *v, true
  15949. }
  15950. // ResetServiceCount resets all changes to the "service_count" field.
  15951. func (m *EmployeeMutation) ResetServiceCount() {
  15952. m.service_count = nil
  15953. m.addservice_count = nil
  15954. }
  15955. // SetAchievementCount sets the "achievement_count" field.
  15956. func (m *EmployeeMutation) SetAchievementCount(i int) {
  15957. m.achievement_count = &i
  15958. m.addachievement_count = nil
  15959. }
  15960. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  15961. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  15962. v := m.achievement_count
  15963. if v == nil {
  15964. return
  15965. }
  15966. return *v, true
  15967. }
  15968. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  15969. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15971. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  15972. if !m.op.Is(OpUpdateOne) {
  15973. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  15974. }
  15975. if m.id == nil || m.oldValue == nil {
  15976. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  15977. }
  15978. oldValue, err := m.oldValue(ctx)
  15979. if err != nil {
  15980. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  15981. }
  15982. return oldValue.AchievementCount, nil
  15983. }
  15984. // AddAchievementCount adds i to the "achievement_count" field.
  15985. func (m *EmployeeMutation) AddAchievementCount(i int) {
  15986. if m.addachievement_count != nil {
  15987. *m.addachievement_count += i
  15988. } else {
  15989. m.addachievement_count = &i
  15990. }
  15991. }
  15992. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  15993. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  15994. v := m.addachievement_count
  15995. if v == nil {
  15996. return
  15997. }
  15998. return *v, true
  15999. }
  16000. // ResetAchievementCount resets all changes to the "achievement_count" field.
  16001. func (m *EmployeeMutation) ResetAchievementCount() {
  16002. m.achievement_count = nil
  16003. m.addachievement_count = nil
  16004. }
  16005. // SetIntro sets the "intro" field.
  16006. func (m *EmployeeMutation) SetIntro(s string) {
  16007. m.intro = &s
  16008. }
  16009. // Intro returns the value of the "intro" field in the mutation.
  16010. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  16011. v := m.intro
  16012. if v == nil {
  16013. return
  16014. }
  16015. return *v, true
  16016. }
  16017. // OldIntro returns the old "intro" field's value of the Employee entity.
  16018. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16020. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  16021. if !m.op.Is(OpUpdateOne) {
  16022. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  16023. }
  16024. if m.id == nil || m.oldValue == nil {
  16025. return v, errors.New("OldIntro requires an ID field in the mutation")
  16026. }
  16027. oldValue, err := m.oldValue(ctx)
  16028. if err != nil {
  16029. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  16030. }
  16031. return oldValue.Intro, nil
  16032. }
  16033. // ResetIntro resets all changes to the "intro" field.
  16034. func (m *EmployeeMutation) ResetIntro() {
  16035. m.intro = nil
  16036. }
  16037. // SetEstimate sets the "estimate" field.
  16038. func (m *EmployeeMutation) SetEstimate(s string) {
  16039. m.estimate = &s
  16040. }
  16041. // Estimate returns the value of the "estimate" field in the mutation.
  16042. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  16043. v := m.estimate
  16044. if v == nil {
  16045. return
  16046. }
  16047. return *v, true
  16048. }
  16049. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  16050. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16052. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  16053. if !m.op.Is(OpUpdateOne) {
  16054. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  16055. }
  16056. if m.id == nil || m.oldValue == nil {
  16057. return v, errors.New("OldEstimate requires an ID field in the mutation")
  16058. }
  16059. oldValue, err := m.oldValue(ctx)
  16060. if err != nil {
  16061. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  16062. }
  16063. return oldValue.Estimate, nil
  16064. }
  16065. // ResetEstimate resets all changes to the "estimate" field.
  16066. func (m *EmployeeMutation) ResetEstimate() {
  16067. m.estimate = nil
  16068. }
  16069. // SetSkill sets the "skill" field.
  16070. func (m *EmployeeMutation) SetSkill(s string) {
  16071. m.skill = &s
  16072. }
  16073. // Skill returns the value of the "skill" field in the mutation.
  16074. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  16075. v := m.skill
  16076. if v == nil {
  16077. return
  16078. }
  16079. return *v, true
  16080. }
  16081. // OldSkill returns the old "skill" field's value of the Employee entity.
  16082. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16084. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  16085. if !m.op.Is(OpUpdateOne) {
  16086. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  16087. }
  16088. if m.id == nil || m.oldValue == nil {
  16089. return v, errors.New("OldSkill requires an ID field in the mutation")
  16090. }
  16091. oldValue, err := m.oldValue(ctx)
  16092. if err != nil {
  16093. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  16094. }
  16095. return oldValue.Skill, nil
  16096. }
  16097. // ResetSkill resets all changes to the "skill" field.
  16098. func (m *EmployeeMutation) ResetSkill() {
  16099. m.skill = nil
  16100. }
  16101. // SetAbilityType sets the "ability_type" field.
  16102. func (m *EmployeeMutation) SetAbilityType(s string) {
  16103. m.ability_type = &s
  16104. }
  16105. // AbilityType returns the value of the "ability_type" field in the mutation.
  16106. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  16107. v := m.ability_type
  16108. if v == nil {
  16109. return
  16110. }
  16111. return *v, true
  16112. }
  16113. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  16114. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16116. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  16117. if !m.op.Is(OpUpdateOne) {
  16118. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  16119. }
  16120. if m.id == nil || m.oldValue == nil {
  16121. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  16122. }
  16123. oldValue, err := m.oldValue(ctx)
  16124. if err != nil {
  16125. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  16126. }
  16127. return oldValue.AbilityType, nil
  16128. }
  16129. // ResetAbilityType resets all changes to the "ability_type" field.
  16130. func (m *EmployeeMutation) ResetAbilityType() {
  16131. m.ability_type = nil
  16132. }
  16133. // SetScene sets the "scene" field.
  16134. func (m *EmployeeMutation) SetScene(s string) {
  16135. m.scene = &s
  16136. }
  16137. // Scene returns the value of the "scene" field in the mutation.
  16138. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  16139. v := m.scene
  16140. if v == nil {
  16141. return
  16142. }
  16143. return *v, true
  16144. }
  16145. // OldScene returns the old "scene" field's value of the Employee entity.
  16146. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16148. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  16149. if !m.op.Is(OpUpdateOne) {
  16150. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  16151. }
  16152. if m.id == nil || m.oldValue == nil {
  16153. return v, errors.New("OldScene requires an ID field in the mutation")
  16154. }
  16155. oldValue, err := m.oldValue(ctx)
  16156. if err != nil {
  16157. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  16158. }
  16159. return oldValue.Scene, nil
  16160. }
  16161. // ResetScene resets all changes to the "scene" field.
  16162. func (m *EmployeeMutation) ResetScene() {
  16163. m.scene = nil
  16164. }
  16165. // SetSwitchIn sets the "switch_in" field.
  16166. func (m *EmployeeMutation) SetSwitchIn(s string) {
  16167. m.switch_in = &s
  16168. }
  16169. // SwitchIn returns the value of the "switch_in" field in the mutation.
  16170. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  16171. v := m.switch_in
  16172. if v == nil {
  16173. return
  16174. }
  16175. return *v, true
  16176. }
  16177. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  16178. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16180. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  16181. if !m.op.Is(OpUpdateOne) {
  16182. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  16183. }
  16184. if m.id == nil || m.oldValue == nil {
  16185. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  16186. }
  16187. oldValue, err := m.oldValue(ctx)
  16188. if err != nil {
  16189. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  16190. }
  16191. return oldValue.SwitchIn, nil
  16192. }
  16193. // ResetSwitchIn resets all changes to the "switch_in" field.
  16194. func (m *EmployeeMutation) ResetSwitchIn() {
  16195. m.switch_in = nil
  16196. }
  16197. // SetVideoURL sets the "video_url" field.
  16198. func (m *EmployeeMutation) SetVideoURL(s string) {
  16199. m.video_url = &s
  16200. }
  16201. // VideoURL returns the value of the "video_url" field in the mutation.
  16202. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  16203. v := m.video_url
  16204. if v == nil {
  16205. return
  16206. }
  16207. return *v, true
  16208. }
  16209. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  16210. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16212. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  16213. if !m.op.Is(OpUpdateOne) {
  16214. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  16215. }
  16216. if m.id == nil || m.oldValue == nil {
  16217. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  16218. }
  16219. oldValue, err := m.oldValue(ctx)
  16220. if err != nil {
  16221. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  16222. }
  16223. return oldValue.VideoURL, nil
  16224. }
  16225. // ResetVideoURL resets all changes to the "video_url" field.
  16226. func (m *EmployeeMutation) ResetVideoURL() {
  16227. m.video_url = nil
  16228. }
  16229. // SetOrganizationID sets the "organization_id" field.
  16230. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  16231. m.organization_id = &u
  16232. m.addorganization_id = nil
  16233. }
  16234. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16235. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  16236. v := m.organization_id
  16237. if v == nil {
  16238. return
  16239. }
  16240. return *v, true
  16241. }
  16242. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  16243. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16245. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16246. if !m.op.Is(OpUpdateOne) {
  16247. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16248. }
  16249. if m.id == nil || m.oldValue == nil {
  16250. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16251. }
  16252. oldValue, err := m.oldValue(ctx)
  16253. if err != nil {
  16254. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16255. }
  16256. return oldValue.OrganizationID, nil
  16257. }
  16258. // AddOrganizationID adds u to the "organization_id" field.
  16259. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  16260. if m.addorganization_id != nil {
  16261. *m.addorganization_id += u
  16262. } else {
  16263. m.addorganization_id = &u
  16264. }
  16265. }
  16266. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16267. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  16268. v := m.addorganization_id
  16269. if v == nil {
  16270. return
  16271. }
  16272. return *v, true
  16273. }
  16274. // ResetOrganizationID resets all changes to the "organization_id" field.
  16275. func (m *EmployeeMutation) ResetOrganizationID() {
  16276. m.organization_id = nil
  16277. m.addorganization_id = nil
  16278. }
  16279. // SetCategoryID sets the "category_id" field.
  16280. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  16281. m.category_id = &u
  16282. m.addcategory_id = nil
  16283. }
  16284. // CategoryID returns the value of the "category_id" field in the mutation.
  16285. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  16286. v := m.category_id
  16287. if v == nil {
  16288. return
  16289. }
  16290. return *v, true
  16291. }
  16292. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  16293. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16295. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  16296. if !m.op.Is(OpUpdateOne) {
  16297. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  16298. }
  16299. if m.id == nil || m.oldValue == nil {
  16300. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  16301. }
  16302. oldValue, err := m.oldValue(ctx)
  16303. if err != nil {
  16304. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  16305. }
  16306. return oldValue.CategoryID, nil
  16307. }
  16308. // AddCategoryID adds u to the "category_id" field.
  16309. func (m *EmployeeMutation) AddCategoryID(u int64) {
  16310. if m.addcategory_id != nil {
  16311. *m.addcategory_id += u
  16312. } else {
  16313. m.addcategory_id = &u
  16314. }
  16315. }
  16316. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  16317. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  16318. v := m.addcategory_id
  16319. if v == nil {
  16320. return
  16321. }
  16322. return *v, true
  16323. }
  16324. // ResetCategoryID resets all changes to the "category_id" field.
  16325. func (m *EmployeeMutation) ResetCategoryID() {
  16326. m.category_id = nil
  16327. m.addcategory_id = nil
  16328. }
  16329. // SetAPIBase sets the "api_base" field.
  16330. func (m *EmployeeMutation) SetAPIBase(s string) {
  16331. m.api_base = &s
  16332. }
  16333. // APIBase returns the value of the "api_base" field in the mutation.
  16334. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  16335. v := m.api_base
  16336. if v == nil {
  16337. return
  16338. }
  16339. return *v, true
  16340. }
  16341. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  16342. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16344. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  16345. if !m.op.Is(OpUpdateOne) {
  16346. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  16347. }
  16348. if m.id == nil || m.oldValue == nil {
  16349. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  16350. }
  16351. oldValue, err := m.oldValue(ctx)
  16352. if err != nil {
  16353. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  16354. }
  16355. return oldValue.APIBase, nil
  16356. }
  16357. // ResetAPIBase resets all changes to the "api_base" field.
  16358. func (m *EmployeeMutation) ResetAPIBase() {
  16359. m.api_base = nil
  16360. }
  16361. // SetAPIKey sets the "api_key" field.
  16362. func (m *EmployeeMutation) SetAPIKey(s string) {
  16363. m.api_key = &s
  16364. }
  16365. // APIKey returns the value of the "api_key" field in the mutation.
  16366. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  16367. v := m.api_key
  16368. if v == nil {
  16369. return
  16370. }
  16371. return *v, true
  16372. }
  16373. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  16374. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16376. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  16377. if !m.op.Is(OpUpdateOne) {
  16378. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  16379. }
  16380. if m.id == nil || m.oldValue == nil {
  16381. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  16382. }
  16383. oldValue, err := m.oldValue(ctx)
  16384. if err != nil {
  16385. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  16386. }
  16387. return oldValue.APIKey, nil
  16388. }
  16389. // ResetAPIKey resets all changes to the "api_key" field.
  16390. func (m *EmployeeMutation) ResetAPIKey() {
  16391. m.api_key = nil
  16392. }
  16393. // SetAiInfo sets the "ai_info" field.
  16394. func (m *EmployeeMutation) SetAiInfo(s string) {
  16395. m.ai_info = &s
  16396. }
  16397. // AiInfo returns the value of the "ai_info" field in the mutation.
  16398. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  16399. v := m.ai_info
  16400. if v == nil {
  16401. return
  16402. }
  16403. return *v, true
  16404. }
  16405. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  16406. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16408. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  16409. if !m.op.Is(OpUpdateOne) {
  16410. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  16411. }
  16412. if m.id == nil || m.oldValue == nil {
  16413. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  16414. }
  16415. oldValue, err := m.oldValue(ctx)
  16416. if err != nil {
  16417. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  16418. }
  16419. return oldValue.AiInfo, nil
  16420. }
  16421. // ClearAiInfo clears the value of the "ai_info" field.
  16422. func (m *EmployeeMutation) ClearAiInfo() {
  16423. m.ai_info = nil
  16424. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  16425. }
  16426. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  16427. func (m *EmployeeMutation) AiInfoCleared() bool {
  16428. _, ok := m.clearedFields[employee.FieldAiInfo]
  16429. return ok
  16430. }
  16431. // ResetAiInfo resets all changes to the "ai_info" field.
  16432. func (m *EmployeeMutation) ResetAiInfo() {
  16433. m.ai_info = nil
  16434. delete(m.clearedFields, employee.FieldAiInfo)
  16435. }
  16436. // SetIsVip sets the "is_vip" field.
  16437. func (m *EmployeeMutation) SetIsVip(i int) {
  16438. m.is_vip = &i
  16439. m.addis_vip = nil
  16440. }
  16441. // IsVip returns the value of the "is_vip" field in the mutation.
  16442. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  16443. v := m.is_vip
  16444. if v == nil {
  16445. return
  16446. }
  16447. return *v, true
  16448. }
  16449. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  16450. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16452. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  16453. if !m.op.Is(OpUpdateOne) {
  16454. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  16455. }
  16456. if m.id == nil || m.oldValue == nil {
  16457. return v, errors.New("OldIsVip requires an ID field in the mutation")
  16458. }
  16459. oldValue, err := m.oldValue(ctx)
  16460. if err != nil {
  16461. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  16462. }
  16463. return oldValue.IsVip, nil
  16464. }
  16465. // AddIsVip adds i to the "is_vip" field.
  16466. func (m *EmployeeMutation) AddIsVip(i int) {
  16467. if m.addis_vip != nil {
  16468. *m.addis_vip += i
  16469. } else {
  16470. m.addis_vip = &i
  16471. }
  16472. }
  16473. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  16474. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  16475. v := m.addis_vip
  16476. if v == nil {
  16477. return
  16478. }
  16479. return *v, true
  16480. }
  16481. // ResetIsVip resets all changes to the "is_vip" field.
  16482. func (m *EmployeeMutation) ResetIsVip() {
  16483. m.is_vip = nil
  16484. m.addis_vip = nil
  16485. }
  16486. // SetChatURL sets the "chat_url" field.
  16487. func (m *EmployeeMutation) SetChatURL(s string) {
  16488. m.chat_url = &s
  16489. }
  16490. // ChatURL returns the value of the "chat_url" field in the mutation.
  16491. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  16492. v := m.chat_url
  16493. if v == nil {
  16494. return
  16495. }
  16496. return *v, true
  16497. }
  16498. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  16499. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16501. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  16502. if !m.op.Is(OpUpdateOne) {
  16503. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  16504. }
  16505. if m.id == nil || m.oldValue == nil {
  16506. return v, errors.New("OldChatURL requires an ID field in the mutation")
  16507. }
  16508. oldValue, err := m.oldValue(ctx)
  16509. if err != nil {
  16510. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  16511. }
  16512. return oldValue.ChatURL, nil
  16513. }
  16514. // ResetChatURL resets all changes to the "chat_url" field.
  16515. func (m *EmployeeMutation) ResetChatURL() {
  16516. m.chat_url = nil
  16517. }
  16518. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  16519. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  16520. if m.em_work_experiences == nil {
  16521. m.em_work_experiences = make(map[uint64]struct{})
  16522. }
  16523. for i := range ids {
  16524. m.em_work_experiences[ids[i]] = struct{}{}
  16525. }
  16526. }
  16527. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  16528. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  16529. m.clearedem_work_experiences = true
  16530. }
  16531. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  16532. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  16533. return m.clearedem_work_experiences
  16534. }
  16535. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  16536. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  16537. if m.removedem_work_experiences == nil {
  16538. m.removedem_work_experiences = make(map[uint64]struct{})
  16539. }
  16540. for i := range ids {
  16541. delete(m.em_work_experiences, ids[i])
  16542. m.removedem_work_experiences[ids[i]] = struct{}{}
  16543. }
  16544. }
  16545. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  16546. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  16547. for id := range m.removedem_work_experiences {
  16548. ids = append(ids, id)
  16549. }
  16550. return
  16551. }
  16552. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  16553. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  16554. for id := range m.em_work_experiences {
  16555. ids = append(ids, id)
  16556. }
  16557. return
  16558. }
  16559. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  16560. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  16561. m.em_work_experiences = nil
  16562. m.clearedem_work_experiences = false
  16563. m.removedem_work_experiences = nil
  16564. }
  16565. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  16566. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  16567. if m.em_tutorial == nil {
  16568. m.em_tutorial = make(map[uint64]struct{})
  16569. }
  16570. for i := range ids {
  16571. m.em_tutorial[ids[i]] = struct{}{}
  16572. }
  16573. }
  16574. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  16575. func (m *EmployeeMutation) ClearEmTutorial() {
  16576. m.clearedem_tutorial = true
  16577. }
  16578. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  16579. func (m *EmployeeMutation) EmTutorialCleared() bool {
  16580. return m.clearedem_tutorial
  16581. }
  16582. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  16583. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  16584. if m.removedem_tutorial == nil {
  16585. m.removedem_tutorial = make(map[uint64]struct{})
  16586. }
  16587. for i := range ids {
  16588. delete(m.em_tutorial, ids[i])
  16589. m.removedem_tutorial[ids[i]] = struct{}{}
  16590. }
  16591. }
  16592. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  16593. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  16594. for id := range m.removedem_tutorial {
  16595. ids = append(ids, id)
  16596. }
  16597. return
  16598. }
  16599. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  16600. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  16601. for id := range m.em_tutorial {
  16602. ids = append(ids, id)
  16603. }
  16604. return
  16605. }
  16606. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  16607. func (m *EmployeeMutation) ResetEmTutorial() {
  16608. m.em_tutorial = nil
  16609. m.clearedem_tutorial = false
  16610. m.removedem_tutorial = nil
  16611. }
  16612. // Where appends a list predicates to the EmployeeMutation builder.
  16613. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  16614. m.predicates = append(m.predicates, ps...)
  16615. }
  16616. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  16617. // users can use type-assertion to append predicates that do not depend on any generated package.
  16618. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  16619. p := make([]predicate.Employee, len(ps))
  16620. for i := range ps {
  16621. p[i] = ps[i]
  16622. }
  16623. m.Where(p...)
  16624. }
  16625. // Op returns the operation name.
  16626. func (m *EmployeeMutation) Op() Op {
  16627. return m.op
  16628. }
  16629. // SetOp allows setting the mutation operation.
  16630. func (m *EmployeeMutation) SetOp(op Op) {
  16631. m.op = op
  16632. }
  16633. // Type returns the node type of this mutation (Employee).
  16634. func (m *EmployeeMutation) Type() string {
  16635. return m.typ
  16636. }
  16637. // Fields returns all fields that were changed during this mutation. Note that in
  16638. // order to get all numeric fields that were incremented/decremented, call
  16639. // AddedFields().
  16640. func (m *EmployeeMutation) Fields() []string {
  16641. fields := make([]string, 0, 23)
  16642. if m.created_at != nil {
  16643. fields = append(fields, employee.FieldCreatedAt)
  16644. }
  16645. if m.updated_at != nil {
  16646. fields = append(fields, employee.FieldUpdatedAt)
  16647. }
  16648. if m.deleted_at != nil {
  16649. fields = append(fields, employee.FieldDeletedAt)
  16650. }
  16651. if m.title != nil {
  16652. fields = append(fields, employee.FieldTitle)
  16653. }
  16654. if m.avatar != nil {
  16655. fields = append(fields, employee.FieldAvatar)
  16656. }
  16657. if m.tags != nil {
  16658. fields = append(fields, employee.FieldTags)
  16659. }
  16660. if m.hire_count != nil {
  16661. fields = append(fields, employee.FieldHireCount)
  16662. }
  16663. if m.service_count != nil {
  16664. fields = append(fields, employee.FieldServiceCount)
  16665. }
  16666. if m.achievement_count != nil {
  16667. fields = append(fields, employee.FieldAchievementCount)
  16668. }
  16669. if m.intro != nil {
  16670. fields = append(fields, employee.FieldIntro)
  16671. }
  16672. if m.estimate != nil {
  16673. fields = append(fields, employee.FieldEstimate)
  16674. }
  16675. if m.skill != nil {
  16676. fields = append(fields, employee.FieldSkill)
  16677. }
  16678. if m.ability_type != nil {
  16679. fields = append(fields, employee.FieldAbilityType)
  16680. }
  16681. if m.scene != nil {
  16682. fields = append(fields, employee.FieldScene)
  16683. }
  16684. if m.switch_in != nil {
  16685. fields = append(fields, employee.FieldSwitchIn)
  16686. }
  16687. if m.video_url != nil {
  16688. fields = append(fields, employee.FieldVideoURL)
  16689. }
  16690. if m.organization_id != nil {
  16691. fields = append(fields, employee.FieldOrganizationID)
  16692. }
  16693. if m.category_id != nil {
  16694. fields = append(fields, employee.FieldCategoryID)
  16695. }
  16696. if m.api_base != nil {
  16697. fields = append(fields, employee.FieldAPIBase)
  16698. }
  16699. if m.api_key != nil {
  16700. fields = append(fields, employee.FieldAPIKey)
  16701. }
  16702. if m.ai_info != nil {
  16703. fields = append(fields, employee.FieldAiInfo)
  16704. }
  16705. if m.is_vip != nil {
  16706. fields = append(fields, employee.FieldIsVip)
  16707. }
  16708. if m.chat_url != nil {
  16709. fields = append(fields, employee.FieldChatURL)
  16710. }
  16711. return fields
  16712. }
  16713. // Field returns the value of a field with the given name. The second boolean
  16714. // return value indicates that this field was not set, or was not defined in the
  16715. // schema.
  16716. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  16717. switch name {
  16718. case employee.FieldCreatedAt:
  16719. return m.CreatedAt()
  16720. case employee.FieldUpdatedAt:
  16721. return m.UpdatedAt()
  16722. case employee.FieldDeletedAt:
  16723. return m.DeletedAt()
  16724. case employee.FieldTitle:
  16725. return m.Title()
  16726. case employee.FieldAvatar:
  16727. return m.Avatar()
  16728. case employee.FieldTags:
  16729. return m.Tags()
  16730. case employee.FieldHireCount:
  16731. return m.HireCount()
  16732. case employee.FieldServiceCount:
  16733. return m.ServiceCount()
  16734. case employee.FieldAchievementCount:
  16735. return m.AchievementCount()
  16736. case employee.FieldIntro:
  16737. return m.Intro()
  16738. case employee.FieldEstimate:
  16739. return m.Estimate()
  16740. case employee.FieldSkill:
  16741. return m.Skill()
  16742. case employee.FieldAbilityType:
  16743. return m.AbilityType()
  16744. case employee.FieldScene:
  16745. return m.Scene()
  16746. case employee.FieldSwitchIn:
  16747. return m.SwitchIn()
  16748. case employee.FieldVideoURL:
  16749. return m.VideoURL()
  16750. case employee.FieldOrganizationID:
  16751. return m.OrganizationID()
  16752. case employee.FieldCategoryID:
  16753. return m.CategoryID()
  16754. case employee.FieldAPIBase:
  16755. return m.APIBase()
  16756. case employee.FieldAPIKey:
  16757. return m.APIKey()
  16758. case employee.FieldAiInfo:
  16759. return m.AiInfo()
  16760. case employee.FieldIsVip:
  16761. return m.IsVip()
  16762. case employee.FieldChatURL:
  16763. return m.ChatURL()
  16764. }
  16765. return nil, false
  16766. }
  16767. // OldField returns the old value of the field from the database. An error is
  16768. // returned if the mutation operation is not UpdateOne, or the query to the
  16769. // database failed.
  16770. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16771. switch name {
  16772. case employee.FieldCreatedAt:
  16773. return m.OldCreatedAt(ctx)
  16774. case employee.FieldUpdatedAt:
  16775. return m.OldUpdatedAt(ctx)
  16776. case employee.FieldDeletedAt:
  16777. return m.OldDeletedAt(ctx)
  16778. case employee.FieldTitle:
  16779. return m.OldTitle(ctx)
  16780. case employee.FieldAvatar:
  16781. return m.OldAvatar(ctx)
  16782. case employee.FieldTags:
  16783. return m.OldTags(ctx)
  16784. case employee.FieldHireCount:
  16785. return m.OldHireCount(ctx)
  16786. case employee.FieldServiceCount:
  16787. return m.OldServiceCount(ctx)
  16788. case employee.FieldAchievementCount:
  16789. return m.OldAchievementCount(ctx)
  16790. case employee.FieldIntro:
  16791. return m.OldIntro(ctx)
  16792. case employee.FieldEstimate:
  16793. return m.OldEstimate(ctx)
  16794. case employee.FieldSkill:
  16795. return m.OldSkill(ctx)
  16796. case employee.FieldAbilityType:
  16797. return m.OldAbilityType(ctx)
  16798. case employee.FieldScene:
  16799. return m.OldScene(ctx)
  16800. case employee.FieldSwitchIn:
  16801. return m.OldSwitchIn(ctx)
  16802. case employee.FieldVideoURL:
  16803. return m.OldVideoURL(ctx)
  16804. case employee.FieldOrganizationID:
  16805. return m.OldOrganizationID(ctx)
  16806. case employee.FieldCategoryID:
  16807. return m.OldCategoryID(ctx)
  16808. case employee.FieldAPIBase:
  16809. return m.OldAPIBase(ctx)
  16810. case employee.FieldAPIKey:
  16811. return m.OldAPIKey(ctx)
  16812. case employee.FieldAiInfo:
  16813. return m.OldAiInfo(ctx)
  16814. case employee.FieldIsVip:
  16815. return m.OldIsVip(ctx)
  16816. case employee.FieldChatURL:
  16817. return m.OldChatURL(ctx)
  16818. }
  16819. return nil, fmt.Errorf("unknown Employee field %s", name)
  16820. }
  16821. // SetField sets the value of a field with the given name. It returns an error if
  16822. // the field is not defined in the schema, or if the type mismatched the field
  16823. // type.
  16824. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  16825. switch name {
  16826. case employee.FieldCreatedAt:
  16827. v, ok := value.(time.Time)
  16828. if !ok {
  16829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16830. }
  16831. m.SetCreatedAt(v)
  16832. return nil
  16833. case employee.FieldUpdatedAt:
  16834. v, ok := value.(time.Time)
  16835. if !ok {
  16836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16837. }
  16838. m.SetUpdatedAt(v)
  16839. return nil
  16840. case employee.FieldDeletedAt:
  16841. v, ok := value.(time.Time)
  16842. if !ok {
  16843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16844. }
  16845. m.SetDeletedAt(v)
  16846. return nil
  16847. case employee.FieldTitle:
  16848. v, ok := value.(string)
  16849. if !ok {
  16850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16851. }
  16852. m.SetTitle(v)
  16853. return nil
  16854. case employee.FieldAvatar:
  16855. v, ok := value.(string)
  16856. if !ok {
  16857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16858. }
  16859. m.SetAvatar(v)
  16860. return nil
  16861. case employee.FieldTags:
  16862. v, ok := value.(string)
  16863. if !ok {
  16864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16865. }
  16866. m.SetTags(v)
  16867. return nil
  16868. case employee.FieldHireCount:
  16869. v, ok := value.(int)
  16870. if !ok {
  16871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16872. }
  16873. m.SetHireCount(v)
  16874. return nil
  16875. case employee.FieldServiceCount:
  16876. v, ok := value.(int)
  16877. if !ok {
  16878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16879. }
  16880. m.SetServiceCount(v)
  16881. return nil
  16882. case employee.FieldAchievementCount:
  16883. v, ok := value.(int)
  16884. if !ok {
  16885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16886. }
  16887. m.SetAchievementCount(v)
  16888. return nil
  16889. case employee.FieldIntro:
  16890. v, ok := value.(string)
  16891. if !ok {
  16892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16893. }
  16894. m.SetIntro(v)
  16895. return nil
  16896. case employee.FieldEstimate:
  16897. v, ok := value.(string)
  16898. if !ok {
  16899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16900. }
  16901. m.SetEstimate(v)
  16902. return nil
  16903. case employee.FieldSkill:
  16904. v, ok := value.(string)
  16905. if !ok {
  16906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16907. }
  16908. m.SetSkill(v)
  16909. return nil
  16910. case employee.FieldAbilityType:
  16911. v, ok := value.(string)
  16912. if !ok {
  16913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16914. }
  16915. m.SetAbilityType(v)
  16916. return nil
  16917. case employee.FieldScene:
  16918. v, ok := value.(string)
  16919. if !ok {
  16920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16921. }
  16922. m.SetScene(v)
  16923. return nil
  16924. case employee.FieldSwitchIn:
  16925. v, ok := value.(string)
  16926. if !ok {
  16927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16928. }
  16929. m.SetSwitchIn(v)
  16930. return nil
  16931. case employee.FieldVideoURL:
  16932. v, ok := value.(string)
  16933. if !ok {
  16934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16935. }
  16936. m.SetVideoURL(v)
  16937. return nil
  16938. case employee.FieldOrganizationID:
  16939. v, ok := value.(uint64)
  16940. if !ok {
  16941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16942. }
  16943. m.SetOrganizationID(v)
  16944. return nil
  16945. case employee.FieldCategoryID:
  16946. v, ok := value.(uint64)
  16947. if !ok {
  16948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16949. }
  16950. m.SetCategoryID(v)
  16951. return nil
  16952. case employee.FieldAPIBase:
  16953. v, ok := value.(string)
  16954. if !ok {
  16955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16956. }
  16957. m.SetAPIBase(v)
  16958. return nil
  16959. case employee.FieldAPIKey:
  16960. v, ok := value.(string)
  16961. if !ok {
  16962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16963. }
  16964. m.SetAPIKey(v)
  16965. return nil
  16966. case employee.FieldAiInfo:
  16967. v, ok := value.(string)
  16968. if !ok {
  16969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16970. }
  16971. m.SetAiInfo(v)
  16972. return nil
  16973. case employee.FieldIsVip:
  16974. v, ok := value.(int)
  16975. if !ok {
  16976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16977. }
  16978. m.SetIsVip(v)
  16979. return nil
  16980. case employee.FieldChatURL:
  16981. v, ok := value.(string)
  16982. if !ok {
  16983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16984. }
  16985. m.SetChatURL(v)
  16986. return nil
  16987. }
  16988. return fmt.Errorf("unknown Employee field %s", name)
  16989. }
  16990. // AddedFields returns all numeric fields that were incremented/decremented during
  16991. // this mutation.
  16992. func (m *EmployeeMutation) AddedFields() []string {
  16993. var fields []string
  16994. if m.addhire_count != nil {
  16995. fields = append(fields, employee.FieldHireCount)
  16996. }
  16997. if m.addservice_count != nil {
  16998. fields = append(fields, employee.FieldServiceCount)
  16999. }
  17000. if m.addachievement_count != nil {
  17001. fields = append(fields, employee.FieldAchievementCount)
  17002. }
  17003. if m.addorganization_id != nil {
  17004. fields = append(fields, employee.FieldOrganizationID)
  17005. }
  17006. if m.addcategory_id != nil {
  17007. fields = append(fields, employee.FieldCategoryID)
  17008. }
  17009. if m.addis_vip != nil {
  17010. fields = append(fields, employee.FieldIsVip)
  17011. }
  17012. return fields
  17013. }
  17014. // AddedField returns the numeric value that was incremented/decremented on a field
  17015. // with the given name. The second boolean return value indicates that this field
  17016. // was not set, or was not defined in the schema.
  17017. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  17018. switch name {
  17019. case employee.FieldHireCount:
  17020. return m.AddedHireCount()
  17021. case employee.FieldServiceCount:
  17022. return m.AddedServiceCount()
  17023. case employee.FieldAchievementCount:
  17024. return m.AddedAchievementCount()
  17025. case employee.FieldOrganizationID:
  17026. return m.AddedOrganizationID()
  17027. case employee.FieldCategoryID:
  17028. return m.AddedCategoryID()
  17029. case employee.FieldIsVip:
  17030. return m.AddedIsVip()
  17031. }
  17032. return nil, false
  17033. }
  17034. // AddField adds the value to the field with the given name. It returns an error if
  17035. // the field is not defined in the schema, or if the type mismatched the field
  17036. // type.
  17037. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  17038. switch name {
  17039. case employee.FieldHireCount:
  17040. v, ok := value.(int)
  17041. if !ok {
  17042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17043. }
  17044. m.AddHireCount(v)
  17045. return nil
  17046. case employee.FieldServiceCount:
  17047. v, ok := value.(int)
  17048. if !ok {
  17049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17050. }
  17051. m.AddServiceCount(v)
  17052. return nil
  17053. case employee.FieldAchievementCount:
  17054. v, ok := value.(int)
  17055. if !ok {
  17056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17057. }
  17058. m.AddAchievementCount(v)
  17059. return nil
  17060. case employee.FieldOrganizationID:
  17061. v, ok := value.(int64)
  17062. if !ok {
  17063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17064. }
  17065. m.AddOrganizationID(v)
  17066. return nil
  17067. case employee.FieldCategoryID:
  17068. v, ok := value.(int64)
  17069. if !ok {
  17070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17071. }
  17072. m.AddCategoryID(v)
  17073. return nil
  17074. case employee.FieldIsVip:
  17075. v, ok := value.(int)
  17076. if !ok {
  17077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17078. }
  17079. m.AddIsVip(v)
  17080. return nil
  17081. }
  17082. return fmt.Errorf("unknown Employee numeric field %s", name)
  17083. }
  17084. // ClearedFields returns all nullable fields that were cleared during this
  17085. // mutation.
  17086. func (m *EmployeeMutation) ClearedFields() []string {
  17087. var fields []string
  17088. if m.FieldCleared(employee.FieldDeletedAt) {
  17089. fields = append(fields, employee.FieldDeletedAt)
  17090. }
  17091. if m.FieldCleared(employee.FieldAiInfo) {
  17092. fields = append(fields, employee.FieldAiInfo)
  17093. }
  17094. return fields
  17095. }
  17096. // FieldCleared returns a boolean indicating if a field with the given name was
  17097. // cleared in this mutation.
  17098. func (m *EmployeeMutation) FieldCleared(name string) bool {
  17099. _, ok := m.clearedFields[name]
  17100. return ok
  17101. }
  17102. // ClearField clears the value of the field with the given name. It returns an
  17103. // error if the field is not defined in the schema.
  17104. func (m *EmployeeMutation) ClearField(name string) error {
  17105. switch name {
  17106. case employee.FieldDeletedAt:
  17107. m.ClearDeletedAt()
  17108. return nil
  17109. case employee.FieldAiInfo:
  17110. m.ClearAiInfo()
  17111. return nil
  17112. }
  17113. return fmt.Errorf("unknown Employee nullable field %s", name)
  17114. }
  17115. // ResetField resets all changes in the mutation for the field with the given name.
  17116. // It returns an error if the field is not defined in the schema.
  17117. func (m *EmployeeMutation) ResetField(name string) error {
  17118. switch name {
  17119. case employee.FieldCreatedAt:
  17120. m.ResetCreatedAt()
  17121. return nil
  17122. case employee.FieldUpdatedAt:
  17123. m.ResetUpdatedAt()
  17124. return nil
  17125. case employee.FieldDeletedAt:
  17126. m.ResetDeletedAt()
  17127. return nil
  17128. case employee.FieldTitle:
  17129. m.ResetTitle()
  17130. return nil
  17131. case employee.FieldAvatar:
  17132. m.ResetAvatar()
  17133. return nil
  17134. case employee.FieldTags:
  17135. m.ResetTags()
  17136. return nil
  17137. case employee.FieldHireCount:
  17138. m.ResetHireCount()
  17139. return nil
  17140. case employee.FieldServiceCount:
  17141. m.ResetServiceCount()
  17142. return nil
  17143. case employee.FieldAchievementCount:
  17144. m.ResetAchievementCount()
  17145. return nil
  17146. case employee.FieldIntro:
  17147. m.ResetIntro()
  17148. return nil
  17149. case employee.FieldEstimate:
  17150. m.ResetEstimate()
  17151. return nil
  17152. case employee.FieldSkill:
  17153. m.ResetSkill()
  17154. return nil
  17155. case employee.FieldAbilityType:
  17156. m.ResetAbilityType()
  17157. return nil
  17158. case employee.FieldScene:
  17159. m.ResetScene()
  17160. return nil
  17161. case employee.FieldSwitchIn:
  17162. m.ResetSwitchIn()
  17163. return nil
  17164. case employee.FieldVideoURL:
  17165. m.ResetVideoURL()
  17166. return nil
  17167. case employee.FieldOrganizationID:
  17168. m.ResetOrganizationID()
  17169. return nil
  17170. case employee.FieldCategoryID:
  17171. m.ResetCategoryID()
  17172. return nil
  17173. case employee.FieldAPIBase:
  17174. m.ResetAPIBase()
  17175. return nil
  17176. case employee.FieldAPIKey:
  17177. m.ResetAPIKey()
  17178. return nil
  17179. case employee.FieldAiInfo:
  17180. m.ResetAiInfo()
  17181. return nil
  17182. case employee.FieldIsVip:
  17183. m.ResetIsVip()
  17184. return nil
  17185. case employee.FieldChatURL:
  17186. m.ResetChatURL()
  17187. return nil
  17188. }
  17189. return fmt.Errorf("unknown Employee field %s", name)
  17190. }
  17191. // AddedEdges returns all edge names that were set/added in this mutation.
  17192. func (m *EmployeeMutation) AddedEdges() []string {
  17193. edges := make([]string, 0, 2)
  17194. if m.em_work_experiences != nil {
  17195. edges = append(edges, employee.EdgeEmWorkExperiences)
  17196. }
  17197. if m.em_tutorial != nil {
  17198. edges = append(edges, employee.EdgeEmTutorial)
  17199. }
  17200. return edges
  17201. }
  17202. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17203. // name in this mutation.
  17204. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  17205. switch name {
  17206. case employee.EdgeEmWorkExperiences:
  17207. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  17208. for id := range m.em_work_experiences {
  17209. ids = append(ids, id)
  17210. }
  17211. return ids
  17212. case employee.EdgeEmTutorial:
  17213. ids := make([]ent.Value, 0, len(m.em_tutorial))
  17214. for id := range m.em_tutorial {
  17215. ids = append(ids, id)
  17216. }
  17217. return ids
  17218. }
  17219. return nil
  17220. }
  17221. // RemovedEdges returns all edge names that were removed in this mutation.
  17222. func (m *EmployeeMutation) RemovedEdges() []string {
  17223. edges := make([]string, 0, 2)
  17224. if m.removedem_work_experiences != nil {
  17225. edges = append(edges, employee.EdgeEmWorkExperiences)
  17226. }
  17227. if m.removedem_tutorial != nil {
  17228. edges = append(edges, employee.EdgeEmTutorial)
  17229. }
  17230. return edges
  17231. }
  17232. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17233. // the given name in this mutation.
  17234. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  17235. switch name {
  17236. case employee.EdgeEmWorkExperiences:
  17237. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  17238. for id := range m.removedem_work_experiences {
  17239. ids = append(ids, id)
  17240. }
  17241. return ids
  17242. case employee.EdgeEmTutorial:
  17243. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  17244. for id := range m.removedem_tutorial {
  17245. ids = append(ids, id)
  17246. }
  17247. return ids
  17248. }
  17249. return nil
  17250. }
  17251. // ClearedEdges returns all edge names that were cleared in this mutation.
  17252. func (m *EmployeeMutation) ClearedEdges() []string {
  17253. edges := make([]string, 0, 2)
  17254. if m.clearedem_work_experiences {
  17255. edges = append(edges, employee.EdgeEmWorkExperiences)
  17256. }
  17257. if m.clearedem_tutorial {
  17258. edges = append(edges, employee.EdgeEmTutorial)
  17259. }
  17260. return edges
  17261. }
  17262. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17263. // was cleared in this mutation.
  17264. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  17265. switch name {
  17266. case employee.EdgeEmWorkExperiences:
  17267. return m.clearedem_work_experiences
  17268. case employee.EdgeEmTutorial:
  17269. return m.clearedem_tutorial
  17270. }
  17271. return false
  17272. }
  17273. // ClearEdge clears the value of the edge with the given name. It returns an error
  17274. // if that edge is not defined in the schema.
  17275. func (m *EmployeeMutation) ClearEdge(name string) error {
  17276. switch name {
  17277. }
  17278. return fmt.Errorf("unknown Employee unique edge %s", name)
  17279. }
  17280. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17281. // It returns an error if the edge is not defined in the schema.
  17282. func (m *EmployeeMutation) ResetEdge(name string) error {
  17283. switch name {
  17284. case employee.EdgeEmWorkExperiences:
  17285. m.ResetEmWorkExperiences()
  17286. return nil
  17287. case employee.EdgeEmTutorial:
  17288. m.ResetEmTutorial()
  17289. return nil
  17290. }
  17291. return fmt.Errorf("unknown Employee edge %s", name)
  17292. }
  17293. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  17294. type EmployeeConfigMutation struct {
  17295. config
  17296. op Op
  17297. typ string
  17298. id *uint64
  17299. created_at *time.Time
  17300. updated_at *time.Time
  17301. deleted_at *time.Time
  17302. stype *string
  17303. title *string
  17304. photo *string
  17305. organization_id *uint64
  17306. addorganization_id *int64
  17307. clearedFields map[string]struct{}
  17308. done bool
  17309. oldValue func(context.Context) (*EmployeeConfig, error)
  17310. predicates []predicate.EmployeeConfig
  17311. }
  17312. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  17313. // employeeconfigOption allows management of the mutation configuration using functional options.
  17314. type employeeconfigOption func(*EmployeeConfigMutation)
  17315. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  17316. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  17317. m := &EmployeeConfigMutation{
  17318. config: c,
  17319. op: op,
  17320. typ: TypeEmployeeConfig,
  17321. clearedFields: make(map[string]struct{}),
  17322. }
  17323. for _, opt := range opts {
  17324. opt(m)
  17325. }
  17326. return m
  17327. }
  17328. // withEmployeeConfigID sets the ID field of the mutation.
  17329. func withEmployeeConfigID(id uint64) employeeconfigOption {
  17330. return func(m *EmployeeConfigMutation) {
  17331. var (
  17332. err error
  17333. once sync.Once
  17334. value *EmployeeConfig
  17335. )
  17336. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  17337. once.Do(func() {
  17338. if m.done {
  17339. err = errors.New("querying old values post mutation is not allowed")
  17340. } else {
  17341. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  17342. }
  17343. })
  17344. return value, err
  17345. }
  17346. m.id = &id
  17347. }
  17348. }
  17349. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  17350. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  17351. return func(m *EmployeeConfigMutation) {
  17352. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  17353. return node, nil
  17354. }
  17355. m.id = &node.ID
  17356. }
  17357. }
  17358. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17359. // executed in a transaction (ent.Tx), a transactional client is returned.
  17360. func (m EmployeeConfigMutation) Client() *Client {
  17361. client := &Client{config: m.config}
  17362. client.init()
  17363. return client
  17364. }
  17365. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17366. // it returns an error otherwise.
  17367. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  17368. if _, ok := m.driver.(*txDriver); !ok {
  17369. return nil, errors.New("ent: mutation is not running in a transaction")
  17370. }
  17371. tx := &Tx{config: m.config}
  17372. tx.init()
  17373. return tx, nil
  17374. }
  17375. // SetID sets the value of the id field. Note that this
  17376. // operation is only accepted on creation of EmployeeConfig entities.
  17377. func (m *EmployeeConfigMutation) SetID(id uint64) {
  17378. m.id = &id
  17379. }
  17380. // ID returns the ID value in the mutation. Note that the ID is only available
  17381. // if it was provided to the builder or after it was returned from the database.
  17382. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  17383. if m.id == nil {
  17384. return
  17385. }
  17386. return *m.id, true
  17387. }
  17388. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17389. // That means, if the mutation is applied within a transaction with an isolation level such
  17390. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17391. // or updated by the mutation.
  17392. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  17393. switch {
  17394. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17395. id, exists := m.ID()
  17396. if exists {
  17397. return []uint64{id}, nil
  17398. }
  17399. fallthrough
  17400. case m.op.Is(OpUpdate | OpDelete):
  17401. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  17402. default:
  17403. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17404. }
  17405. }
  17406. // SetCreatedAt sets the "created_at" field.
  17407. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  17408. m.created_at = &t
  17409. }
  17410. // CreatedAt returns the value of the "created_at" field in the mutation.
  17411. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  17412. v := m.created_at
  17413. if v == nil {
  17414. return
  17415. }
  17416. return *v, true
  17417. }
  17418. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  17419. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17421. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17422. if !m.op.Is(OpUpdateOne) {
  17423. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17424. }
  17425. if m.id == nil || m.oldValue == nil {
  17426. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17427. }
  17428. oldValue, err := m.oldValue(ctx)
  17429. if err != nil {
  17430. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17431. }
  17432. return oldValue.CreatedAt, nil
  17433. }
  17434. // ResetCreatedAt resets all changes to the "created_at" field.
  17435. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  17436. m.created_at = nil
  17437. }
  17438. // SetUpdatedAt sets the "updated_at" field.
  17439. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  17440. m.updated_at = &t
  17441. }
  17442. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17443. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  17444. v := m.updated_at
  17445. if v == nil {
  17446. return
  17447. }
  17448. return *v, true
  17449. }
  17450. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  17451. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17453. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17454. if !m.op.Is(OpUpdateOne) {
  17455. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17456. }
  17457. if m.id == nil || m.oldValue == nil {
  17458. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17459. }
  17460. oldValue, err := m.oldValue(ctx)
  17461. if err != nil {
  17462. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17463. }
  17464. return oldValue.UpdatedAt, nil
  17465. }
  17466. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17467. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  17468. m.updated_at = nil
  17469. }
  17470. // SetDeletedAt sets the "deleted_at" field.
  17471. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  17472. m.deleted_at = &t
  17473. }
  17474. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17475. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  17476. v := m.deleted_at
  17477. if v == nil {
  17478. return
  17479. }
  17480. return *v, true
  17481. }
  17482. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  17483. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17485. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17486. if !m.op.Is(OpUpdateOne) {
  17487. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17488. }
  17489. if m.id == nil || m.oldValue == nil {
  17490. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17491. }
  17492. oldValue, err := m.oldValue(ctx)
  17493. if err != nil {
  17494. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17495. }
  17496. return oldValue.DeletedAt, nil
  17497. }
  17498. // ClearDeletedAt clears the value of the "deleted_at" field.
  17499. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  17500. m.deleted_at = nil
  17501. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  17502. }
  17503. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17504. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  17505. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  17506. return ok
  17507. }
  17508. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17509. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  17510. m.deleted_at = nil
  17511. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  17512. }
  17513. // SetStype sets the "stype" field.
  17514. func (m *EmployeeConfigMutation) SetStype(s string) {
  17515. m.stype = &s
  17516. }
  17517. // Stype returns the value of the "stype" field in the mutation.
  17518. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  17519. v := m.stype
  17520. if v == nil {
  17521. return
  17522. }
  17523. return *v, true
  17524. }
  17525. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  17526. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17528. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  17529. if !m.op.Is(OpUpdateOne) {
  17530. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  17531. }
  17532. if m.id == nil || m.oldValue == nil {
  17533. return v, errors.New("OldStype requires an ID field in the mutation")
  17534. }
  17535. oldValue, err := m.oldValue(ctx)
  17536. if err != nil {
  17537. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  17538. }
  17539. return oldValue.Stype, nil
  17540. }
  17541. // ResetStype resets all changes to the "stype" field.
  17542. func (m *EmployeeConfigMutation) ResetStype() {
  17543. m.stype = nil
  17544. }
  17545. // SetTitle sets the "title" field.
  17546. func (m *EmployeeConfigMutation) SetTitle(s string) {
  17547. m.title = &s
  17548. }
  17549. // Title returns the value of the "title" field in the mutation.
  17550. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  17551. v := m.title
  17552. if v == nil {
  17553. return
  17554. }
  17555. return *v, true
  17556. }
  17557. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  17558. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17560. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  17561. if !m.op.Is(OpUpdateOne) {
  17562. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17563. }
  17564. if m.id == nil || m.oldValue == nil {
  17565. return v, errors.New("OldTitle requires an ID field in the mutation")
  17566. }
  17567. oldValue, err := m.oldValue(ctx)
  17568. if err != nil {
  17569. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17570. }
  17571. return oldValue.Title, nil
  17572. }
  17573. // ResetTitle resets all changes to the "title" field.
  17574. func (m *EmployeeConfigMutation) ResetTitle() {
  17575. m.title = nil
  17576. }
  17577. // SetPhoto sets the "photo" field.
  17578. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  17579. m.photo = &s
  17580. }
  17581. // Photo returns the value of the "photo" field in the mutation.
  17582. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  17583. v := m.photo
  17584. if v == nil {
  17585. return
  17586. }
  17587. return *v, true
  17588. }
  17589. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  17590. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17592. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  17593. if !m.op.Is(OpUpdateOne) {
  17594. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  17595. }
  17596. if m.id == nil || m.oldValue == nil {
  17597. return v, errors.New("OldPhoto requires an ID field in the mutation")
  17598. }
  17599. oldValue, err := m.oldValue(ctx)
  17600. if err != nil {
  17601. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  17602. }
  17603. return oldValue.Photo, nil
  17604. }
  17605. // ResetPhoto resets all changes to the "photo" field.
  17606. func (m *EmployeeConfigMutation) ResetPhoto() {
  17607. m.photo = nil
  17608. }
  17609. // SetOrganizationID sets the "organization_id" field.
  17610. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  17611. m.organization_id = &u
  17612. m.addorganization_id = nil
  17613. }
  17614. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17615. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  17616. v := m.organization_id
  17617. if v == nil {
  17618. return
  17619. }
  17620. return *v, true
  17621. }
  17622. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  17623. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17625. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17626. if !m.op.Is(OpUpdateOne) {
  17627. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17628. }
  17629. if m.id == nil || m.oldValue == nil {
  17630. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17631. }
  17632. oldValue, err := m.oldValue(ctx)
  17633. if err != nil {
  17634. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17635. }
  17636. return oldValue.OrganizationID, nil
  17637. }
  17638. // AddOrganizationID adds u to the "organization_id" field.
  17639. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  17640. if m.addorganization_id != nil {
  17641. *m.addorganization_id += u
  17642. } else {
  17643. m.addorganization_id = &u
  17644. }
  17645. }
  17646. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17647. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  17648. v := m.addorganization_id
  17649. if v == nil {
  17650. return
  17651. }
  17652. return *v, true
  17653. }
  17654. // ClearOrganizationID clears the value of the "organization_id" field.
  17655. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  17656. m.organization_id = nil
  17657. m.addorganization_id = nil
  17658. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  17659. }
  17660. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17661. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  17662. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  17663. return ok
  17664. }
  17665. // ResetOrganizationID resets all changes to the "organization_id" field.
  17666. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  17667. m.organization_id = nil
  17668. m.addorganization_id = nil
  17669. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  17670. }
  17671. // Where appends a list predicates to the EmployeeConfigMutation builder.
  17672. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  17673. m.predicates = append(m.predicates, ps...)
  17674. }
  17675. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  17676. // users can use type-assertion to append predicates that do not depend on any generated package.
  17677. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  17678. p := make([]predicate.EmployeeConfig, len(ps))
  17679. for i := range ps {
  17680. p[i] = ps[i]
  17681. }
  17682. m.Where(p...)
  17683. }
  17684. // Op returns the operation name.
  17685. func (m *EmployeeConfigMutation) Op() Op {
  17686. return m.op
  17687. }
  17688. // SetOp allows setting the mutation operation.
  17689. func (m *EmployeeConfigMutation) SetOp(op Op) {
  17690. m.op = op
  17691. }
  17692. // Type returns the node type of this mutation (EmployeeConfig).
  17693. func (m *EmployeeConfigMutation) Type() string {
  17694. return m.typ
  17695. }
  17696. // Fields returns all fields that were changed during this mutation. Note that in
  17697. // order to get all numeric fields that were incremented/decremented, call
  17698. // AddedFields().
  17699. func (m *EmployeeConfigMutation) Fields() []string {
  17700. fields := make([]string, 0, 7)
  17701. if m.created_at != nil {
  17702. fields = append(fields, employeeconfig.FieldCreatedAt)
  17703. }
  17704. if m.updated_at != nil {
  17705. fields = append(fields, employeeconfig.FieldUpdatedAt)
  17706. }
  17707. if m.deleted_at != nil {
  17708. fields = append(fields, employeeconfig.FieldDeletedAt)
  17709. }
  17710. if m.stype != nil {
  17711. fields = append(fields, employeeconfig.FieldStype)
  17712. }
  17713. if m.title != nil {
  17714. fields = append(fields, employeeconfig.FieldTitle)
  17715. }
  17716. if m.photo != nil {
  17717. fields = append(fields, employeeconfig.FieldPhoto)
  17718. }
  17719. if m.organization_id != nil {
  17720. fields = append(fields, employeeconfig.FieldOrganizationID)
  17721. }
  17722. return fields
  17723. }
  17724. // Field returns the value of a field with the given name. The second boolean
  17725. // return value indicates that this field was not set, or was not defined in the
  17726. // schema.
  17727. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  17728. switch name {
  17729. case employeeconfig.FieldCreatedAt:
  17730. return m.CreatedAt()
  17731. case employeeconfig.FieldUpdatedAt:
  17732. return m.UpdatedAt()
  17733. case employeeconfig.FieldDeletedAt:
  17734. return m.DeletedAt()
  17735. case employeeconfig.FieldStype:
  17736. return m.Stype()
  17737. case employeeconfig.FieldTitle:
  17738. return m.Title()
  17739. case employeeconfig.FieldPhoto:
  17740. return m.Photo()
  17741. case employeeconfig.FieldOrganizationID:
  17742. return m.OrganizationID()
  17743. }
  17744. return nil, false
  17745. }
  17746. // OldField returns the old value of the field from the database. An error is
  17747. // returned if the mutation operation is not UpdateOne, or the query to the
  17748. // database failed.
  17749. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17750. switch name {
  17751. case employeeconfig.FieldCreatedAt:
  17752. return m.OldCreatedAt(ctx)
  17753. case employeeconfig.FieldUpdatedAt:
  17754. return m.OldUpdatedAt(ctx)
  17755. case employeeconfig.FieldDeletedAt:
  17756. return m.OldDeletedAt(ctx)
  17757. case employeeconfig.FieldStype:
  17758. return m.OldStype(ctx)
  17759. case employeeconfig.FieldTitle:
  17760. return m.OldTitle(ctx)
  17761. case employeeconfig.FieldPhoto:
  17762. return m.OldPhoto(ctx)
  17763. case employeeconfig.FieldOrganizationID:
  17764. return m.OldOrganizationID(ctx)
  17765. }
  17766. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  17767. }
  17768. // SetField sets the value of a field with the given name. It returns an error if
  17769. // the field is not defined in the schema, or if the type mismatched the field
  17770. // type.
  17771. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  17772. switch name {
  17773. case employeeconfig.FieldCreatedAt:
  17774. v, ok := value.(time.Time)
  17775. if !ok {
  17776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17777. }
  17778. m.SetCreatedAt(v)
  17779. return nil
  17780. case employeeconfig.FieldUpdatedAt:
  17781. v, ok := value.(time.Time)
  17782. if !ok {
  17783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17784. }
  17785. m.SetUpdatedAt(v)
  17786. return nil
  17787. case employeeconfig.FieldDeletedAt:
  17788. v, ok := value.(time.Time)
  17789. if !ok {
  17790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17791. }
  17792. m.SetDeletedAt(v)
  17793. return nil
  17794. case employeeconfig.FieldStype:
  17795. v, ok := value.(string)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.SetStype(v)
  17800. return nil
  17801. case employeeconfig.FieldTitle:
  17802. v, ok := value.(string)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.SetTitle(v)
  17807. return nil
  17808. case employeeconfig.FieldPhoto:
  17809. v, ok := value.(string)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.SetPhoto(v)
  17814. return nil
  17815. case employeeconfig.FieldOrganizationID:
  17816. v, ok := value.(uint64)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.SetOrganizationID(v)
  17821. return nil
  17822. }
  17823. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17824. }
  17825. // AddedFields returns all numeric fields that were incremented/decremented during
  17826. // this mutation.
  17827. func (m *EmployeeConfigMutation) AddedFields() []string {
  17828. var fields []string
  17829. if m.addorganization_id != nil {
  17830. fields = append(fields, employeeconfig.FieldOrganizationID)
  17831. }
  17832. return fields
  17833. }
  17834. // AddedField returns the numeric value that was incremented/decremented on a field
  17835. // with the given name. The second boolean return value indicates that this field
  17836. // was not set, or was not defined in the schema.
  17837. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  17838. switch name {
  17839. case employeeconfig.FieldOrganizationID:
  17840. return m.AddedOrganizationID()
  17841. }
  17842. return nil, false
  17843. }
  17844. // AddField adds the value to the field with the given name. It returns an error if
  17845. // the field is not defined in the schema, or if the type mismatched the field
  17846. // type.
  17847. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  17848. switch name {
  17849. case employeeconfig.FieldOrganizationID:
  17850. v, ok := value.(int64)
  17851. if !ok {
  17852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17853. }
  17854. m.AddOrganizationID(v)
  17855. return nil
  17856. }
  17857. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  17858. }
  17859. // ClearedFields returns all nullable fields that were cleared during this
  17860. // mutation.
  17861. func (m *EmployeeConfigMutation) ClearedFields() []string {
  17862. var fields []string
  17863. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  17864. fields = append(fields, employeeconfig.FieldDeletedAt)
  17865. }
  17866. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  17867. fields = append(fields, employeeconfig.FieldOrganizationID)
  17868. }
  17869. return fields
  17870. }
  17871. // FieldCleared returns a boolean indicating if a field with the given name was
  17872. // cleared in this mutation.
  17873. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  17874. _, ok := m.clearedFields[name]
  17875. return ok
  17876. }
  17877. // ClearField clears the value of the field with the given name. It returns an
  17878. // error if the field is not defined in the schema.
  17879. func (m *EmployeeConfigMutation) ClearField(name string) error {
  17880. switch name {
  17881. case employeeconfig.FieldDeletedAt:
  17882. m.ClearDeletedAt()
  17883. return nil
  17884. case employeeconfig.FieldOrganizationID:
  17885. m.ClearOrganizationID()
  17886. return nil
  17887. }
  17888. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  17889. }
  17890. // ResetField resets all changes in the mutation for the field with the given name.
  17891. // It returns an error if the field is not defined in the schema.
  17892. func (m *EmployeeConfigMutation) ResetField(name string) error {
  17893. switch name {
  17894. case employeeconfig.FieldCreatedAt:
  17895. m.ResetCreatedAt()
  17896. return nil
  17897. case employeeconfig.FieldUpdatedAt:
  17898. m.ResetUpdatedAt()
  17899. return nil
  17900. case employeeconfig.FieldDeletedAt:
  17901. m.ResetDeletedAt()
  17902. return nil
  17903. case employeeconfig.FieldStype:
  17904. m.ResetStype()
  17905. return nil
  17906. case employeeconfig.FieldTitle:
  17907. m.ResetTitle()
  17908. return nil
  17909. case employeeconfig.FieldPhoto:
  17910. m.ResetPhoto()
  17911. return nil
  17912. case employeeconfig.FieldOrganizationID:
  17913. m.ResetOrganizationID()
  17914. return nil
  17915. }
  17916. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17917. }
  17918. // AddedEdges returns all edge names that were set/added in this mutation.
  17919. func (m *EmployeeConfigMutation) AddedEdges() []string {
  17920. edges := make([]string, 0, 0)
  17921. return edges
  17922. }
  17923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17924. // name in this mutation.
  17925. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  17926. return nil
  17927. }
  17928. // RemovedEdges returns all edge names that were removed in this mutation.
  17929. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  17930. edges := make([]string, 0, 0)
  17931. return edges
  17932. }
  17933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17934. // the given name in this mutation.
  17935. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  17936. return nil
  17937. }
  17938. // ClearedEdges returns all edge names that were cleared in this mutation.
  17939. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  17940. edges := make([]string, 0, 0)
  17941. return edges
  17942. }
  17943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17944. // was cleared in this mutation.
  17945. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  17946. return false
  17947. }
  17948. // ClearEdge clears the value of the edge with the given name. It returns an error
  17949. // if that edge is not defined in the schema.
  17950. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  17951. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  17952. }
  17953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17954. // It returns an error if the edge is not defined in the schema.
  17955. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  17956. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  17957. }
  17958. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  17959. type LabelMutation struct {
  17960. config
  17961. op Op
  17962. typ string
  17963. id *uint64
  17964. created_at *time.Time
  17965. updated_at *time.Time
  17966. status *uint8
  17967. addstatus *int8
  17968. _type *int
  17969. add_type *int
  17970. name *string
  17971. from *int
  17972. addfrom *int
  17973. mode *int
  17974. addmode *int
  17975. conditions *string
  17976. organization_id *uint64
  17977. addorganization_id *int64
  17978. clearedFields map[string]struct{}
  17979. label_relationships map[uint64]struct{}
  17980. removedlabel_relationships map[uint64]struct{}
  17981. clearedlabel_relationships bool
  17982. done bool
  17983. oldValue func(context.Context) (*Label, error)
  17984. predicates []predicate.Label
  17985. }
  17986. var _ ent.Mutation = (*LabelMutation)(nil)
  17987. // labelOption allows management of the mutation configuration using functional options.
  17988. type labelOption func(*LabelMutation)
  17989. // newLabelMutation creates new mutation for the Label entity.
  17990. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  17991. m := &LabelMutation{
  17992. config: c,
  17993. op: op,
  17994. typ: TypeLabel,
  17995. clearedFields: make(map[string]struct{}),
  17996. }
  17997. for _, opt := range opts {
  17998. opt(m)
  17999. }
  18000. return m
  18001. }
  18002. // withLabelID sets the ID field of the mutation.
  18003. func withLabelID(id uint64) labelOption {
  18004. return func(m *LabelMutation) {
  18005. var (
  18006. err error
  18007. once sync.Once
  18008. value *Label
  18009. )
  18010. m.oldValue = func(ctx context.Context) (*Label, error) {
  18011. once.Do(func() {
  18012. if m.done {
  18013. err = errors.New("querying old values post mutation is not allowed")
  18014. } else {
  18015. value, err = m.Client().Label.Get(ctx, id)
  18016. }
  18017. })
  18018. return value, err
  18019. }
  18020. m.id = &id
  18021. }
  18022. }
  18023. // withLabel sets the old Label of the mutation.
  18024. func withLabel(node *Label) labelOption {
  18025. return func(m *LabelMutation) {
  18026. m.oldValue = func(context.Context) (*Label, error) {
  18027. return node, nil
  18028. }
  18029. m.id = &node.ID
  18030. }
  18031. }
  18032. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18033. // executed in a transaction (ent.Tx), a transactional client is returned.
  18034. func (m LabelMutation) Client() *Client {
  18035. client := &Client{config: m.config}
  18036. client.init()
  18037. return client
  18038. }
  18039. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18040. // it returns an error otherwise.
  18041. func (m LabelMutation) Tx() (*Tx, error) {
  18042. if _, ok := m.driver.(*txDriver); !ok {
  18043. return nil, errors.New("ent: mutation is not running in a transaction")
  18044. }
  18045. tx := &Tx{config: m.config}
  18046. tx.init()
  18047. return tx, nil
  18048. }
  18049. // SetID sets the value of the id field. Note that this
  18050. // operation is only accepted on creation of Label entities.
  18051. func (m *LabelMutation) SetID(id uint64) {
  18052. m.id = &id
  18053. }
  18054. // ID returns the ID value in the mutation. Note that the ID is only available
  18055. // if it was provided to the builder or after it was returned from the database.
  18056. func (m *LabelMutation) ID() (id uint64, exists bool) {
  18057. if m.id == nil {
  18058. return
  18059. }
  18060. return *m.id, true
  18061. }
  18062. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18063. // That means, if the mutation is applied within a transaction with an isolation level such
  18064. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18065. // or updated by the mutation.
  18066. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  18067. switch {
  18068. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18069. id, exists := m.ID()
  18070. if exists {
  18071. return []uint64{id}, nil
  18072. }
  18073. fallthrough
  18074. case m.op.Is(OpUpdate | OpDelete):
  18075. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  18076. default:
  18077. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18078. }
  18079. }
  18080. // SetCreatedAt sets the "created_at" field.
  18081. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  18082. m.created_at = &t
  18083. }
  18084. // CreatedAt returns the value of the "created_at" field in the mutation.
  18085. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  18086. v := m.created_at
  18087. if v == nil {
  18088. return
  18089. }
  18090. return *v, true
  18091. }
  18092. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  18093. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18095. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18096. if !m.op.Is(OpUpdateOne) {
  18097. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18098. }
  18099. if m.id == nil || m.oldValue == nil {
  18100. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18101. }
  18102. oldValue, err := m.oldValue(ctx)
  18103. if err != nil {
  18104. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18105. }
  18106. return oldValue.CreatedAt, nil
  18107. }
  18108. // ResetCreatedAt resets all changes to the "created_at" field.
  18109. func (m *LabelMutation) ResetCreatedAt() {
  18110. m.created_at = nil
  18111. }
  18112. // SetUpdatedAt sets the "updated_at" field.
  18113. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  18114. m.updated_at = &t
  18115. }
  18116. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18117. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  18118. v := m.updated_at
  18119. if v == nil {
  18120. return
  18121. }
  18122. return *v, true
  18123. }
  18124. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  18125. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18127. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18128. if !m.op.Is(OpUpdateOne) {
  18129. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18130. }
  18131. if m.id == nil || m.oldValue == nil {
  18132. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18133. }
  18134. oldValue, err := m.oldValue(ctx)
  18135. if err != nil {
  18136. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18137. }
  18138. return oldValue.UpdatedAt, nil
  18139. }
  18140. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18141. func (m *LabelMutation) ResetUpdatedAt() {
  18142. m.updated_at = nil
  18143. }
  18144. // SetStatus sets the "status" field.
  18145. func (m *LabelMutation) SetStatus(u uint8) {
  18146. m.status = &u
  18147. m.addstatus = nil
  18148. }
  18149. // Status returns the value of the "status" field in the mutation.
  18150. func (m *LabelMutation) Status() (r uint8, exists bool) {
  18151. v := m.status
  18152. if v == nil {
  18153. return
  18154. }
  18155. return *v, true
  18156. }
  18157. // OldStatus returns the old "status" field's value of the Label entity.
  18158. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18160. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18161. if !m.op.Is(OpUpdateOne) {
  18162. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18163. }
  18164. if m.id == nil || m.oldValue == nil {
  18165. return v, errors.New("OldStatus requires an ID field in the mutation")
  18166. }
  18167. oldValue, err := m.oldValue(ctx)
  18168. if err != nil {
  18169. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18170. }
  18171. return oldValue.Status, nil
  18172. }
  18173. // AddStatus adds u to the "status" field.
  18174. func (m *LabelMutation) AddStatus(u int8) {
  18175. if m.addstatus != nil {
  18176. *m.addstatus += u
  18177. } else {
  18178. m.addstatus = &u
  18179. }
  18180. }
  18181. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18182. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  18183. v := m.addstatus
  18184. if v == nil {
  18185. return
  18186. }
  18187. return *v, true
  18188. }
  18189. // ClearStatus clears the value of the "status" field.
  18190. func (m *LabelMutation) ClearStatus() {
  18191. m.status = nil
  18192. m.addstatus = nil
  18193. m.clearedFields[label.FieldStatus] = struct{}{}
  18194. }
  18195. // StatusCleared returns if the "status" field was cleared in this mutation.
  18196. func (m *LabelMutation) StatusCleared() bool {
  18197. _, ok := m.clearedFields[label.FieldStatus]
  18198. return ok
  18199. }
  18200. // ResetStatus resets all changes to the "status" field.
  18201. func (m *LabelMutation) ResetStatus() {
  18202. m.status = nil
  18203. m.addstatus = nil
  18204. delete(m.clearedFields, label.FieldStatus)
  18205. }
  18206. // SetType sets the "type" field.
  18207. func (m *LabelMutation) SetType(i int) {
  18208. m._type = &i
  18209. m.add_type = nil
  18210. }
  18211. // GetType returns the value of the "type" field in the mutation.
  18212. func (m *LabelMutation) GetType() (r int, exists bool) {
  18213. v := m._type
  18214. if v == nil {
  18215. return
  18216. }
  18217. return *v, true
  18218. }
  18219. // OldType returns the old "type" field's value of the Label entity.
  18220. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18222. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  18223. if !m.op.Is(OpUpdateOne) {
  18224. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18225. }
  18226. if m.id == nil || m.oldValue == nil {
  18227. return v, errors.New("OldType requires an ID field in the mutation")
  18228. }
  18229. oldValue, err := m.oldValue(ctx)
  18230. if err != nil {
  18231. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18232. }
  18233. return oldValue.Type, nil
  18234. }
  18235. // AddType adds i to the "type" field.
  18236. func (m *LabelMutation) AddType(i int) {
  18237. if m.add_type != nil {
  18238. *m.add_type += i
  18239. } else {
  18240. m.add_type = &i
  18241. }
  18242. }
  18243. // AddedType returns the value that was added to the "type" field in this mutation.
  18244. func (m *LabelMutation) AddedType() (r int, exists bool) {
  18245. v := m.add_type
  18246. if v == nil {
  18247. return
  18248. }
  18249. return *v, true
  18250. }
  18251. // ResetType resets all changes to the "type" field.
  18252. func (m *LabelMutation) ResetType() {
  18253. m._type = nil
  18254. m.add_type = nil
  18255. }
  18256. // SetName sets the "name" field.
  18257. func (m *LabelMutation) SetName(s string) {
  18258. m.name = &s
  18259. }
  18260. // Name returns the value of the "name" field in the mutation.
  18261. func (m *LabelMutation) Name() (r string, exists bool) {
  18262. v := m.name
  18263. if v == nil {
  18264. return
  18265. }
  18266. return *v, true
  18267. }
  18268. // OldName returns the old "name" field's value of the Label entity.
  18269. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18271. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  18272. if !m.op.Is(OpUpdateOne) {
  18273. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18274. }
  18275. if m.id == nil || m.oldValue == nil {
  18276. return v, errors.New("OldName requires an ID field in the mutation")
  18277. }
  18278. oldValue, err := m.oldValue(ctx)
  18279. if err != nil {
  18280. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18281. }
  18282. return oldValue.Name, nil
  18283. }
  18284. // ResetName resets all changes to the "name" field.
  18285. func (m *LabelMutation) ResetName() {
  18286. m.name = nil
  18287. }
  18288. // SetFrom sets the "from" field.
  18289. func (m *LabelMutation) SetFrom(i int) {
  18290. m.from = &i
  18291. m.addfrom = nil
  18292. }
  18293. // From returns the value of the "from" field in the mutation.
  18294. func (m *LabelMutation) From() (r int, exists bool) {
  18295. v := m.from
  18296. if v == nil {
  18297. return
  18298. }
  18299. return *v, true
  18300. }
  18301. // OldFrom returns the old "from" field's value of the Label entity.
  18302. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18304. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  18305. if !m.op.Is(OpUpdateOne) {
  18306. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  18307. }
  18308. if m.id == nil || m.oldValue == nil {
  18309. return v, errors.New("OldFrom requires an ID field in the mutation")
  18310. }
  18311. oldValue, err := m.oldValue(ctx)
  18312. if err != nil {
  18313. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  18314. }
  18315. return oldValue.From, nil
  18316. }
  18317. // AddFrom adds i to the "from" field.
  18318. func (m *LabelMutation) AddFrom(i int) {
  18319. if m.addfrom != nil {
  18320. *m.addfrom += i
  18321. } else {
  18322. m.addfrom = &i
  18323. }
  18324. }
  18325. // AddedFrom returns the value that was added to the "from" field in this mutation.
  18326. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  18327. v := m.addfrom
  18328. if v == nil {
  18329. return
  18330. }
  18331. return *v, true
  18332. }
  18333. // ResetFrom resets all changes to the "from" field.
  18334. func (m *LabelMutation) ResetFrom() {
  18335. m.from = nil
  18336. m.addfrom = nil
  18337. }
  18338. // SetMode sets the "mode" field.
  18339. func (m *LabelMutation) SetMode(i int) {
  18340. m.mode = &i
  18341. m.addmode = nil
  18342. }
  18343. // Mode returns the value of the "mode" field in the mutation.
  18344. func (m *LabelMutation) Mode() (r int, exists bool) {
  18345. v := m.mode
  18346. if v == nil {
  18347. return
  18348. }
  18349. return *v, true
  18350. }
  18351. // OldMode returns the old "mode" field's value of the Label entity.
  18352. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18354. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  18355. if !m.op.Is(OpUpdateOne) {
  18356. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  18357. }
  18358. if m.id == nil || m.oldValue == nil {
  18359. return v, errors.New("OldMode requires an ID field in the mutation")
  18360. }
  18361. oldValue, err := m.oldValue(ctx)
  18362. if err != nil {
  18363. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  18364. }
  18365. return oldValue.Mode, nil
  18366. }
  18367. // AddMode adds i to the "mode" field.
  18368. func (m *LabelMutation) AddMode(i int) {
  18369. if m.addmode != nil {
  18370. *m.addmode += i
  18371. } else {
  18372. m.addmode = &i
  18373. }
  18374. }
  18375. // AddedMode returns the value that was added to the "mode" field in this mutation.
  18376. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  18377. v := m.addmode
  18378. if v == nil {
  18379. return
  18380. }
  18381. return *v, true
  18382. }
  18383. // ResetMode resets all changes to the "mode" field.
  18384. func (m *LabelMutation) ResetMode() {
  18385. m.mode = nil
  18386. m.addmode = nil
  18387. }
  18388. // SetConditions sets the "conditions" field.
  18389. func (m *LabelMutation) SetConditions(s string) {
  18390. m.conditions = &s
  18391. }
  18392. // Conditions returns the value of the "conditions" field in the mutation.
  18393. func (m *LabelMutation) Conditions() (r string, exists bool) {
  18394. v := m.conditions
  18395. if v == nil {
  18396. return
  18397. }
  18398. return *v, true
  18399. }
  18400. // OldConditions returns the old "conditions" field's value of the Label entity.
  18401. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18403. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  18404. if !m.op.Is(OpUpdateOne) {
  18405. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18406. }
  18407. if m.id == nil || m.oldValue == nil {
  18408. return v, errors.New("OldConditions requires an ID field in the mutation")
  18409. }
  18410. oldValue, err := m.oldValue(ctx)
  18411. if err != nil {
  18412. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18413. }
  18414. return oldValue.Conditions, nil
  18415. }
  18416. // ClearConditions clears the value of the "conditions" field.
  18417. func (m *LabelMutation) ClearConditions() {
  18418. m.conditions = nil
  18419. m.clearedFields[label.FieldConditions] = struct{}{}
  18420. }
  18421. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  18422. func (m *LabelMutation) ConditionsCleared() bool {
  18423. _, ok := m.clearedFields[label.FieldConditions]
  18424. return ok
  18425. }
  18426. // ResetConditions resets all changes to the "conditions" field.
  18427. func (m *LabelMutation) ResetConditions() {
  18428. m.conditions = nil
  18429. delete(m.clearedFields, label.FieldConditions)
  18430. }
  18431. // SetOrganizationID sets the "organization_id" field.
  18432. func (m *LabelMutation) SetOrganizationID(u uint64) {
  18433. m.organization_id = &u
  18434. m.addorganization_id = nil
  18435. }
  18436. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18437. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  18438. v := m.organization_id
  18439. if v == nil {
  18440. return
  18441. }
  18442. return *v, true
  18443. }
  18444. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  18445. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18447. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18448. if !m.op.Is(OpUpdateOne) {
  18449. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18450. }
  18451. if m.id == nil || m.oldValue == nil {
  18452. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18453. }
  18454. oldValue, err := m.oldValue(ctx)
  18455. if err != nil {
  18456. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18457. }
  18458. return oldValue.OrganizationID, nil
  18459. }
  18460. // AddOrganizationID adds u to the "organization_id" field.
  18461. func (m *LabelMutation) AddOrganizationID(u int64) {
  18462. if m.addorganization_id != nil {
  18463. *m.addorganization_id += u
  18464. } else {
  18465. m.addorganization_id = &u
  18466. }
  18467. }
  18468. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18469. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  18470. v := m.addorganization_id
  18471. if v == nil {
  18472. return
  18473. }
  18474. return *v, true
  18475. }
  18476. // ClearOrganizationID clears the value of the "organization_id" field.
  18477. func (m *LabelMutation) ClearOrganizationID() {
  18478. m.organization_id = nil
  18479. m.addorganization_id = nil
  18480. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  18481. }
  18482. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18483. func (m *LabelMutation) OrganizationIDCleared() bool {
  18484. _, ok := m.clearedFields[label.FieldOrganizationID]
  18485. return ok
  18486. }
  18487. // ResetOrganizationID resets all changes to the "organization_id" field.
  18488. func (m *LabelMutation) ResetOrganizationID() {
  18489. m.organization_id = nil
  18490. m.addorganization_id = nil
  18491. delete(m.clearedFields, label.FieldOrganizationID)
  18492. }
  18493. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  18494. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  18495. if m.label_relationships == nil {
  18496. m.label_relationships = make(map[uint64]struct{})
  18497. }
  18498. for i := range ids {
  18499. m.label_relationships[ids[i]] = struct{}{}
  18500. }
  18501. }
  18502. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  18503. func (m *LabelMutation) ClearLabelRelationships() {
  18504. m.clearedlabel_relationships = true
  18505. }
  18506. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  18507. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  18508. return m.clearedlabel_relationships
  18509. }
  18510. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  18511. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  18512. if m.removedlabel_relationships == nil {
  18513. m.removedlabel_relationships = make(map[uint64]struct{})
  18514. }
  18515. for i := range ids {
  18516. delete(m.label_relationships, ids[i])
  18517. m.removedlabel_relationships[ids[i]] = struct{}{}
  18518. }
  18519. }
  18520. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  18521. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  18522. for id := range m.removedlabel_relationships {
  18523. ids = append(ids, id)
  18524. }
  18525. return
  18526. }
  18527. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  18528. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  18529. for id := range m.label_relationships {
  18530. ids = append(ids, id)
  18531. }
  18532. return
  18533. }
  18534. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  18535. func (m *LabelMutation) ResetLabelRelationships() {
  18536. m.label_relationships = nil
  18537. m.clearedlabel_relationships = false
  18538. m.removedlabel_relationships = nil
  18539. }
  18540. // Where appends a list predicates to the LabelMutation builder.
  18541. func (m *LabelMutation) Where(ps ...predicate.Label) {
  18542. m.predicates = append(m.predicates, ps...)
  18543. }
  18544. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  18545. // users can use type-assertion to append predicates that do not depend on any generated package.
  18546. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  18547. p := make([]predicate.Label, len(ps))
  18548. for i := range ps {
  18549. p[i] = ps[i]
  18550. }
  18551. m.Where(p...)
  18552. }
  18553. // Op returns the operation name.
  18554. func (m *LabelMutation) Op() Op {
  18555. return m.op
  18556. }
  18557. // SetOp allows setting the mutation operation.
  18558. func (m *LabelMutation) SetOp(op Op) {
  18559. m.op = op
  18560. }
  18561. // Type returns the node type of this mutation (Label).
  18562. func (m *LabelMutation) Type() string {
  18563. return m.typ
  18564. }
  18565. // Fields returns all fields that were changed during this mutation. Note that in
  18566. // order to get all numeric fields that were incremented/decremented, call
  18567. // AddedFields().
  18568. func (m *LabelMutation) Fields() []string {
  18569. fields := make([]string, 0, 9)
  18570. if m.created_at != nil {
  18571. fields = append(fields, label.FieldCreatedAt)
  18572. }
  18573. if m.updated_at != nil {
  18574. fields = append(fields, label.FieldUpdatedAt)
  18575. }
  18576. if m.status != nil {
  18577. fields = append(fields, label.FieldStatus)
  18578. }
  18579. if m._type != nil {
  18580. fields = append(fields, label.FieldType)
  18581. }
  18582. if m.name != nil {
  18583. fields = append(fields, label.FieldName)
  18584. }
  18585. if m.from != nil {
  18586. fields = append(fields, label.FieldFrom)
  18587. }
  18588. if m.mode != nil {
  18589. fields = append(fields, label.FieldMode)
  18590. }
  18591. if m.conditions != nil {
  18592. fields = append(fields, label.FieldConditions)
  18593. }
  18594. if m.organization_id != nil {
  18595. fields = append(fields, label.FieldOrganizationID)
  18596. }
  18597. return fields
  18598. }
  18599. // Field returns the value of a field with the given name. The second boolean
  18600. // return value indicates that this field was not set, or was not defined in the
  18601. // schema.
  18602. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  18603. switch name {
  18604. case label.FieldCreatedAt:
  18605. return m.CreatedAt()
  18606. case label.FieldUpdatedAt:
  18607. return m.UpdatedAt()
  18608. case label.FieldStatus:
  18609. return m.Status()
  18610. case label.FieldType:
  18611. return m.GetType()
  18612. case label.FieldName:
  18613. return m.Name()
  18614. case label.FieldFrom:
  18615. return m.From()
  18616. case label.FieldMode:
  18617. return m.Mode()
  18618. case label.FieldConditions:
  18619. return m.Conditions()
  18620. case label.FieldOrganizationID:
  18621. return m.OrganizationID()
  18622. }
  18623. return nil, false
  18624. }
  18625. // OldField returns the old value of the field from the database. An error is
  18626. // returned if the mutation operation is not UpdateOne, or the query to the
  18627. // database failed.
  18628. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18629. switch name {
  18630. case label.FieldCreatedAt:
  18631. return m.OldCreatedAt(ctx)
  18632. case label.FieldUpdatedAt:
  18633. return m.OldUpdatedAt(ctx)
  18634. case label.FieldStatus:
  18635. return m.OldStatus(ctx)
  18636. case label.FieldType:
  18637. return m.OldType(ctx)
  18638. case label.FieldName:
  18639. return m.OldName(ctx)
  18640. case label.FieldFrom:
  18641. return m.OldFrom(ctx)
  18642. case label.FieldMode:
  18643. return m.OldMode(ctx)
  18644. case label.FieldConditions:
  18645. return m.OldConditions(ctx)
  18646. case label.FieldOrganizationID:
  18647. return m.OldOrganizationID(ctx)
  18648. }
  18649. return nil, fmt.Errorf("unknown Label field %s", name)
  18650. }
  18651. // SetField sets the value of a field with the given name. It returns an error if
  18652. // the field is not defined in the schema, or if the type mismatched the field
  18653. // type.
  18654. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  18655. switch name {
  18656. case label.FieldCreatedAt:
  18657. v, ok := value.(time.Time)
  18658. if !ok {
  18659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18660. }
  18661. m.SetCreatedAt(v)
  18662. return nil
  18663. case label.FieldUpdatedAt:
  18664. v, ok := value.(time.Time)
  18665. if !ok {
  18666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18667. }
  18668. m.SetUpdatedAt(v)
  18669. return nil
  18670. case label.FieldStatus:
  18671. v, ok := value.(uint8)
  18672. if !ok {
  18673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18674. }
  18675. m.SetStatus(v)
  18676. return nil
  18677. case label.FieldType:
  18678. v, ok := value.(int)
  18679. if !ok {
  18680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18681. }
  18682. m.SetType(v)
  18683. return nil
  18684. case label.FieldName:
  18685. v, ok := value.(string)
  18686. if !ok {
  18687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18688. }
  18689. m.SetName(v)
  18690. return nil
  18691. case label.FieldFrom:
  18692. v, ok := value.(int)
  18693. if !ok {
  18694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18695. }
  18696. m.SetFrom(v)
  18697. return nil
  18698. case label.FieldMode:
  18699. v, ok := value.(int)
  18700. if !ok {
  18701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18702. }
  18703. m.SetMode(v)
  18704. return nil
  18705. case label.FieldConditions:
  18706. v, ok := value.(string)
  18707. if !ok {
  18708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18709. }
  18710. m.SetConditions(v)
  18711. return nil
  18712. case label.FieldOrganizationID:
  18713. v, ok := value.(uint64)
  18714. if !ok {
  18715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18716. }
  18717. m.SetOrganizationID(v)
  18718. return nil
  18719. }
  18720. return fmt.Errorf("unknown Label field %s", name)
  18721. }
  18722. // AddedFields returns all numeric fields that were incremented/decremented during
  18723. // this mutation.
  18724. func (m *LabelMutation) AddedFields() []string {
  18725. var fields []string
  18726. if m.addstatus != nil {
  18727. fields = append(fields, label.FieldStatus)
  18728. }
  18729. if m.add_type != nil {
  18730. fields = append(fields, label.FieldType)
  18731. }
  18732. if m.addfrom != nil {
  18733. fields = append(fields, label.FieldFrom)
  18734. }
  18735. if m.addmode != nil {
  18736. fields = append(fields, label.FieldMode)
  18737. }
  18738. if m.addorganization_id != nil {
  18739. fields = append(fields, label.FieldOrganizationID)
  18740. }
  18741. return fields
  18742. }
  18743. // AddedField returns the numeric value that was incremented/decremented on a field
  18744. // with the given name. The second boolean return value indicates that this field
  18745. // was not set, or was not defined in the schema.
  18746. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  18747. switch name {
  18748. case label.FieldStatus:
  18749. return m.AddedStatus()
  18750. case label.FieldType:
  18751. return m.AddedType()
  18752. case label.FieldFrom:
  18753. return m.AddedFrom()
  18754. case label.FieldMode:
  18755. return m.AddedMode()
  18756. case label.FieldOrganizationID:
  18757. return m.AddedOrganizationID()
  18758. }
  18759. return nil, false
  18760. }
  18761. // AddField adds the value to the field with the given name. It returns an error if
  18762. // the field is not defined in the schema, or if the type mismatched the field
  18763. // type.
  18764. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  18765. switch name {
  18766. case label.FieldStatus:
  18767. v, ok := value.(int8)
  18768. if !ok {
  18769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18770. }
  18771. m.AddStatus(v)
  18772. return nil
  18773. case label.FieldType:
  18774. v, ok := value.(int)
  18775. if !ok {
  18776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18777. }
  18778. m.AddType(v)
  18779. return nil
  18780. case label.FieldFrom:
  18781. v, ok := value.(int)
  18782. if !ok {
  18783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18784. }
  18785. m.AddFrom(v)
  18786. return nil
  18787. case label.FieldMode:
  18788. v, ok := value.(int)
  18789. if !ok {
  18790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18791. }
  18792. m.AddMode(v)
  18793. return nil
  18794. case label.FieldOrganizationID:
  18795. v, ok := value.(int64)
  18796. if !ok {
  18797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18798. }
  18799. m.AddOrganizationID(v)
  18800. return nil
  18801. }
  18802. return fmt.Errorf("unknown Label numeric field %s", name)
  18803. }
  18804. // ClearedFields returns all nullable fields that were cleared during this
  18805. // mutation.
  18806. func (m *LabelMutation) ClearedFields() []string {
  18807. var fields []string
  18808. if m.FieldCleared(label.FieldStatus) {
  18809. fields = append(fields, label.FieldStatus)
  18810. }
  18811. if m.FieldCleared(label.FieldConditions) {
  18812. fields = append(fields, label.FieldConditions)
  18813. }
  18814. if m.FieldCleared(label.FieldOrganizationID) {
  18815. fields = append(fields, label.FieldOrganizationID)
  18816. }
  18817. return fields
  18818. }
  18819. // FieldCleared returns a boolean indicating if a field with the given name was
  18820. // cleared in this mutation.
  18821. func (m *LabelMutation) FieldCleared(name string) bool {
  18822. _, ok := m.clearedFields[name]
  18823. return ok
  18824. }
  18825. // ClearField clears the value of the field with the given name. It returns an
  18826. // error if the field is not defined in the schema.
  18827. func (m *LabelMutation) ClearField(name string) error {
  18828. switch name {
  18829. case label.FieldStatus:
  18830. m.ClearStatus()
  18831. return nil
  18832. case label.FieldConditions:
  18833. m.ClearConditions()
  18834. return nil
  18835. case label.FieldOrganizationID:
  18836. m.ClearOrganizationID()
  18837. return nil
  18838. }
  18839. return fmt.Errorf("unknown Label nullable field %s", name)
  18840. }
  18841. // ResetField resets all changes in the mutation for the field with the given name.
  18842. // It returns an error if the field is not defined in the schema.
  18843. func (m *LabelMutation) ResetField(name string) error {
  18844. switch name {
  18845. case label.FieldCreatedAt:
  18846. m.ResetCreatedAt()
  18847. return nil
  18848. case label.FieldUpdatedAt:
  18849. m.ResetUpdatedAt()
  18850. return nil
  18851. case label.FieldStatus:
  18852. m.ResetStatus()
  18853. return nil
  18854. case label.FieldType:
  18855. m.ResetType()
  18856. return nil
  18857. case label.FieldName:
  18858. m.ResetName()
  18859. return nil
  18860. case label.FieldFrom:
  18861. m.ResetFrom()
  18862. return nil
  18863. case label.FieldMode:
  18864. m.ResetMode()
  18865. return nil
  18866. case label.FieldConditions:
  18867. m.ResetConditions()
  18868. return nil
  18869. case label.FieldOrganizationID:
  18870. m.ResetOrganizationID()
  18871. return nil
  18872. }
  18873. return fmt.Errorf("unknown Label field %s", name)
  18874. }
  18875. // AddedEdges returns all edge names that were set/added in this mutation.
  18876. func (m *LabelMutation) AddedEdges() []string {
  18877. edges := make([]string, 0, 1)
  18878. if m.label_relationships != nil {
  18879. edges = append(edges, label.EdgeLabelRelationships)
  18880. }
  18881. return edges
  18882. }
  18883. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18884. // name in this mutation.
  18885. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  18886. switch name {
  18887. case label.EdgeLabelRelationships:
  18888. ids := make([]ent.Value, 0, len(m.label_relationships))
  18889. for id := range m.label_relationships {
  18890. ids = append(ids, id)
  18891. }
  18892. return ids
  18893. }
  18894. return nil
  18895. }
  18896. // RemovedEdges returns all edge names that were removed in this mutation.
  18897. func (m *LabelMutation) RemovedEdges() []string {
  18898. edges := make([]string, 0, 1)
  18899. if m.removedlabel_relationships != nil {
  18900. edges = append(edges, label.EdgeLabelRelationships)
  18901. }
  18902. return edges
  18903. }
  18904. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18905. // the given name in this mutation.
  18906. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  18907. switch name {
  18908. case label.EdgeLabelRelationships:
  18909. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  18910. for id := range m.removedlabel_relationships {
  18911. ids = append(ids, id)
  18912. }
  18913. return ids
  18914. }
  18915. return nil
  18916. }
  18917. // ClearedEdges returns all edge names that were cleared in this mutation.
  18918. func (m *LabelMutation) ClearedEdges() []string {
  18919. edges := make([]string, 0, 1)
  18920. if m.clearedlabel_relationships {
  18921. edges = append(edges, label.EdgeLabelRelationships)
  18922. }
  18923. return edges
  18924. }
  18925. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18926. // was cleared in this mutation.
  18927. func (m *LabelMutation) EdgeCleared(name string) bool {
  18928. switch name {
  18929. case label.EdgeLabelRelationships:
  18930. return m.clearedlabel_relationships
  18931. }
  18932. return false
  18933. }
  18934. // ClearEdge clears the value of the edge with the given name. It returns an error
  18935. // if that edge is not defined in the schema.
  18936. func (m *LabelMutation) ClearEdge(name string) error {
  18937. switch name {
  18938. }
  18939. return fmt.Errorf("unknown Label unique edge %s", name)
  18940. }
  18941. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18942. // It returns an error if the edge is not defined in the schema.
  18943. func (m *LabelMutation) ResetEdge(name string) error {
  18944. switch name {
  18945. case label.EdgeLabelRelationships:
  18946. m.ResetLabelRelationships()
  18947. return nil
  18948. }
  18949. return fmt.Errorf("unknown Label edge %s", name)
  18950. }
  18951. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  18952. type LabelRelationshipMutation struct {
  18953. config
  18954. op Op
  18955. typ string
  18956. id *uint64
  18957. created_at *time.Time
  18958. updated_at *time.Time
  18959. status *uint8
  18960. addstatus *int8
  18961. organization_id *uint64
  18962. addorganization_id *int64
  18963. clearedFields map[string]struct{}
  18964. contacts *uint64
  18965. clearedcontacts bool
  18966. labels *uint64
  18967. clearedlabels bool
  18968. done bool
  18969. oldValue func(context.Context) (*LabelRelationship, error)
  18970. predicates []predicate.LabelRelationship
  18971. }
  18972. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  18973. // labelrelationshipOption allows management of the mutation configuration using functional options.
  18974. type labelrelationshipOption func(*LabelRelationshipMutation)
  18975. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  18976. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  18977. m := &LabelRelationshipMutation{
  18978. config: c,
  18979. op: op,
  18980. typ: TypeLabelRelationship,
  18981. clearedFields: make(map[string]struct{}),
  18982. }
  18983. for _, opt := range opts {
  18984. opt(m)
  18985. }
  18986. return m
  18987. }
  18988. // withLabelRelationshipID sets the ID field of the mutation.
  18989. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  18990. return func(m *LabelRelationshipMutation) {
  18991. var (
  18992. err error
  18993. once sync.Once
  18994. value *LabelRelationship
  18995. )
  18996. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  18997. once.Do(func() {
  18998. if m.done {
  18999. err = errors.New("querying old values post mutation is not allowed")
  19000. } else {
  19001. value, err = m.Client().LabelRelationship.Get(ctx, id)
  19002. }
  19003. })
  19004. return value, err
  19005. }
  19006. m.id = &id
  19007. }
  19008. }
  19009. // withLabelRelationship sets the old LabelRelationship of the mutation.
  19010. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  19011. return func(m *LabelRelationshipMutation) {
  19012. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  19013. return node, nil
  19014. }
  19015. m.id = &node.ID
  19016. }
  19017. }
  19018. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19019. // executed in a transaction (ent.Tx), a transactional client is returned.
  19020. func (m LabelRelationshipMutation) Client() *Client {
  19021. client := &Client{config: m.config}
  19022. client.init()
  19023. return client
  19024. }
  19025. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19026. // it returns an error otherwise.
  19027. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  19028. if _, ok := m.driver.(*txDriver); !ok {
  19029. return nil, errors.New("ent: mutation is not running in a transaction")
  19030. }
  19031. tx := &Tx{config: m.config}
  19032. tx.init()
  19033. return tx, nil
  19034. }
  19035. // SetID sets the value of the id field. Note that this
  19036. // operation is only accepted on creation of LabelRelationship entities.
  19037. func (m *LabelRelationshipMutation) SetID(id uint64) {
  19038. m.id = &id
  19039. }
  19040. // ID returns the ID value in the mutation. Note that the ID is only available
  19041. // if it was provided to the builder or after it was returned from the database.
  19042. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  19043. if m.id == nil {
  19044. return
  19045. }
  19046. return *m.id, true
  19047. }
  19048. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19049. // That means, if the mutation is applied within a transaction with an isolation level such
  19050. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19051. // or updated by the mutation.
  19052. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  19053. switch {
  19054. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19055. id, exists := m.ID()
  19056. if exists {
  19057. return []uint64{id}, nil
  19058. }
  19059. fallthrough
  19060. case m.op.Is(OpUpdate | OpDelete):
  19061. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  19062. default:
  19063. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19064. }
  19065. }
  19066. // SetCreatedAt sets the "created_at" field.
  19067. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  19068. m.created_at = &t
  19069. }
  19070. // CreatedAt returns the value of the "created_at" field in the mutation.
  19071. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  19072. v := m.created_at
  19073. if v == nil {
  19074. return
  19075. }
  19076. return *v, true
  19077. }
  19078. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  19079. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19081. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19082. if !m.op.Is(OpUpdateOne) {
  19083. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19084. }
  19085. if m.id == nil || m.oldValue == nil {
  19086. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19087. }
  19088. oldValue, err := m.oldValue(ctx)
  19089. if err != nil {
  19090. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19091. }
  19092. return oldValue.CreatedAt, nil
  19093. }
  19094. // ResetCreatedAt resets all changes to the "created_at" field.
  19095. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  19096. m.created_at = nil
  19097. }
  19098. // SetUpdatedAt sets the "updated_at" field.
  19099. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  19100. m.updated_at = &t
  19101. }
  19102. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19103. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  19104. v := m.updated_at
  19105. if v == nil {
  19106. return
  19107. }
  19108. return *v, true
  19109. }
  19110. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  19111. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19113. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19114. if !m.op.Is(OpUpdateOne) {
  19115. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19116. }
  19117. if m.id == nil || m.oldValue == nil {
  19118. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19119. }
  19120. oldValue, err := m.oldValue(ctx)
  19121. if err != nil {
  19122. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19123. }
  19124. return oldValue.UpdatedAt, nil
  19125. }
  19126. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19127. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  19128. m.updated_at = nil
  19129. }
  19130. // SetStatus sets the "status" field.
  19131. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  19132. m.status = &u
  19133. m.addstatus = nil
  19134. }
  19135. // Status returns the value of the "status" field in the mutation.
  19136. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  19137. v := m.status
  19138. if v == nil {
  19139. return
  19140. }
  19141. return *v, true
  19142. }
  19143. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  19144. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19146. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19147. if !m.op.Is(OpUpdateOne) {
  19148. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19149. }
  19150. if m.id == nil || m.oldValue == nil {
  19151. return v, errors.New("OldStatus requires an ID field in the mutation")
  19152. }
  19153. oldValue, err := m.oldValue(ctx)
  19154. if err != nil {
  19155. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19156. }
  19157. return oldValue.Status, nil
  19158. }
  19159. // AddStatus adds u to the "status" field.
  19160. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  19161. if m.addstatus != nil {
  19162. *m.addstatus += u
  19163. } else {
  19164. m.addstatus = &u
  19165. }
  19166. }
  19167. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19168. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  19169. v := m.addstatus
  19170. if v == nil {
  19171. return
  19172. }
  19173. return *v, true
  19174. }
  19175. // ClearStatus clears the value of the "status" field.
  19176. func (m *LabelRelationshipMutation) ClearStatus() {
  19177. m.status = nil
  19178. m.addstatus = nil
  19179. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  19180. }
  19181. // StatusCleared returns if the "status" field was cleared in this mutation.
  19182. func (m *LabelRelationshipMutation) StatusCleared() bool {
  19183. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  19184. return ok
  19185. }
  19186. // ResetStatus resets all changes to the "status" field.
  19187. func (m *LabelRelationshipMutation) ResetStatus() {
  19188. m.status = nil
  19189. m.addstatus = nil
  19190. delete(m.clearedFields, labelrelationship.FieldStatus)
  19191. }
  19192. // SetLabelID sets the "label_id" field.
  19193. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  19194. m.labels = &u
  19195. }
  19196. // LabelID returns the value of the "label_id" field in the mutation.
  19197. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  19198. v := m.labels
  19199. if v == nil {
  19200. return
  19201. }
  19202. return *v, true
  19203. }
  19204. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  19205. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19207. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  19208. if !m.op.Is(OpUpdateOne) {
  19209. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  19210. }
  19211. if m.id == nil || m.oldValue == nil {
  19212. return v, errors.New("OldLabelID requires an ID field in the mutation")
  19213. }
  19214. oldValue, err := m.oldValue(ctx)
  19215. if err != nil {
  19216. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  19217. }
  19218. return oldValue.LabelID, nil
  19219. }
  19220. // ResetLabelID resets all changes to the "label_id" field.
  19221. func (m *LabelRelationshipMutation) ResetLabelID() {
  19222. m.labels = nil
  19223. }
  19224. // SetContactID sets the "contact_id" field.
  19225. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  19226. m.contacts = &u
  19227. }
  19228. // ContactID returns the value of the "contact_id" field in the mutation.
  19229. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  19230. v := m.contacts
  19231. if v == nil {
  19232. return
  19233. }
  19234. return *v, true
  19235. }
  19236. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  19237. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19239. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19240. if !m.op.Is(OpUpdateOne) {
  19241. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19242. }
  19243. if m.id == nil || m.oldValue == nil {
  19244. return v, errors.New("OldContactID requires an ID field in the mutation")
  19245. }
  19246. oldValue, err := m.oldValue(ctx)
  19247. if err != nil {
  19248. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19249. }
  19250. return oldValue.ContactID, nil
  19251. }
  19252. // ResetContactID resets all changes to the "contact_id" field.
  19253. func (m *LabelRelationshipMutation) ResetContactID() {
  19254. m.contacts = nil
  19255. }
  19256. // SetOrganizationID sets the "organization_id" field.
  19257. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  19258. m.organization_id = &u
  19259. m.addorganization_id = nil
  19260. }
  19261. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19262. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  19263. v := m.organization_id
  19264. if v == nil {
  19265. return
  19266. }
  19267. return *v, true
  19268. }
  19269. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  19270. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19272. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19273. if !m.op.Is(OpUpdateOne) {
  19274. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19275. }
  19276. if m.id == nil || m.oldValue == nil {
  19277. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19278. }
  19279. oldValue, err := m.oldValue(ctx)
  19280. if err != nil {
  19281. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19282. }
  19283. return oldValue.OrganizationID, nil
  19284. }
  19285. // AddOrganizationID adds u to the "organization_id" field.
  19286. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  19287. if m.addorganization_id != nil {
  19288. *m.addorganization_id += u
  19289. } else {
  19290. m.addorganization_id = &u
  19291. }
  19292. }
  19293. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19294. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  19295. v := m.addorganization_id
  19296. if v == nil {
  19297. return
  19298. }
  19299. return *v, true
  19300. }
  19301. // ClearOrganizationID clears the value of the "organization_id" field.
  19302. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  19303. m.organization_id = nil
  19304. m.addorganization_id = nil
  19305. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  19306. }
  19307. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19308. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  19309. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  19310. return ok
  19311. }
  19312. // ResetOrganizationID resets all changes to the "organization_id" field.
  19313. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  19314. m.organization_id = nil
  19315. m.addorganization_id = nil
  19316. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  19317. }
  19318. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  19319. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  19320. m.contacts = &id
  19321. }
  19322. // ClearContacts clears the "contacts" edge to the Contact entity.
  19323. func (m *LabelRelationshipMutation) ClearContacts() {
  19324. m.clearedcontacts = true
  19325. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  19326. }
  19327. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  19328. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  19329. return m.clearedcontacts
  19330. }
  19331. // ContactsID returns the "contacts" edge ID in the mutation.
  19332. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  19333. if m.contacts != nil {
  19334. return *m.contacts, true
  19335. }
  19336. return
  19337. }
  19338. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  19339. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19340. // ContactsID instead. It exists only for internal usage by the builders.
  19341. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  19342. if id := m.contacts; id != nil {
  19343. ids = append(ids, *id)
  19344. }
  19345. return
  19346. }
  19347. // ResetContacts resets all changes to the "contacts" edge.
  19348. func (m *LabelRelationshipMutation) ResetContacts() {
  19349. m.contacts = nil
  19350. m.clearedcontacts = false
  19351. }
  19352. // SetLabelsID sets the "labels" edge to the Label entity by id.
  19353. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  19354. m.labels = &id
  19355. }
  19356. // ClearLabels clears the "labels" edge to the Label entity.
  19357. func (m *LabelRelationshipMutation) ClearLabels() {
  19358. m.clearedlabels = true
  19359. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  19360. }
  19361. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  19362. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  19363. return m.clearedlabels
  19364. }
  19365. // LabelsID returns the "labels" edge ID in the mutation.
  19366. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  19367. if m.labels != nil {
  19368. return *m.labels, true
  19369. }
  19370. return
  19371. }
  19372. // LabelsIDs returns the "labels" edge IDs in the mutation.
  19373. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19374. // LabelsID instead. It exists only for internal usage by the builders.
  19375. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  19376. if id := m.labels; id != nil {
  19377. ids = append(ids, *id)
  19378. }
  19379. return
  19380. }
  19381. // ResetLabels resets all changes to the "labels" edge.
  19382. func (m *LabelRelationshipMutation) ResetLabels() {
  19383. m.labels = nil
  19384. m.clearedlabels = false
  19385. }
  19386. // Where appends a list predicates to the LabelRelationshipMutation builder.
  19387. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  19388. m.predicates = append(m.predicates, ps...)
  19389. }
  19390. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  19391. // users can use type-assertion to append predicates that do not depend on any generated package.
  19392. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  19393. p := make([]predicate.LabelRelationship, len(ps))
  19394. for i := range ps {
  19395. p[i] = ps[i]
  19396. }
  19397. m.Where(p...)
  19398. }
  19399. // Op returns the operation name.
  19400. func (m *LabelRelationshipMutation) Op() Op {
  19401. return m.op
  19402. }
  19403. // SetOp allows setting the mutation operation.
  19404. func (m *LabelRelationshipMutation) SetOp(op Op) {
  19405. m.op = op
  19406. }
  19407. // Type returns the node type of this mutation (LabelRelationship).
  19408. func (m *LabelRelationshipMutation) Type() string {
  19409. return m.typ
  19410. }
  19411. // Fields returns all fields that were changed during this mutation. Note that in
  19412. // order to get all numeric fields that were incremented/decremented, call
  19413. // AddedFields().
  19414. func (m *LabelRelationshipMutation) Fields() []string {
  19415. fields := make([]string, 0, 6)
  19416. if m.created_at != nil {
  19417. fields = append(fields, labelrelationship.FieldCreatedAt)
  19418. }
  19419. if m.updated_at != nil {
  19420. fields = append(fields, labelrelationship.FieldUpdatedAt)
  19421. }
  19422. if m.status != nil {
  19423. fields = append(fields, labelrelationship.FieldStatus)
  19424. }
  19425. if m.labels != nil {
  19426. fields = append(fields, labelrelationship.FieldLabelID)
  19427. }
  19428. if m.contacts != nil {
  19429. fields = append(fields, labelrelationship.FieldContactID)
  19430. }
  19431. if m.organization_id != nil {
  19432. fields = append(fields, labelrelationship.FieldOrganizationID)
  19433. }
  19434. return fields
  19435. }
  19436. // Field returns the value of a field with the given name. The second boolean
  19437. // return value indicates that this field was not set, or was not defined in the
  19438. // schema.
  19439. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  19440. switch name {
  19441. case labelrelationship.FieldCreatedAt:
  19442. return m.CreatedAt()
  19443. case labelrelationship.FieldUpdatedAt:
  19444. return m.UpdatedAt()
  19445. case labelrelationship.FieldStatus:
  19446. return m.Status()
  19447. case labelrelationship.FieldLabelID:
  19448. return m.LabelID()
  19449. case labelrelationship.FieldContactID:
  19450. return m.ContactID()
  19451. case labelrelationship.FieldOrganizationID:
  19452. return m.OrganizationID()
  19453. }
  19454. return nil, false
  19455. }
  19456. // OldField returns the old value of the field from the database. An error is
  19457. // returned if the mutation operation is not UpdateOne, or the query to the
  19458. // database failed.
  19459. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19460. switch name {
  19461. case labelrelationship.FieldCreatedAt:
  19462. return m.OldCreatedAt(ctx)
  19463. case labelrelationship.FieldUpdatedAt:
  19464. return m.OldUpdatedAt(ctx)
  19465. case labelrelationship.FieldStatus:
  19466. return m.OldStatus(ctx)
  19467. case labelrelationship.FieldLabelID:
  19468. return m.OldLabelID(ctx)
  19469. case labelrelationship.FieldContactID:
  19470. return m.OldContactID(ctx)
  19471. case labelrelationship.FieldOrganizationID:
  19472. return m.OldOrganizationID(ctx)
  19473. }
  19474. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  19475. }
  19476. // SetField sets the value of a field with the given name. It returns an error if
  19477. // the field is not defined in the schema, or if the type mismatched the field
  19478. // type.
  19479. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  19480. switch name {
  19481. case labelrelationship.FieldCreatedAt:
  19482. v, ok := value.(time.Time)
  19483. if !ok {
  19484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19485. }
  19486. m.SetCreatedAt(v)
  19487. return nil
  19488. case labelrelationship.FieldUpdatedAt:
  19489. v, ok := value.(time.Time)
  19490. if !ok {
  19491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19492. }
  19493. m.SetUpdatedAt(v)
  19494. return nil
  19495. case labelrelationship.FieldStatus:
  19496. v, ok := value.(uint8)
  19497. if !ok {
  19498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19499. }
  19500. m.SetStatus(v)
  19501. return nil
  19502. case labelrelationship.FieldLabelID:
  19503. v, ok := value.(uint64)
  19504. if !ok {
  19505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19506. }
  19507. m.SetLabelID(v)
  19508. return nil
  19509. case labelrelationship.FieldContactID:
  19510. v, ok := value.(uint64)
  19511. if !ok {
  19512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19513. }
  19514. m.SetContactID(v)
  19515. return nil
  19516. case labelrelationship.FieldOrganizationID:
  19517. v, ok := value.(uint64)
  19518. if !ok {
  19519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19520. }
  19521. m.SetOrganizationID(v)
  19522. return nil
  19523. }
  19524. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19525. }
  19526. // AddedFields returns all numeric fields that were incremented/decremented during
  19527. // this mutation.
  19528. func (m *LabelRelationshipMutation) AddedFields() []string {
  19529. var fields []string
  19530. if m.addstatus != nil {
  19531. fields = append(fields, labelrelationship.FieldStatus)
  19532. }
  19533. if m.addorganization_id != nil {
  19534. fields = append(fields, labelrelationship.FieldOrganizationID)
  19535. }
  19536. return fields
  19537. }
  19538. // AddedField returns the numeric value that was incremented/decremented on a field
  19539. // with the given name. The second boolean return value indicates that this field
  19540. // was not set, or was not defined in the schema.
  19541. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  19542. switch name {
  19543. case labelrelationship.FieldStatus:
  19544. return m.AddedStatus()
  19545. case labelrelationship.FieldOrganizationID:
  19546. return m.AddedOrganizationID()
  19547. }
  19548. return nil, false
  19549. }
  19550. // AddField adds the value to the field with the given name. It returns an error if
  19551. // the field is not defined in the schema, or if the type mismatched the field
  19552. // type.
  19553. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  19554. switch name {
  19555. case labelrelationship.FieldStatus:
  19556. v, ok := value.(int8)
  19557. if !ok {
  19558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19559. }
  19560. m.AddStatus(v)
  19561. return nil
  19562. case labelrelationship.FieldOrganizationID:
  19563. v, ok := value.(int64)
  19564. if !ok {
  19565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19566. }
  19567. m.AddOrganizationID(v)
  19568. return nil
  19569. }
  19570. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  19571. }
  19572. // ClearedFields returns all nullable fields that were cleared during this
  19573. // mutation.
  19574. func (m *LabelRelationshipMutation) ClearedFields() []string {
  19575. var fields []string
  19576. if m.FieldCleared(labelrelationship.FieldStatus) {
  19577. fields = append(fields, labelrelationship.FieldStatus)
  19578. }
  19579. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  19580. fields = append(fields, labelrelationship.FieldOrganizationID)
  19581. }
  19582. return fields
  19583. }
  19584. // FieldCleared returns a boolean indicating if a field with the given name was
  19585. // cleared in this mutation.
  19586. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  19587. _, ok := m.clearedFields[name]
  19588. return ok
  19589. }
  19590. // ClearField clears the value of the field with the given name. It returns an
  19591. // error if the field is not defined in the schema.
  19592. func (m *LabelRelationshipMutation) ClearField(name string) error {
  19593. switch name {
  19594. case labelrelationship.FieldStatus:
  19595. m.ClearStatus()
  19596. return nil
  19597. case labelrelationship.FieldOrganizationID:
  19598. m.ClearOrganizationID()
  19599. return nil
  19600. }
  19601. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  19602. }
  19603. // ResetField resets all changes in the mutation for the field with the given name.
  19604. // It returns an error if the field is not defined in the schema.
  19605. func (m *LabelRelationshipMutation) ResetField(name string) error {
  19606. switch name {
  19607. case labelrelationship.FieldCreatedAt:
  19608. m.ResetCreatedAt()
  19609. return nil
  19610. case labelrelationship.FieldUpdatedAt:
  19611. m.ResetUpdatedAt()
  19612. return nil
  19613. case labelrelationship.FieldStatus:
  19614. m.ResetStatus()
  19615. return nil
  19616. case labelrelationship.FieldLabelID:
  19617. m.ResetLabelID()
  19618. return nil
  19619. case labelrelationship.FieldContactID:
  19620. m.ResetContactID()
  19621. return nil
  19622. case labelrelationship.FieldOrganizationID:
  19623. m.ResetOrganizationID()
  19624. return nil
  19625. }
  19626. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19627. }
  19628. // AddedEdges returns all edge names that were set/added in this mutation.
  19629. func (m *LabelRelationshipMutation) AddedEdges() []string {
  19630. edges := make([]string, 0, 2)
  19631. if m.contacts != nil {
  19632. edges = append(edges, labelrelationship.EdgeContacts)
  19633. }
  19634. if m.labels != nil {
  19635. edges = append(edges, labelrelationship.EdgeLabels)
  19636. }
  19637. return edges
  19638. }
  19639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19640. // name in this mutation.
  19641. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  19642. switch name {
  19643. case labelrelationship.EdgeContacts:
  19644. if id := m.contacts; id != nil {
  19645. return []ent.Value{*id}
  19646. }
  19647. case labelrelationship.EdgeLabels:
  19648. if id := m.labels; id != nil {
  19649. return []ent.Value{*id}
  19650. }
  19651. }
  19652. return nil
  19653. }
  19654. // RemovedEdges returns all edge names that were removed in this mutation.
  19655. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  19656. edges := make([]string, 0, 2)
  19657. return edges
  19658. }
  19659. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19660. // the given name in this mutation.
  19661. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  19662. return nil
  19663. }
  19664. // ClearedEdges returns all edge names that were cleared in this mutation.
  19665. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  19666. edges := make([]string, 0, 2)
  19667. if m.clearedcontacts {
  19668. edges = append(edges, labelrelationship.EdgeContacts)
  19669. }
  19670. if m.clearedlabels {
  19671. edges = append(edges, labelrelationship.EdgeLabels)
  19672. }
  19673. return edges
  19674. }
  19675. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19676. // was cleared in this mutation.
  19677. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  19678. switch name {
  19679. case labelrelationship.EdgeContacts:
  19680. return m.clearedcontacts
  19681. case labelrelationship.EdgeLabels:
  19682. return m.clearedlabels
  19683. }
  19684. return false
  19685. }
  19686. // ClearEdge clears the value of the edge with the given name. It returns an error
  19687. // if that edge is not defined in the schema.
  19688. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  19689. switch name {
  19690. case labelrelationship.EdgeContacts:
  19691. m.ClearContacts()
  19692. return nil
  19693. case labelrelationship.EdgeLabels:
  19694. m.ClearLabels()
  19695. return nil
  19696. }
  19697. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  19698. }
  19699. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19700. // It returns an error if the edge is not defined in the schema.
  19701. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  19702. switch name {
  19703. case labelrelationship.EdgeContacts:
  19704. m.ResetContacts()
  19705. return nil
  19706. case labelrelationship.EdgeLabels:
  19707. m.ResetLabels()
  19708. return nil
  19709. }
  19710. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  19711. }
  19712. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  19713. type LabelTaggingMutation struct {
  19714. config
  19715. op Op
  19716. typ string
  19717. id *uint64
  19718. created_at *time.Time
  19719. updated_at *time.Time
  19720. status *uint8
  19721. addstatus *int8
  19722. deleted_at *time.Time
  19723. organization_id *uint64
  19724. addorganization_id *int64
  19725. _type *int
  19726. add_type *int
  19727. conditions *string
  19728. action_label_add *[]uint64
  19729. appendaction_label_add []uint64
  19730. action_label_del *[]uint64
  19731. appendaction_label_del []uint64
  19732. clearedFields map[string]struct{}
  19733. done bool
  19734. oldValue func(context.Context) (*LabelTagging, error)
  19735. predicates []predicate.LabelTagging
  19736. }
  19737. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  19738. // labeltaggingOption allows management of the mutation configuration using functional options.
  19739. type labeltaggingOption func(*LabelTaggingMutation)
  19740. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  19741. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  19742. m := &LabelTaggingMutation{
  19743. config: c,
  19744. op: op,
  19745. typ: TypeLabelTagging,
  19746. clearedFields: make(map[string]struct{}),
  19747. }
  19748. for _, opt := range opts {
  19749. opt(m)
  19750. }
  19751. return m
  19752. }
  19753. // withLabelTaggingID sets the ID field of the mutation.
  19754. func withLabelTaggingID(id uint64) labeltaggingOption {
  19755. return func(m *LabelTaggingMutation) {
  19756. var (
  19757. err error
  19758. once sync.Once
  19759. value *LabelTagging
  19760. )
  19761. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  19762. once.Do(func() {
  19763. if m.done {
  19764. err = errors.New("querying old values post mutation is not allowed")
  19765. } else {
  19766. value, err = m.Client().LabelTagging.Get(ctx, id)
  19767. }
  19768. })
  19769. return value, err
  19770. }
  19771. m.id = &id
  19772. }
  19773. }
  19774. // withLabelTagging sets the old LabelTagging of the mutation.
  19775. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  19776. return func(m *LabelTaggingMutation) {
  19777. m.oldValue = func(context.Context) (*LabelTagging, error) {
  19778. return node, nil
  19779. }
  19780. m.id = &node.ID
  19781. }
  19782. }
  19783. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19784. // executed in a transaction (ent.Tx), a transactional client is returned.
  19785. func (m LabelTaggingMutation) Client() *Client {
  19786. client := &Client{config: m.config}
  19787. client.init()
  19788. return client
  19789. }
  19790. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19791. // it returns an error otherwise.
  19792. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  19793. if _, ok := m.driver.(*txDriver); !ok {
  19794. return nil, errors.New("ent: mutation is not running in a transaction")
  19795. }
  19796. tx := &Tx{config: m.config}
  19797. tx.init()
  19798. return tx, nil
  19799. }
  19800. // SetID sets the value of the id field. Note that this
  19801. // operation is only accepted on creation of LabelTagging entities.
  19802. func (m *LabelTaggingMutation) SetID(id uint64) {
  19803. m.id = &id
  19804. }
  19805. // ID returns the ID value in the mutation. Note that the ID is only available
  19806. // if it was provided to the builder or after it was returned from the database.
  19807. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  19808. if m.id == nil {
  19809. return
  19810. }
  19811. return *m.id, true
  19812. }
  19813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19814. // That means, if the mutation is applied within a transaction with an isolation level such
  19815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19816. // or updated by the mutation.
  19817. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  19818. switch {
  19819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19820. id, exists := m.ID()
  19821. if exists {
  19822. return []uint64{id}, nil
  19823. }
  19824. fallthrough
  19825. case m.op.Is(OpUpdate | OpDelete):
  19826. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  19827. default:
  19828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19829. }
  19830. }
  19831. // SetCreatedAt sets the "created_at" field.
  19832. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  19833. m.created_at = &t
  19834. }
  19835. // CreatedAt returns the value of the "created_at" field in the mutation.
  19836. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  19837. v := m.created_at
  19838. if v == nil {
  19839. return
  19840. }
  19841. return *v, true
  19842. }
  19843. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  19844. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19846. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19847. if !m.op.Is(OpUpdateOne) {
  19848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19849. }
  19850. if m.id == nil || m.oldValue == nil {
  19851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19852. }
  19853. oldValue, err := m.oldValue(ctx)
  19854. if err != nil {
  19855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19856. }
  19857. return oldValue.CreatedAt, nil
  19858. }
  19859. // ResetCreatedAt resets all changes to the "created_at" field.
  19860. func (m *LabelTaggingMutation) ResetCreatedAt() {
  19861. m.created_at = nil
  19862. }
  19863. // SetUpdatedAt sets the "updated_at" field.
  19864. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  19865. m.updated_at = &t
  19866. }
  19867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19868. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  19869. v := m.updated_at
  19870. if v == nil {
  19871. return
  19872. }
  19873. return *v, true
  19874. }
  19875. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  19876. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19878. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19879. if !m.op.Is(OpUpdateOne) {
  19880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19881. }
  19882. if m.id == nil || m.oldValue == nil {
  19883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19884. }
  19885. oldValue, err := m.oldValue(ctx)
  19886. if err != nil {
  19887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19888. }
  19889. return oldValue.UpdatedAt, nil
  19890. }
  19891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19892. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  19893. m.updated_at = nil
  19894. }
  19895. // SetStatus sets the "status" field.
  19896. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  19897. m.status = &u
  19898. m.addstatus = nil
  19899. }
  19900. // Status returns the value of the "status" field in the mutation.
  19901. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  19902. v := m.status
  19903. if v == nil {
  19904. return
  19905. }
  19906. return *v, true
  19907. }
  19908. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  19909. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19911. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19912. if !m.op.Is(OpUpdateOne) {
  19913. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19914. }
  19915. if m.id == nil || m.oldValue == nil {
  19916. return v, errors.New("OldStatus requires an ID field in the mutation")
  19917. }
  19918. oldValue, err := m.oldValue(ctx)
  19919. if err != nil {
  19920. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19921. }
  19922. return oldValue.Status, nil
  19923. }
  19924. // AddStatus adds u to the "status" field.
  19925. func (m *LabelTaggingMutation) AddStatus(u int8) {
  19926. if m.addstatus != nil {
  19927. *m.addstatus += u
  19928. } else {
  19929. m.addstatus = &u
  19930. }
  19931. }
  19932. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19933. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  19934. v := m.addstatus
  19935. if v == nil {
  19936. return
  19937. }
  19938. return *v, true
  19939. }
  19940. // ClearStatus clears the value of the "status" field.
  19941. func (m *LabelTaggingMutation) ClearStatus() {
  19942. m.status = nil
  19943. m.addstatus = nil
  19944. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  19945. }
  19946. // StatusCleared returns if the "status" field was cleared in this mutation.
  19947. func (m *LabelTaggingMutation) StatusCleared() bool {
  19948. _, ok := m.clearedFields[labeltagging.FieldStatus]
  19949. return ok
  19950. }
  19951. // ResetStatus resets all changes to the "status" field.
  19952. func (m *LabelTaggingMutation) ResetStatus() {
  19953. m.status = nil
  19954. m.addstatus = nil
  19955. delete(m.clearedFields, labeltagging.FieldStatus)
  19956. }
  19957. // SetDeletedAt sets the "deleted_at" field.
  19958. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  19959. m.deleted_at = &t
  19960. }
  19961. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19962. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  19963. v := m.deleted_at
  19964. if v == nil {
  19965. return
  19966. }
  19967. return *v, true
  19968. }
  19969. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  19970. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19972. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19973. if !m.op.Is(OpUpdateOne) {
  19974. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19975. }
  19976. if m.id == nil || m.oldValue == nil {
  19977. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19978. }
  19979. oldValue, err := m.oldValue(ctx)
  19980. if err != nil {
  19981. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19982. }
  19983. return oldValue.DeletedAt, nil
  19984. }
  19985. // ClearDeletedAt clears the value of the "deleted_at" field.
  19986. func (m *LabelTaggingMutation) ClearDeletedAt() {
  19987. m.deleted_at = nil
  19988. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  19989. }
  19990. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19991. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  19992. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  19993. return ok
  19994. }
  19995. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19996. func (m *LabelTaggingMutation) ResetDeletedAt() {
  19997. m.deleted_at = nil
  19998. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  19999. }
  20000. // SetOrganizationID sets the "organization_id" field.
  20001. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  20002. m.organization_id = &u
  20003. m.addorganization_id = nil
  20004. }
  20005. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20006. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  20007. v := m.organization_id
  20008. if v == nil {
  20009. return
  20010. }
  20011. return *v, true
  20012. }
  20013. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  20014. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20016. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20017. if !m.op.Is(OpUpdateOne) {
  20018. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20019. }
  20020. if m.id == nil || m.oldValue == nil {
  20021. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20022. }
  20023. oldValue, err := m.oldValue(ctx)
  20024. if err != nil {
  20025. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20026. }
  20027. return oldValue.OrganizationID, nil
  20028. }
  20029. // AddOrganizationID adds u to the "organization_id" field.
  20030. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  20031. if m.addorganization_id != nil {
  20032. *m.addorganization_id += u
  20033. } else {
  20034. m.addorganization_id = &u
  20035. }
  20036. }
  20037. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20038. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  20039. v := m.addorganization_id
  20040. if v == nil {
  20041. return
  20042. }
  20043. return *v, true
  20044. }
  20045. // ResetOrganizationID resets all changes to the "organization_id" field.
  20046. func (m *LabelTaggingMutation) ResetOrganizationID() {
  20047. m.organization_id = nil
  20048. m.addorganization_id = nil
  20049. }
  20050. // SetType sets the "type" field.
  20051. func (m *LabelTaggingMutation) SetType(i int) {
  20052. m._type = &i
  20053. m.add_type = nil
  20054. }
  20055. // GetType returns the value of the "type" field in the mutation.
  20056. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  20057. v := m._type
  20058. if v == nil {
  20059. return
  20060. }
  20061. return *v, true
  20062. }
  20063. // OldType returns the old "type" field's value of the LabelTagging entity.
  20064. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20066. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  20067. if !m.op.Is(OpUpdateOne) {
  20068. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20069. }
  20070. if m.id == nil || m.oldValue == nil {
  20071. return v, errors.New("OldType requires an ID field in the mutation")
  20072. }
  20073. oldValue, err := m.oldValue(ctx)
  20074. if err != nil {
  20075. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20076. }
  20077. return oldValue.Type, nil
  20078. }
  20079. // AddType adds i to the "type" field.
  20080. func (m *LabelTaggingMutation) AddType(i int) {
  20081. if m.add_type != nil {
  20082. *m.add_type += i
  20083. } else {
  20084. m.add_type = &i
  20085. }
  20086. }
  20087. // AddedType returns the value that was added to the "type" field in this mutation.
  20088. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  20089. v := m.add_type
  20090. if v == nil {
  20091. return
  20092. }
  20093. return *v, true
  20094. }
  20095. // ResetType resets all changes to the "type" field.
  20096. func (m *LabelTaggingMutation) ResetType() {
  20097. m._type = nil
  20098. m.add_type = nil
  20099. }
  20100. // SetConditions sets the "conditions" field.
  20101. func (m *LabelTaggingMutation) SetConditions(s string) {
  20102. m.conditions = &s
  20103. }
  20104. // Conditions returns the value of the "conditions" field in the mutation.
  20105. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  20106. v := m.conditions
  20107. if v == nil {
  20108. return
  20109. }
  20110. return *v, true
  20111. }
  20112. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  20113. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20115. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  20116. if !m.op.Is(OpUpdateOne) {
  20117. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20118. }
  20119. if m.id == nil || m.oldValue == nil {
  20120. return v, errors.New("OldConditions requires an ID field in the mutation")
  20121. }
  20122. oldValue, err := m.oldValue(ctx)
  20123. if err != nil {
  20124. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20125. }
  20126. return oldValue.Conditions, nil
  20127. }
  20128. // ResetConditions resets all changes to the "conditions" field.
  20129. func (m *LabelTaggingMutation) ResetConditions() {
  20130. m.conditions = nil
  20131. }
  20132. // SetActionLabelAdd sets the "action_label_add" field.
  20133. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  20134. m.action_label_add = &u
  20135. m.appendaction_label_add = nil
  20136. }
  20137. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  20138. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  20139. v := m.action_label_add
  20140. if v == nil {
  20141. return
  20142. }
  20143. return *v, true
  20144. }
  20145. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  20146. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20148. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  20149. if !m.op.Is(OpUpdateOne) {
  20150. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  20151. }
  20152. if m.id == nil || m.oldValue == nil {
  20153. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  20154. }
  20155. oldValue, err := m.oldValue(ctx)
  20156. if err != nil {
  20157. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  20158. }
  20159. return oldValue.ActionLabelAdd, nil
  20160. }
  20161. // AppendActionLabelAdd adds u to the "action_label_add" field.
  20162. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  20163. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  20164. }
  20165. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  20166. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  20167. if len(m.appendaction_label_add) == 0 {
  20168. return nil, false
  20169. }
  20170. return m.appendaction_label_add, true
  20171. }
  20172. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  20173. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  20174. m.action_label_add = nil
  20175. m.appendaction_label_add = nil
  20176. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  20177. }
  20178. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  20179. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  20180. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  20181. return ok
  20182. }
  20183. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  20184. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  20185. m.action_label_add = nil
  20186. m.appendaction_label_add = nil
  20187. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  20188. }
  20189. // SetActionLabelDel sets the "action_label_del" field.
  20190. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  20191. m.action_label_del = &u
  20192. m.appendaction_label_del = nil
  20193. }
  20194. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  20195. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  20196. v := m.action_label_del
  20197. if v == nil {
  20198. return
  20199. }
  20200. return *v, true
  20201. }
  20202. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  20203. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20205. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  20206. if !m.op.Is(OpUpdateOne) {
  20207. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  20208. }
  20209. if m.id == nil || m.oldValue == nil {
  20210. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  20211. }
  20212. oldValue, err := m.oldValue(ctx)
  20213. if err != nil {
  20214. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  20215. }
  20216. return oldValue.ActionLabelDel, nil
  20217. }
  20218. // AppendActionLabelDel adds u to the "action_label_del" field.
  20219. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  20220. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  20221. }
  20222. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  20223. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  20224. if len(m.appendaction_label_del) == 0 {
  20225. return nil, false
  20226. }
  20227. return m.appendaction_label_del, true
  20228. }
  20229. // ClearActionLabelDel clears the value of the "action_label_del" field.
  20230. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  20231. m.action_label_del = nil
  20232. m.appendaction_label_del = nil
  20233. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  20234. }
  20235. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  20236. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  20237. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  20238. return ok
  20239. }
  20240. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  20241. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  20242. m.action_label_del = nil
  20243. m.appendaction_label_del = nil
  20244. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  20245. }
  20246. // Where appends a list predicates to the LabelTaggingMutation builder.
  20247. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  20248. m.predicates = append(m.predicates, ps...)
  20249. }
  20250. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  20251. // users can use type-assertion to append predicates that do not depend on any generated package.
  20252. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  20253. p := make([]predicate.LabelTagging, len(ps))
  20254. for i := range ps {
  20255. p[i] = ps[i]
  20256. }
  20257. m.Where(p...)
  20258. }
  20259. // Op returns the operation name.
  20260. func (m *LabelTaggingMutation) Op() Op {
  20261. return m.op
  20262. }
  20263. // SetOp allows setting the mutation operation.
  20264. func (m *LabelTaggingMutation) SetOp(op Op) {
  20265. m.op = op
  20266. }
  20267. // Type returns the node type of this mutation (LabelTagging).
  20268. func (m *LabelTaggingMutation) Type() string {
  20269. return m.typ
  20270. }
  20271. // Fields returns all fields that were changed during this mutation. Note that in
  20272. // order to get all numeric fields that were incremented/decremented, call
  20273. // AddedFields().
  20274. func (m *LabelTaggingMutation) Fields() []string {
  20275. fields := make([]string, 0, 9)
  20276. if m.created_at != nil {
  20277. fields = append(fields, labeltagging.FieldCreatedAt)
  20278. }
  20279. if m.updated_at != nil {
  20280. fields = append(fields, labeltagging.FieldUpdatedAt)
  20281. }
  20282. if m.status != nil {
  20283. fields = append(fields, labeltagging.FieldStatus)
  20284. }
  20285. if m.deleted_at != nil {
  20286. fields = append(fields, labeltagging.FieldDeletedAt)
  20287. }
  20288. if m.organization_id != nil {
  20289. fields = append(fields, labeltagging.FieldOrganizationID)
  20290. }
  20291. if m._type != nil {
  20292. fields = append(fields, labeltagging.FieldType)
  20293. }
  20294. if m.conditions != nil {
  20295. fields = append(fields, labeltagging.FieldConditions)
  20296. }
  20297. if m.action_label_add != nil {
  20298. fields = append(fields, labeltagging.FieldActionLabelAdd)
  20299. }
  20300. if m.action_label_del != nil {
  20301. fields = append(fields, labeltagging.FieldActionLabelDel)
  20302. }
  20303. return fields
  20304. }
  20305. // Field returns the value of a field with the given name. The second boolean
  20306. // return value indicates that this field was not set, or was not defined in the
  20307. // schema.
  20308. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  20309. switch name {
  20310. case labeltagging.FieldCreatedAt:
  20311. return m.CreatedAt()
  20312. case labeltagging.FieldUpdatedAt:
  20313. return m.UpdatedAt()
  20314. case labeltagging.FieldStatus:
  20315. return m.Status()
  20316. case labeltagging.FieldDeletedAt:
  20317. return m.DeletedAt()
  20318. case labeltagging.FieldOrganizationID:
  20319. return m.OrganizationID()
  20320. case labeltagging.FieldType:
  20321. return m.GetType()
  20322. case labeltagging.FieldConditions:
  20323. return m.Conditions()
  20324. case labeltagging.FieldActionLabelAdd:
  20325. return m.ActionLabelAdd()
  20326. case labeltagging.FieldActionLabelDel:
  20327. return m.ActionLabelDel()
  20328. }
  20329. return nil, false
  20330. }
  20331. // OldField returns the old value of the field from the database. An error is
  20332. // returned if the mutation operation is not UpdateOne, or the query to the
  20333. // database failed.
  20334. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20335. switch name {
  20336. case labeltagging.FieldCreatedAt:
  20337. return m.OldCreatedAt(ctx)
  20338. case labeltagging.FieldUpdatedAt:
  20339. return m.OldUpdatedAt(ctx)
  20340. case labeltagging.FieldStatus:
  20341. return m.OldStatus(ctx)
  20342. case labeltagging.FieldDeletedAt:
  20343. return m.OldDeletedAt(ctx)
  20344. case labeltagging.FieldOrganizationID:
  20345. return m.OldOrganizationID(ctx)
  20346. case labeltagging.FieldType:
  20347. return m.OldType(ctx)
  20348. case labeltagging.FieldConditions:
  20349. return m.OldConditions(ctx)
  20350. case labeltagging.FieldActionLabelAdd:
  20351. return m.OldActionLabelAdd(ctx)
  20352. case labeltagging.FieldActionLabelDel:
  20353. return m.OldActionLabelDel(ctx)
  20354. }
  20355. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  20356. }
  20357. // SetField sets the value of a field with the given name. It returns an error if
  20358. // the field is not defined in the schema, or if the type mismatched the field
  20359. // type.
  20360. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  20361. switch name {
  20362. case labeltagging.FieldCreatedAt:
  20363. v, ok := value.(time.Time)
  20364. if !ok {
  20365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20366. }
  20367. m.SetCreatedAt(v)
  20368. return nil
  20369. case labeltagging.FieldUpdatedAt:
  20370. v, ok := value.(time.Time)
  20371. if !ok {
  20372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20373. }
  20374. m.SetUpdatedAt(v)
  20375. return nil
  20376. case labeltagging.FieldStatus:
  20377. v, ok := value.(uint8)
  20378. if !ok {
  20379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20380. }
  20381. m.SetStatus(v)
  20382. return nil
  20383. case labeltagging.FieldDeletedAt:
  20384. v, ok := value.(time.Time)
  20385. if !ok {
  20386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20387. }
  20388. m.SetDeletedAt(v)
  20389. return nil
  20390. case labeltagging.FieldOrganizationID:
  20391. v, ok := value.(uint64)
  20392. if !ok {
  20393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20394. }
  20395. m.SetOrganizationID(v)
  20396. return nil
  20397. case labeltagging.FieldType:
  20398. v, ok := value.(int)
  20399. if !ok {
  20400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20401. }
  20402. m.SetType(v)
  20403. return nil
  20404. case labeltagging.FieldConditions:
  20405. v, ok := value.(string)
  20406. if !ok {
  20407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20408. }
  20409. m.SetConditions(v)
  20410. return nil
  20411. case labeltagging.FieldActionLabelAdd:
  20412. v, ok := value.([]uint64)
  20413. if !ok {
  20414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20415. }
  20416. m.SetActionLabelAdd(v)
  20417. return nil
  20418. case labeltagging.FieldActionLabelDel:
  20419. v, ok := value.([]uint64)
  20420. if !ok {
  20421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20422. }
  20423. m.SetActionLabelDel(v)
  20424. return nil
  20425. }
  20426. return fmt.Errorf("unknown LabelTagging field %s", name)
  20427. }
  20428. // AddedFields returns all numeric fields that were incremented/decremented during
  20429. // this mutation.
  20430. func (m *LabelTaggingMutation) AddedFields() []string {
  20431. var fields []string
  20432. if m.addstatus != nil {
  20433. fields = append(fields, labeltagging.FieldStatus)
  20434. }
  20435. if m.addorganization_id != nil {
  20436. fields = append(fields, labeltagging.FieldOrganizationID)
  20437. }
  20438. if m.add_type != nil {
  20439. fields = append(fields, labeltagging.FieldType)
  20440. }
  20441. return fields
  20442. }
  20443. // AddedField returns the numeric value that was incremented/decremented on a field
  20444. // with the given name. The second boolean return value indicates that this field
  20445. // was not set, or was not defined in the schema.
  20446. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  20447. switch name {
  20448. case labeltagging.FieldStatus:
  20449. return m.AddedStatus()
  20450. case labeltagging.FieldOrganizationID:
  20451. return m.AddedOrganizationID()
  20452. case labeltagging.FieldType:
  20453. return m.AddedType()
  20454. }
  20455. return nil, false
  20456. }
  20457. // AddField adds the value to the field with the given name. It returns an error if
  20458. // the field is not defined in the schema, or if the type mismatched the field
  20459. // type.
  20460. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  20461. switch name {
  20462. case labeltagging.FieldStatus:
  20463. v, ok := value.(int8)
  20464. if !ok {
  20465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20466. }
  20467. m.AddStatus(v)
  20468. return nil
  20469. case labeltagging.FieldOrganizationID:
  20470. v, ok := value.(int64)
  20471. if !ok {
  20472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20473. }
  20474. m.AddOrganizationID(v)
  20475. return nil
  20476. case labeltagging.FieldType:
  20477. v, ok := value.(int)
  20478. if !ok {
  20479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20480. }
  20481. m.AddType(v)
  20482. return nil
  20483. }
  20484. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  20485. }
  20486. // ClearedFields returns all nullable fields that were cleared during this
  20487. // mutation.
  20488. func (m *LabelTaggingMutation) ClearedFields() []string {
  20489. var fields []string
  20490. if m.FieldCleared(labeltagging.FieldStatus) {
  20491. fields = append(fields, labeltagging.FieldStatus)
  20492. }
  20493. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  20494. fields = append(fields, labeltagging.FieldDeletedAt)
  20495. }
  20496. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  20497. fields = append(fields, labeltagging.FieldActionLabelAdd)
  20498. }
  20499. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  20500. fields = append(fields, labeltagging.FieldActionLabelDel)
  20501. }
  20502. return fields
  20503. }
  20504. // FieldCleared returns a boolean indicating if a field with the given name was
  20505. // cleared in this mutation.
  20506. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  20507. _, ok := m.clearedFields[name]
  20508. return ok
  20509. }
  20510. // ClearField clears the value of the field with the given name. It returns an
  20511. // error if the field is not defined in the schema.
  20512. func (m *LabelTaggingMutation) ClearField(name string) error {
  20513. switch name {
  20514. case labeltagging.FieldStatus:
  20515. m.ClearStatus()
  20516. return nil
  20517. case labeltagging.FieldDeletedAt:
  20518. m.ClearDeletedAt()
  20519. return nil
  20520. case labeltagging.FieldActionLabelAdd:
  20521. m.ClearActionLabelAdd()
  20522. return nil
  20523. case labeltagging.FieldActionLabelDel:
  20524. m.ClearActionLabelDel()
  20525. return nil
  20526. }
  20527. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  20528. }
  20529. // ResetField resets all changes in the mutation for the field with the given name.
  20530. // It returns an error if the field is not defined in the schema.
  20531. func (m *LabelTaggingMutation) ResetField(name string) error {
  20532. switch name {
  20533. case labeltagging.FieldCreatedAt:
  20534. m.ResetCreatedAt()
  20535. return nil
  20536. case labeltagging.FieldUpdatedAt:
  20537. m.ResetUpdatedAt()
  20538. return nil
  20539. case labeltagging.FieldStatus:
  20540. m.ResetStatus()
  20541. return nil
  20542. case labeltagging.FieldDeletedAt:
  20543. m.ResetDeletedAt()
  20544. return nil
  20545. case labeltagging.FieldOrganizationID:
  20546. m.ResetOrganizationID()
  20547. return nil
  20548. case labeltagging.FieldType:
  20549. m.ResetType()
  20550. return nil
  20551. case labeltagging.FieldConditions:
  20552. m.ResetConditions()
  20553. return nil
  20554. case labeltagging.FieldActionLabelAdd:
  20555. m.ResetActionLabelAdd()
  20556. return nil
  20557. case labeltagging.FieldActionLabelDel:
  20558. m.ResetActionLabelDel()
  20559. return nil
  20560. }
  20561. return fmt.Errorf("unknown LabelTagging field %s", name)
  20562. }
  20563. // AddedEdges returns all edge names that were set/added in this mutation.
  20564. func (m *LabelTaggingMutation) AddedEdges() []string {
  20565. edges := make([]string, 0, 0)
  20566. return edges
  20567. }
  20568. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20569. // name in this mutation.
  20570. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  20571. return nil
  20572. }
  20573. // RemovedEdges returns all edge names that were removed in this mutation.
  20574. func (m *LabelTaggingMutation) RemovedEdges() []string {
  20575. edges := make([]string, 0, 0)
  20576. return edges
  20577. }
  20578. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20579. // the given name in this mutation.
  20580. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  20581. return nil
  20582. }
  20583. // ClearedEdges returns all edge names that were cleared in this mutation.
  20584. func (m *LabelTaggingMutation) ClearedEdges() []string {
  20585. edges := make([]string, 0, 0)
  20586. return edges
  20587. }
  20588. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20589. // was cleared in this mutation.
  20590. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  20591. return false
  20592. }
  20593. // ClearEdge clears the value of the edge with the given name. It returns an error
  20594. // if that edge is not defined in the schema.
  20595. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  20596. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  20597. }
  20598. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20599. // It returns an error if the edge is not defined in the schema.
  20600. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  20601. return fmt.Errorf("unknown LabelTagging edge %s", name)
  20602. }
  20603. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  20604. type MessageMutation struct {
  20605. config
  20606. op Op
  20607. typ string
  20608. id *int
  20609. wx_wxid *string
  20610. wxid *string
  20611. content *string
  20612. clearedFields map[string]struct{}
  20613. done bool
  20614. oldValue func(context.Context) (*Message, error)
  20615. predicates []predicate.Message
  20616. }
  20617. var _ ent.Mutation = (*MessageMutation)(nil)
  20618. // messageOption allows management of the mutation configuration using functional options.
  20619. type messageOption func(*MessageMutation)
  20620. // newMessageMutation creates new mutation for the Message entity.
  20621. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  20622. m := &MessageMutation{
  20623. config: c,
  20624. op: op,
  20625. typ: TypeMessage,
  20626. clearedFields: make(map[string]struct{}),
  20627. }
  20628. for _, opt := range opts {
  20629. opt(m)
  20630. }
  20631. return m
  20632. }
  20633. // withMessageID sets the ID field of the mutation.
  20634. func withMessageID(id int) messageOption {
  20635. return func(m *MessageMutation) {
  20636. var (
  20637. err error
  20638. once sync.Once
  20639. value *Message
  20640. )
  20641. m.oldValue = func(ctx context.Context) (*Message, error) {
  20642. once.Do(func() {
  20643. if m.done {
  20644. err = errors.New("querying old values post mutation is not allowed")
  20645. } else {
  20646. value, err = m.Client().Message.Get(ctx, id)
  20647. }
  20648. })
  20649. return value, err
  20650. }
  20651. m.id = &id
  20652. }
  20653. }
  20654. // withMessage sets the old Message of the mutation.
  20655. func withMessage(node *Message) messageOption {
  20656. return func(m *MessageMutation) {
  20657. m.oldValue = func(context.Context) (*Message, error) {
  20658. return node, nil
  20659. }
  20660. m.id = &node.ID
  20661. }
  20662. }
  20663. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20664. // executed in a transaction (ent.Tx), a transactional client is returned.
  20665. func (m MessageMutation) Client() *Client {
  20666. client := &Client{config: m.config}
  20667. client.init()
  20668. return client
  20669. }
  20670. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20671. // it returns an error otherwise.
  20672. func (m MessageMutation) Tx() (*Tx, error) {
  20673. if _, ok := m.driver.(*txDriver); !ok {
  20674. return nil, errors.New("ent: mutation is not running in a transaction")
  20675. }
  20676. tx := &Tx{config: m.config}
  20677. tx.init()
  20678. return tx, nil
  20679. }
  20680. // ID returns the ID value in the mutation. Note that the ID is only available
  20681. // if it was provided to the builder or after it was returned from the database.
  20682. func (m *MessageMutation) ID() (id int, exists bool) {
  20683. if m.id == nil {
  20684. return
  20685. }
  20686. return *m.id, true
  20687. }
  20688. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20689. // That means, if the mutation is applied within a transaction with an isolation level such
  20690. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20691. // or updated by the mutation.
  20692. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  20693. switch {
  20694. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20695. id, exists := m.ID()
  20696. if exists {
  20697. return []int{id}, nil
  20698. }
  20699. fallthrough
  20700. case m.op.Is(OpUpdate | OpDelete):
  20701. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  20702. default:
  20703. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20704. }
  20705. }
  20706. // SetWxWxid sets the "wx_wxid" field.
  20707. func (m *MessageMutation) SetWxWxid(s string) {
  20708. m.wx_wxid = &s
  20709. }
  20710. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  20711. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  20712. v := m.wx_wxid
  20713. if v == nil {
  20714. return
  20715. }
  20716. return *v, true
  20717. }
  20718. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  20719. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20721. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  20722. if !m.op.Is(OpUpdateOne) {
  20723. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  20724. }
  20725. if m.id == nil || m.oldValue == nil {
  20726. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  20727. }
  20728. oldValue, err := m.oldValue(ctx)
  20729. if err != nil {
  20730. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  20731. }
  20732. return oldValue.WxWxid, nil
  20733. }
  20734. // ClearWxWxid clears the value of the "wx_wxid" field.
  20735. func (m *MessageMutation) ClearWxWxid() {
  20736. m.wx_wxid = nil
  20737. m.clearedFields[message.FieldWxWxid] = struct{}{}
  20738. }
  20739. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  20740. func (m *MessageMutation) WxWxidCleared() bool {
  20741. _, ok := m.clearedFields[message.FieldWxWxid]
  20742. return ok
  20743. }
  20744. // ResetWxWxid resets all changes to the "wx_wxid" field.
  20745. func (m *MessageMutation) ResetWxWxid() {
  20746. m.wx_wxid = nil
  20747. delete(m.clearedFields, message.FieldWxWxid)
  20748. }
  20749. // SetWxid sets the "wxid" field.
  20750. func (m *MessageMutation) SetWxid(s string) {
  20751. m.wxid = &s
  20752. }
  20753. // Wxid returns the value of the "wxid" field in the mutation.
  20754. func (m *MessageMutation) Wxid() (r string, exists bool) {
  20755. v := m.wxid
  20756. if v == nil {
  20757. return
  20758. }
  20759. return *v, true
  20760. }
  20761. // OldWxid returns the old "wxid" field's value of the Message entity.
  20762. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20764. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  20765. if !m.op.Is(OpUpdateOne) {
  20766. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  20767. }
  20768. if m.id == nil || m.oldValue == nil {
  20769. return v, errors.New("OldWxid requires an ID field in the mutation")
  20770. }
  20771. oldValue, err := m.oldValue(ctx)
  20772. if err != nil {
  20773. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  20774. }
  20775. return oldValue.Wxid, nil
  20776. }
  20777. // ResetWxid resets all changes to the "wxid" field.
  20778. func (m *MessageMutation) ResetWxid() {
  20779. m.wxid = nil
  20780. }
  20781. // SetContent sets the "content" field.
  20782. func (m *MessageMutation) SetContent(s string) {
  20783. m.content = &s
  20784. }
  20785. // Content returns the value of the "content" field in the mutation.
  20786. func (m *MessageMutation) Content() (r string, exists bool) {
  20787. v := m.content
  20788. if v == nil {
  20789. return
  20790. }
  20791. return *v, true
  20792. }
  20793. // OldContent returns the old "content" field's value of the Message entity.
  20794. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20796. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  20797. if !m.op.Is(OpUpdateOne) {
  20798. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20799. }
  20800. if m.id == nil || m.oldValue == nil {
  20801. return v, errors.New("OldContent requires an ID field in the mutation")
  20802. }
  20803. oldValue, err := m.oldValue(ctx)
  20804. if err != nil {
  20805. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20806. }
  20807. return oldValue.Content, nil
  20808. }
  20809. // ResetContent resets all changes to the "content" field.
  20810. func (m *MessageMutation) ResetContent() {
  20811. m.content = nil
  20812. }
  20813. // Where appends a list predicates to the MessageMutation builder.
  20814. func (m *MessageMutation) Where(ps ...predicate.Message) {
  20815. m.predicates = append(m.predicates, ps...)
  20816. }
  20817. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  20818. // users can use type-assertion to append predicates that do not depend on any generated package.
  20819. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  20820. p := make([]predicate.Message, len(ps))
  20821. for i := range ps {
  20822. p[i] = ps[i]
  20823. }
  20824. m.Where(p...)
  20825. }
  20826. // Op returns the operation name.
  20827. func (m *MessageMutation) Op() Op {
  20828. return m.op
  20829. }
  20830. // SetOp allows setting the mutation operation.
  20831. func (m *MessageMutation) SetOp(op Op) {
  20832. m.op = op
  20833. }
  20834. // Type returns the node type of this mutation (Message).
  20835. func (m *MessageMutation) Type() string {
  20836. return m.typ
  20837. }
  20838. // Fields returns all fields that were changed during this mutation. Note that in
  20839. // order to get all numeric fields that were incremented/decremented, call
  20840. // AddedFields().
  20841. func (m *MessageMutation) Fields() []string {
  20842. fields := make([]string, 0, 3)
  20843. if m.wx_wxid != nil {
  20844. fields = append(fields, message.FieldWxWxid)
  20845. }
  20846. if m.wxid != nil {
  20847. fields = append(fields, message.FieldWxid)
  20848. }
  20849. if m.content != nil {
  20850. fields = append(fields, message.FieldContent)
  20851. }
  20852. return fields
  20853. }
  20854. // Field returns the value of a field with the given name. The second boolean
  20855. // return value indicates that this field was not set, or was not defined in the
  20856. // schema.
  20857. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  20858. switch name {
  20859. case message.FieldWxWxid:
  20860. return m.WxWxid()
  20861. case message.FieldWxid:
  20862. return m.Wxid()
  20863. case message.FieldContent:
  20864. return m.Content()
  20865. }
  20866. return nil, false
  20867. }
  20868. // OldField returns the old value of the field from the database. An error is
  20869. // returned if the mutation operation is not UpdateOne, or the query to the
  20870. // database failed.
  20871. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20872. switch name {
  20873. case message.FieldWxWxid:
  20874. return m.OldWxWxid(ctx)
  20875. case message.FieldWxid:
  20876. return m.OldWxid(ctx)
  20877. case message.FieldContent:
  20878. return m.OldContent(ctx)
  20879. }
  20880. return nil, fmt.Errorf("unknown Message field %s", name)
  20881. }
  20882. // SetField sets the value of a field with the given name. It returns an error if
  20883. // the field is not defined in the schema, or if the type mismatched the field
  20884. // type.
  20885. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  20886. switch name {
  20887. case message.FieldWxWxid:
  20888. v, ok := value.(string)
  20889. if !ok {
  20890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20891. }
  20892. m.SetWxWxid(v)
  20893. return nil
  20894. case message.FieldWxid:
  20895. v, ok := value.(string)
  20896. if !ok {
  20897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20898. }
  20899. m.SetWxid(v)
  20900. return nil
  20901. case message.FieldContent:
  20902. v, ok := value.(string)
  20903. if !ok {
  20904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20905. }
  20906. m.SetContent(v)
  20907. return nil
  20908. }
  20909. return fmt.Errorf("unknown Message field %s", name)
  20910. }
  20911. // AddedFields returns all numeric fields that were incremented/decremented during
  20912. // this mutation.
  20913. func (m *MessageMutation) AddedFields() []string {
  20914. return nil
  20915. }
  20916. // AddedField returns the numeric value that was incremented/decremented on a field
  20917. // with the given name. The second boolean return value indicates that this field
  20918. // was not set, or was not defined in the schema.
  20919. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  20920. return nil, false
  20921. }
  20922. // AddField adds the value to the field with the given name. It returns an error if
  20923. // the field is not defined in the schema, or if the type mismatched the field
  20924. // type.
  20925. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  20926. switch name {
  20927. }
  20928. return fmt.Errorf("unknown Message numeric field %s", name)
  20929. }
  20930. // ClearedFields returns all nullable fields that were cleared during this
  20931. // mutation.
  20932. func (m *MessageMutation) ClearedFields() []string {
  20933. var fields []string
  20934. if m.FieldCleared(message.FieldWxWxid) {
  20935. fields = append(fields, message.FieldWxWxid)
  20936. }
  20937. return fields
  20938. }
  20939. // FieldCleared returns a boolean indicating if a field with the given name was
  20940. // cleared in this mutation.
  20941. func (m *MessageMutation) FieldCleared(name string) bool {
  20942. _, ok := m.clearedFields[name]
  20943. return ok
  20944. }
  20945. // ClearField clears the value of the field with the given name. It returns an
  20946. // error if the field is not defined in the schema.
  20947. func (m *MessageMutation) ClearField(name string) error {
  20948. switch name {
  20949. case message.FieldWxWxid:
  20950. m.ClearWxWxid()
  20951. return nil
  20952. }
  20953. return fmt.Errorf("unknown Message nullable field %s", name)
  20954. }
  20955. // ResetField resets all changes in the mutation for the field with the given name.
  20956. // It returns an error if the field is not defined in the schema.
  20957. func (m *MessageMutation) ResetField(name string) error {
  20958. switch name {
  20959. case message.FieldWxWxid:
  20960. m.ResetWxWxid()
  20961. return nil
  20962. case message.FieldWxid:
  20963. m.ResetWxid()
  20964. return nil
  20965. case message.FieldContent:
  20966. m.ResetContent()
  20967. return nil
  20968. }
  20969. return fmt.Errorf("unknown Message field %s", name)
  20970. }
  20971. // AddedEdges returns all edge names that were set/added in this mutation.
  20972. func (m *MessageMutation) AddedEdges() []string {
  20973. edges := make([]string, 0, 0)
  20974. return edges
  20975. }
  20976. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20977. // name in this mutation.
  20978. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  20979. return nil
  20980. }
  20981. // RemovedEdges returns all edge names that were removed in this mutation.
  20982. func (m *MessageMutation) RemovedEdges() []string {
  20983. edges := make([]string, 0, 0)
  20984. return edges
  20985. }
  20986. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20987. // the given name in this mutation.
  20988. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  20989. return nil
  20990. }
  20991. // ClearedEdges returns all edge names that were cleared in this mutation.
  20992. func (m *MessageMutation) ClearedEdges() []string {
  20993. edges := make([]string, 0, 0)
  20994. return edges
  20995. }
  20996. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20997. // was cleared in this mutation.
  20998. func (m *MessageMutation) EdgeCleared(name string) bool {
  20999. return false
  21000. }
  21001. // ClearEdge clears the value of the edge with the given name. It returns an error
  21002. // if that edge is not defined in the schema.
  21003. func (m *MessageMutation) ClearEdge(name string) error {
  21004. return fmt.Errorf("unknown Message unique edge %s", name)
  21005. }
  21006. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21007. // It returns an error if the edge is not defined in the schema.
  21008. func (m *MessageMutation) ResetEdge(name string) error {
  21009. return fmt.Errorf("unknown Message edge %s", name)
  21010. }
  21011. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  21012. type MessageRecordsMutation struct {
  21013. config
  21014. op Op
  21015. typ string
  21016. id *uint64
  21017. created_at *time.Time
  21018. updated_at *time.Time
  21019. status *uint8
  21020. addstatus *int8
  21021. bot_wxid *string
  21022. contact_type *int
  21023. addcontact_type *int
  21024. contact_wxid *string
  21025. content_type *int
  21026. addcontent_type *int
  21027. content *string
  21028. meta *custom_types.Meta
  21029. error_detail *string
  21030. send_time *time.Time
  21031. source_type *int
  21032. addsource_type *int
  21033. organization_id *uint64
  21034. addorganization_id *int64
  21035. clearedFields map[string]struct{}
  21036. sop_stage *uint64
  21037. clearedsop_stage bool
  21038. sop_node *uint64
  21039. clearedsop_node bool
  21040. message_contact *uint64
  21041. clearedmessage_contact bool
  21042. done bool
  21043. oldValue func(context.Context) (*MessageRecords, error)
  21044. predicates []predicate.MessageRecords
  21045. }
  21046. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  21047. // messagerecordsOption allows management of the mutation configuration using functional options.
  21048. type messagerecordsOption func(*MessageRecordsMutation)
  21049. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  21050. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  21051. m := &MessageRecordsMutation{
  21052. config: c,
  21053. op: op,
  21054. typ: TypeMessageRecords,
  21055. clearedFields: make(map[string]struct{}),
  21056. }
  21057. for _, opt := range opts {
  21058. opt(m)
  21059. }
  21060. return m
  21061. }
  21062. // withMessageRecordsID sets the ID field of the mutation.
  21063. func withMessageRecordsID(id uint64) messagerecordsOption {
  21064. return func(m *MessageRecordsMutation) {
  21065. var (
  21066. err error
  21067. once sync.Once
  21068. value *MessageRecords
  21069. )
  21070. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  21071. once.Do(func() {
  21072. if m.done {
  21073. err = errors.New("querying old values post mutation is not allowed")
  21074. } else {
  21075. value, err = m.Client().MessageRecords.Get(ctx, id)
  21076. }
  21077. })
  21078. return value, err
  21079. }
  21080. m.id = &id
  21081. }
  21082. }
  21083. // withMessageRecords sets the old MessageRecords of the mutation.
  21084. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  21085. return func(m *MessageRecordsMutation) {
  21086. m.oldValue = func(context.Context) (*MessageRecords, error) {
  21087. return node, nil
  21088. }
  21089. m.id = &node.ID
  21090. }
  21091. }
  21092. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21093. // executed in a transaction (ent.Tx), a transactional client is returned.
  21094. func (m MessageRecordsMutation) Client() *Client {
  21095. client := &Client{config: m.config}
  21096. client.init()
  21097. return client
  21098. }
  21099. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21100. // it returns an error otherwise.
  21101. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  21102. if _, ok := m.driver.(*txDriver); !ok {
  21103. return nil, errors.New("ent: mutation is not running in a transaction")
  21104. }
  21105. tx := &Tx{config: m.config}
  21106. tx.init()
  21107. return tx, nil
  21108. }
  21109. // SetID sets the value of the id field. Note that this
  21110. // operation is only accepted on creation of MessageRecords entities.
  21111. func (m *MessageRecordsMutation) SetID(id uint64) {
  21112. m.id = &id
  21113. }
  21114. // ID returns the ID value in the mutation. Note that the ID is only available
  21115. // if it was provided to the builder or after it was returned from the database.
  21116. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  21117. if m.id == nil {
  21118. return
  21119. }
  21120. return *m.id, true
  21121. }
  21122. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21123. // That means, if the mutation is applied within a transaction with an isolation level such
  21124. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21125. // or updated by the mutation.
  21126. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  21127. switch {
  21128. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21129. id, exists := m.ID()
  21130. if exists {
  21131. return []uint64{id}, nil
  21132. }
  21133. fallthrough
  21134. case m.op.Is(OpUpdate | OpDelete):
  21135. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  21136. default:
  21137. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21138. }
  21139. }
  21140. // SetCreatedAt sets the "created_at" field.
  21141. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  21142. m.created_at = &t
  21143. }
  21144. // CreatedAt returns the value of the "created_at" field in the mutation.
  21145. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  21146. v := m.created_at
  21147. if v == nil {
  21148. return
  21149. }
  21150. return *v, true
  21151. }
  21152. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  21153. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21155. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21156. if !m.op.Is(OpUpdateOne) {
  21157. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21158. }
  21159. if m.id == nil || m.oldValue == nil {
  21160. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21161. }
  21162. oldValue, err := m.oldValue(ctx)
  21163. if err != nil {
  21164. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21165. }
  21166. return oldValue.CreatedAt, nil
  21167. }
  21168. // ResetCreatedAt resets all changes to the "created_at" field.
  21169. func (m *MessageRecordsMutation) ResetCreatedAt() {
  21170. m.created_at = nil
  21171. }
  21172. // SetUpdatedAt sets the "updated_at" field.
  21173. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  21174. m.updated_at = &t
  21175. }
  21176. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21177. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  21178. v := m.updated_at
  21179. if v == nil {
  21180. return
  21181. }
  21182. return *v, true
  21183. }
  21184. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  21185. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21187. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21188. if !m.op.Is(OpUpdateOne) {
  21189. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21190. }
  21191. if m.id == nil || m.oldValue == nil {
  21192. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21193. }
  21194. oldValue, err := m.oldValue(ctx)
  21195. if err != nil {
  21196. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21197. }
  21198. return oldValue.UpdatedAt, nil
  21199. }
  21200. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21201. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  21202. m.updated_at = nil
  21203. }
  21204. // SetStatus sets the "status" field.
  21205. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  21206. m.status = &u
  21207. m.addstatus = nil
  21208. }
  21209. // Status returns the value of the "status" field in the mutation.
  21210. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  21211. v := m.status
  21212. if v == nil {
  21213. return
  21214. }
  21215. return *v, true
  21216. }
  21217. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  21218. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21220. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21221. if !m.op.Is(OpUpdateOne) {
  21222. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21223. }
  21224. if m.id == nil || m.oldValue == nil {
  21225. return v, errors.New("OldStatus requires an ID field in the mutation")
  21226. }
  21227. oldValue, err := m.oldValue(ctx)
  21228. if err != nil {
  21229. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21230. }
  21231. return oldValue.Status, nil
  21232. }
  21233. // AddStatus adds u to the "status" field.
  21234. func (m *MessageRecordsMutation) AddStatus(u int8) {
  21235. if m.addstatus != nil {
  21236. *m.addstatus += u
  21237. } else {
  21238. m.addstatus = &u
  21239. }
  21240. }
  21241. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21242. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  21243. v := m.addstatus
  21244. if v == nil {
  21245. return
  21246. }
  21247. return *v, true
  21248. }
  21249. // ClearStatus clears the value of the "status" field.
  21250. func (m *MessageRecordsMutation) ClearStatus() {
  21251. m.status = nil
  21252. m.addstatus = nil
  21253. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  21254. }
  21255. // StatusCleared returns if the "status" field was cleared in this mutation.
  21256. func (m *MessageRecordsMutation) StatusCleared() bool {
  21257. _, ok := m.clearedFields[messagerecords.FieldStatus]
  21258. return ok
  21259. }
  21260. // ResetStatus resets all changes to the "status" field.
  21261. func (m *MessageRecordsMutation) ResetStatus() {
  21262. m.status = nil
  21263. m.addstatus = nil
  21264. delete(m.clearedFields, messagerecords.FieldStatus)
  21265. }
  21266. // SetBotWxid sets the "bot_wxid" field.
  21267. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  21268. m.bot_wxid = &s
  21269. }
  21270. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  21271. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  21272. v := m.bot_wxid
  21273. if v == nil {
  21274. return
  21275. }
  21276. return *v, true
  21277. }
  21278. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  21279. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21281. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  21282. if !m.op.Is(OpUpdateOne) {
  21283. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  21284. }
  21285. if m.id == nil || m.oldValue == nil {
  21286. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  21287. }
  21288. oldValue, err := m.oldValue(ctx)
  21289. if err != nil {
  21290. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  21291. }
  21292. return oldValue.BotWxid, nil
  21293. }
  21294. // ResetBotWxid resets all changes to the "bot_wxid" field.
  21295. func (m *MessageRecordsMutation) ResetBotWxid() {
  21296. m.bot_wxid = nil
  21297. }
  21298. // SetContactID sets the "contact_id" field.
  21299. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  21300. m.message_contact = &u
  21301. }
  21302. // ContactID returns the value of the "contact_id" field in the mutation.
  21303. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  21304. v := m.message_contact
  21305. if v == nil {
  21306. return
  21307. }
  21308. return *v, true
  21309. }
  21310. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  21311. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21313. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  21314. if !m.op.Is(OpUpdateOne) {
  21315. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  21316. }
  21317. if m.id == nil || m.oldValue == nil {
  21318. return v, errors.New("OldContactID requires an ID field in the mutation")
  21319. }
  21320. oldValue, err := m.oldValue(ctx)
  21321. if err != nil {
  21322. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  21323. }
  21324. return oldValue.ContactID, nil
  21325. }
  21326. // ClearContactID clears the value of the "contact_id" field.
  21327. func (m *MessageRecordsMutation) ClearContactID() {
  21328. m.message_contact = nil
  21329. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21330. }
  21331. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  21332. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  21333. _, ok := m.clearedFields[messagerecords.FieldContactID]
  21334. return ok
  21335. }
  21336. // ResetContactID resets all changes to the "contact_id" field.
  21337. func (m *MessageRecordsMutation) ResetContactID() {
  21338. m.message_contact = nil
  21339. delete(m.clearedFields, messagerecords.FieldContactID)
  21340. }
  21341. // SetContactType sets the "contact_type" field.
  21342. func (m *MessageRecordsMutation) SetContactType(i int) {
  21343. m.contact_type = &i
  21344. m.addcontact_type = nil
  21345. }
  21346. // ContactType returns the value of the "contact_type" field in the mutation.
  21347. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  21348. v := m.contact_type
  21349. if v == nil {
  21350. return
  21351. }
  21352. return *v, true
  21353. }
  21354. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  21355. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21357. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  21358. if !m.op.Is(OpUpdateOne) {
  21359. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  21360. }
  21361. if m.id == nil || m.oldValue == nil {
  21362. return v, errors.New("OldContactType requires an ID field in the mutation")
  21363. }
  21364. oldValue, err := m.oldValue(ctx)
  21365. if err != nil {
  21366. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  21367. }
  21368. return oldValue.ContactType, nil
  21369. }
  21370. // AddContactType adds i to the "contact_type" field.
  21371. func (m *MessageRecordsMutation) AddContactType(i int) {
  21372. if m.addcontact_type != nil {
  21373. *m.addcontact_type += i
  21374. } else {
  21375. m.addcontact_type = &i
  21376. }
  21377. }
  21378. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  21379. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  21380. v := m.addcontact_type
  21381. if v == nil {
  21382. return
  21383. }
  21384. return *v, true
  21385. }
  21386. // ResetContactType resets all changes to the "contact_type" field.
  21387. func (m *MessageRecordsMutation) ResetContactType() {
  21388. m.contact_type = nil
  21389. m.addcontact_type = nil
  21390. }
  21391. // SetContactWxid sets the "contact_wxid" field.
  21392. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  21393. m.contact_wxid = &s
  21394. }
  21395. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  21396. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  21397. v := m.contact_wxid
  21398. if v == nil {
  21399. return
  21400. }
  21401. return *v, true
  21402. }
  21403. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  21404. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21406. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  21407. if !m.op.Is(OpUpdateOne) {
  21408. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  21409. }
  21410. if m.id == nil || m.oldValue == nil {
  21411. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  21412. }
  21413. oldValue, err := m.oldValue(ctx)
  21414. if err != nil {
  21415. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  21416. }
  21417. return oldValue.ContactWxid, nil
  21418. }
  21419. // ResetContactWxid resets all changes to the "contact_wxid" field.
  21420. func (m *MessageRecordsMutation) ResetContactWxid() {
  21421. m.contact_wxid = nil
  21422. }
  21423. // SetContentType sets the "content_type" field.
  21424. func (m *MessageRecordsMutation) SetContentType(i int) {
  21425. m.content_type = &i
  21426. m.addcontent_type = nil
  21427. }
  21428. // ContentType returns the value of the "content_type" field in the mutation.
  21429. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  21430. v := m.content_type
  21431. if v == nil {
  21432. return
  21433. }
  21434. return *v, true
  21435. }
  21436. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  21437. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21439. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  21440. if !m.op.Is(OpUpdateOne) {
  21441. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  21442. }
  21443. if m.id == nil || m.oldValue == nil {
  21444. return v, errors.New("OldContentType requires an ID field in the mutation")
  21445. }
  21446. oldValue, err := m.oldValue(ctx)
  21447. if err != nil {
  21448. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  21449. }
  21450. return oldValue.ContentType, nil
  21451. }
  21452. // AddContentType adds i to the "content_type" field.
  21453. func (m *MessageRecordsMutation) AddContentType(i int) {
  21454. if m.addcontent_type != nil {
  21455. *m.addcontent_type += i
  21456. } else {
  21457. m.addcontent_type = &i
  21458. }
  21459. }
  21460. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  21461. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  21462. v := m.addcontent_type
  21463. if v == nil {
  21464. return
  21465. }
  21466. return *v, true
  21467. }
  21468. // ResetContentType resets all changes to the "content_type" field.
  21469. func (m *MessageRecordsMutation) ResetContentType() {
  21470. m.content_type = nil
  21471. m.addcontent_type = nil
  21472. }
  21473. // SetContent sets the "content" field.
  21474. func (m *MessageRecordsMutation) SetContent(s string) {
  21475. m.content = &s
  21476. }
  21477. // Content returns the value of the "content" field in the mutation.
  21478. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  21479. v := m.content
  21480. if v == nil {
  21481. return
  21482. }
  21483. return *v, true
  21484. }
  21485. // OldContent returns the old "content" field's value of the MessageRecords entity.
  21486. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21488. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  21489. if !m.op.Is(OpUpdateOne) {
  21490. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21491. }
  21492. if m.id == nil || m.oldValue == nil {
  21493. return v, errors.New("OldContent requires an ID field in the mutation")
  21494. }
  21495. oldValue, err := m.oldValue(ctx)
  21496. if err != nil {
  21497. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21498. }
  21499. return oldValue.Content, nil
  21500. }
  21501. // ResetContent resets all changes to the "content" field.
  21502. func (m *MessageRecordsMutation) ResetContent() {
  21503. m.content = nil
  21504. }
  21505. // SetMeta sets the "meta" field.
  21506. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  21507. m.meta = &ct
  21508. }
  21509. // Meta returns the value of the "meta" field in the mutation.
  21510. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  21511. v := m.meta
  21512. if v == nil {
  21513. return
  21514. }
  21515. return *v, true
  21516. }
  21517. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  21518. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21520. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  21521. if !m.op.Is(OpUpdateOne) {
  21522. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  21523. }
  21524. if m.id == nil || m.oldValue == nil {
  21525. return v, errors.New("OldMeta requires an ID field in the mutation")
  21526. }
  21527. oldValue, err := m.oldValue(ctx)
  21528. if err != nil {
  21529. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  21530. }
  21531. return oldValue.Meta, nil
  21532. }
  21533. // ClearMeta clears the value of the "meta" field.
  21534. func (m *MessageRecordsMutation) ClearMeta() {
  21535. m.meta = nil
  21536. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  21537. }
  21538. // MetaCleared returns if the "meta" field was cleared in this mutation.
  21539. func (m *MessageRecordsMutation) MetaCleared() bool {
  21540. _, ok := m.clearedFields[messagerecords.FieldMeta]
  21541. return ok
  21542. }
  21543. // ResetMeta resets all changes to the "meta" field.
  21544. func (m *MessageRecordsMutation) ResetMeta() {
  21545. m.meta = nil
  21546. delete(m.clearedFields, messagerecords.FieldMeta)
  21547. }
  21548. // SetErrorDetail sets the "error_detail" field.
  21549. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  21550. m.error_detail = &s
  21551. }
  21552. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  21553. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  21554. v := m.error_detail
  21555. if v == nil {
  21556. return
  21557. }
  21558. return *v, true
  21559. }
  21560. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  21561. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21563. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  21564. if !m.op.Is(OpUpdateOne) {
  21565. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  21566. }
  21567. if m.id == nil || m.oldValue == nil {
  21568. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  21569. }
  21570. oldValue, err := m.oldValue(ctx)
  21571. if err != nil {
  21572. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  21573. }
  21574. return oldValue.ErrorDetail, nil
  21575. }
  21576. // ResetErrorDetail resets all changes to the "error_detail" field.
  21577. func (m *MessageRecordsMutation) ResetErrorDetail() {
  21578. m.error_detail = nil
  21579. }
  21580. // SetSendTime sets the "send_time" field.
  21581. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  21582. m.send_time = &t
  21583. }
  21584. // SendTime returns the value of the "send_time" field in the mutation.
  21585. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  21586. v := m.send_time
  21587. if v == nil {
  21588. return
  21589. }
  21590. return *v, true
  21591. }
  21592. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  21593. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21595. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  21596. if !m.op.Is(OpUpdateOne) {
  21597. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  21598. }
  21599. if m.id == nil || m.oldValue == nil {
  21600. return v, errors.New("OldSendTime requires an ID field in the mutation")
  21601. }
  21602. oldValue, err := m.oldValue(ctx)
  21603. if err != nil {
  21604. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  21605. }
  21606. return oldValue.SendTime, nil
  21607. }
  21608. // ClearSendTime clears the value of the "send_time" field.
  21609. func (m *MessageRecordsMutation) ClearSendTime() {
  21610. m.send_time = nil
  21611. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  21612. }
  21613. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  21614. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  21615. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  21616. return ok
  21617. }
  21618. // ResetSendTime resets all changes to the "send_time" field.
  21619. func (m *MessageRecordsMutation) ResetSendTime() {
  21620. m.send_time = nil
  21621. delete(m.clearedFields, messagerecords.FieldSendTime)
  21622. }
  21623. // SetSourceType sets the "source_type" field.
  21624. func (m *MessageRecordsMutation) SetSourceType(i int) {
  21625. m.source_type = &i
  21626. m.addsource_type = nil
  21627. }
  21628. // SourceType returns the value of the "source_type" field in the mutation.
  21629. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  21630. v := m.source_type
  21631. if v == nil {
  21632. return
  21633. }
  21634. return *v, true
  21635. }
  21636. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  21637. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21639. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  21640. if !m.op.Is(OpUpdateOne) {
  21641. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  21642. }
  21643. if m.id == nil || m.oldValue == nil {
  21644. return v, errors.New("OldSourceType requires an ID field in the mutation")
  21645. }
  21646. oldValue, err := m.oldValue(ctx)
  21647. if err != nil {
  21648. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  21649. }
  21650. return oldValue.SourceType, nil
  21651. }
  21652. // AddSourceType adds i to the "source_type" field.
  21653. func (m *MessageRecordsMutation) AddSourceType(i int) {
  21654. if m.addsource_type != nil {
  21655. *m.addsource_type += i
  21656. } else {
  21657. m.addsource_type = &i
  21658. }
  21659. }
  21660. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  21661. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  21662. v := m.addsource_type
  21663. if v == nil {
  21664. return
  21665. }
  21666. return *v, true
  21667. }
  21668. // ResetSourceType resets all changes to the "source_type" field.
  21669. func (m *MessageRecordsMutation) ResetSourceType() {
  21670. m.source_type = nil
  21671. m.addsource_type = nil
  21672. }
  21673. // SetSourceID sets the "source_id" field.
  21674. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  21675. m.sop_stage = &u
  21676. }
  21677. // SourceID returns the value of the "source_id" field in the mutation.
  21678. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  21679. v := m.sop_stage
  21680. if v == nil {
  21681. return
  21682. }
  21683. return *v, true
  21684. }
  21685. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  21686. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21688. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  21689. if !m.op.Is(OpUpdateOne) {
  21690. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  21691. }
  21692. if m.id == nil || m.oldValue == nil {
  21693. return v, errors.New("OldSourceID requires an ID field in the mutation")
  21694. }
  21695. oldValue, err := m.oldValue(ctx)
  21696. if err != nil {
  21697. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  21698. }
  21699. return oldValue.SourceID, nil
  21700. }
  21701. // ClearSourceID clears the value of the "source_id" field.
  21702. func (m *MessageRecordsMutation) ClearSourceID() {
  21703. m.sop_stage = nil
  21704. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21705. }
  21706. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  21707. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  21708. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  21709. return ok
  21710. }
  21711. // ResetSourceID resets all changes to the "source_id" field.
  21712. func (m *MessageRecordsMutation) ResetSourceID() {
  21713. m.sop_stage = nil
  21714. delete(m.clearedFields, messagerecords.FieldSourceID)
  21715. }
  21716. // SetSubSourceID sets the "sub_source_id" field.
  21717. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  21718. m.sop_node = &u
  21719. }
  21720. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  21721. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  21722. v := m.sop_node
  21723. if v == nil {
  21724. return
  21725. }
  21726. return *v, true
  21727. }
  21728. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  21729. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21731. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  21732. if !m.op.Is(OpUpdateOne) {
  21733. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  21734. }
  21735. if m.id == nil || m.oldValue == nil {
  21736. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  21737. }
  21738. oldValue, err := m.oldValue(ctx)
  21739. if err != nil {
  21740. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  21741. }
  21742. return oldValue.SubSourceID, nil
  21743. }
  21744. // ClearSubSourceID clears the value of the "sub_source_id" field.
  21745. func (m *MessageRecordsMutation) ClearSubSourceID() {
  21746. m.sop_node = nil
  21747. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21748. }
  21749. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  21750. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  21751. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  21752. return ok
  21753. }
  21754. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  21755. func (m *MessageRecordsMutation) ResetSubSourceID() {
  21756. m.sop_node = nil
  21757. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  21758. }
  21759. // SetOrganizationID sets the "organization_id" field.
  21760. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  21761. m.organization_id = &u
  21762. m.addorganization_id = nil
  21763. }
  21764. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21765. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  21766. v := m.organization_id
  21767. if v == nil {
  21768. return
  21769. }
  21770. return *v, true
  21771. }
  21772. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  21773. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21775. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21776. if !m.op.Is(OpUpdateOne) {
  21777. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21778. }
  21779. if m.id == nil || m.oldValue == nil {
  21780. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21781. }
  21782. oldValue, err := m.oldValue(ctx)
  21783. if err != nil {
  21784. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21785. }
  21786. return oldValue.OrganizationID, nil
  21787. }
  21788. // AddOrganizationID adds u to the "organization_id" field.
  21789. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  21790. if m.addorganization_id != nil {
  21791. *m.addorganization_id += u
  21792. } else {
  21793. m.addorganization_id = &u
  21794. }
  21795. }
  21796. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21797. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  21798. v := m.addorganization_id
  21799. if v == nil {
  21800. return
  21801. }
  21802. return *v, true
  21803. }
  21804. // ClearOrganizationID clears the value of the "organization_id" field.
  21805. func (m *MessageRecordsMutation) ClearOrganizationID() {
  21806. m.organization_id = nil
  21807. m.addorganization_id = nil
  21808. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  21809. }
  21810. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21811. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  21812. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  21813. return ok
  21814. }
  21815. // ResetOrganizationID resets all changes to the "organization_id" field.
  21816. func (m *MessageRecordsMutation) ResetOrganizationID() {
  21817. m.organization_id = nil
  21818. m.addorganization_id = nil
  21819. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  21820. }
  21821. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21822. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  21823. m.sop_stage = &id
  21824. }
  21825. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21826. func (m *MessageRecordsMutation) ClearSopStage() {
  21827. m.clearedsop_stage = true
  21828. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21829. }
  21830. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21831. func (m *MessageRecordsMutation) SopStageCleared() bool {
  21832. return m.SourceIDCleared() || m.clearedsop_stage
  21833. }
  21834. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21835. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  21836. if m.sop_stage != nil {
  21837. return *m.sop_stage, true
  21838. }
  21839. return
  21840. }
  21841. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21842. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21843. // SopStageID instead. It exists only for internal usage by the builders.
  21844. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  21845. if id := m.sop_stage; id != nil {
  21846. ids = append(ids, *id)
  21847. }
  21848. return
  21849. }
  21850. // ResetSopStage resets all changes to the "sop_stage" edge.
  21851. func (m *MessageRecordsMutation) ResetSopStage() {
  21852. m.sop_stage = nil
  21853. m.clearedsop_stage = false
  21854. }
  21855. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  21856. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  21857. m.sop_node = &id
  21858. }
  21859. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  21860. func (m *MessageRecordsMutation) ClearSopNode() {
  21861. m.clearedsop_node = true
  21862. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21863. }
  21864. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  21865. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  21866. return m.SubSourceIDCleared() || m.clearedsop_node
  21867. }
  21868. // SopNodeID returns the "sop_node" edge ID in the mutation.
  21869. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  21870. if m.sop_node != nil {
  21871. return *m.sop_node, true
  21872. }
  21873. return
  21874. }
  21875. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  21876. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21877. // SopNodeID instead. It exists only for internal usage by the builders.
  21878. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  21879. if id := m.sop_node; id != nil {
  21880. ids = append(ids, *id)
  21881. }
  21882. return
  21883. }
  21884. // ResetSopNode resets all changes to the "sop_node" edge.
  21885. func (m *MessageRecordsMutation) ResetSopNode() {
  21886. m.sop_node = nil
  21887. m.clearedsop_node = false
  21888. }
  21889. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  21890. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  21891. m.message_contact = &id
  21892. }
  21893. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  21894. func (m *MessageRecordsMutation) ClearMessageContact() {
  21895. m.clearedmessage_contact = true
  21896. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21897. }
  21898. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  21899. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  21900. return m.ContactIDCleared() || m.clearedmessage_contact
  21901. }
  21902. // MessageContactID returns the "message_contact" edge ID in the mutation.
  21903. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  21904. if m.message_contact != nil {
  21905. return *m.message_contact, true
  21906. }
  21907. return
  21908. }
  21909. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  21910. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21911. // MessageContactID instead. It exists only for internal usage by the builders.
  21912. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  21913. if id := m.message_contact; id != nil {
  21914. ids = append(ids, *id)
  21915. }
  21916. return
  21917. }
  21918. // ResetMessageContact resets all changes to the "message_contact" edge.
  21919. func (m *MessageRecordsMutation) ResetMessageContact() {
  21920. m.message_contact = nil
  21921. m.clearedmessage_contact = false
  21922. }
  21923. // Where appends a list predicates to the MessageRecordsMutation builder.
  21924. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  21925. m.predicates = append(m.predicates, ps...)
  21926. }
  21927. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  21928. // users can use type-assertion to append predicates that do not depend on any generated package.
  21929. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  21930. p := make([]predicate.MessageRecords, len(ps))
  21931. for i := range ps {
  21932. p[i] = ps[i]
  21933. }
  21934. m.Where(p...)
  21935. }
  21936. // Op returns the operation name.
  21937. func (m *MessageRecordsMutation) Op() Op {
  21938. return m.op
  21939. }
  21940. // SetOp allows setting the mutation operation.
  21941. func (m *MessageRecordsMutation) SetOp(op Op) {
  21942. m.op = op
  21943. }
  21944. // Type returns the node type of this mutation (MessageRecords).
  21945. func (m *MessageRecordsMutation) Type() string {
  21946. return m.typ
  21947. }
  21948. // Fields returns all fields that were changed during this mutation. Note that in
  21949. // order to get all numeric fields that were incremented/decremented, call
  21950. // AddedFields().
  21951. func (m *MessageRecordsMutation) Fields() []string {
  21952. fields := make([]string, 0, 16)
  21953. if m.created_at != nil {
  21954. fields = append(fields, messagerecords.FieldCreatedAt)
  21955. }
  21956. if m.updated_at != nil {
  21957. fields = append(fields, messagerecords.FieldUpdatedAt)
  21958. }
  21959. if m.status != nil {
  21960. fields = append(fields, messagerecords.FieldStatus)
  21961. }
  21962. if m.bot_wxid != nil {
  21963. fields = append(fields, messagerecords.FieldBotWxid)
  21964. }
  21965. if m.message_contact != nil {
  21966. fields = append(fields, messagerecords.FieldContactID)
  21967. }
  21968. if m.contact_type != nil {
  21969. fields = append(fields, messagerecords.FieldContactType)
  21970. }
  21971. if m.contact_wxid != nil {
  21972. fields = append(fields, messagerecords.FieldContactWxid)
  21973. }
  21974. if m.content_type != nil {
  21975. fields = append(fields, messagerecords.FieldContentType)
  21976. }
  21977. if m.content != nil {
  21978. fields = append(fields, messagerecords.FieldContent)
  21979. }
  21980. if m.meta != nil {
  21981. fields = append(fields, messagerecords.FieldMeta)
  21982. }
  21983. if m.error_detail != nil {
  21984. fields = append(fields, messagerecords.FieldErrorDetail)
  21985. }
  21986. if m.send_time != nil {
  21987. fields = append(fields, messagerecords.FieldSendTime)
  21988. }
  21989. if m.source_type != nil {
  21990. fields = append(fields, messagerecords.FieldSourceType)
  21991. }
  21992. if m.sop_stage != nil {
  21993. fields = append(fields, messagerecords.FieldSourceID)
  21994. }
  21995. if m.sop_node != nil {
  21996. fields = append(fields, messagerecords.FieldSubSourceID)
  21997. }
  21998. if m.organization_id != nil {
  21999. fields = append(fields, messagerecords.FieldOrganizationID)
  22000. }
  22001. return fields
  22002. }
  22003. // Field returns the value of a field with the given name. The second boolean
  22004. // return value indicates that this field was not set, or was not defined in the
  22005. // schema.
  22006. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  22007. switch name {
  22008. case messagerecords.FieldCreatedAt:
  22009. return m.CreatedAt()
  22010. case messagerecords.FieldUpdatedAt:
  22011. return m.UpdatedAt()
  22012. case messagerecords.FieldStatus:
  22013. return m.Status()
  22014. case messagerecords.FieldBotWxid:
  22015. return m.BotWxid()
  22016. case messagerecords.FieldContactID:
  22017. return m.ContactID()
  22018. case messagerecords.FieldContactType:
  22019. return m.ContactType()
  22020. case messagerecords.FieldContactWxid:
  22021. return m.ContactWxid()
  22022. case messagerecords.FieldContentType:
  22023. return m.ContentType()
  22024. case messagerecords.FieldContent:
  22025. return m.Content()
  22026. case messagerecords.FieldMeta:
  22027. return m.Meta()
  22028. case messagerecords.FieldErrorDetail:
  22029. return m.ErrorDetail()
  22030. case messagerecords.FieldSendTime:
  22031. return m.SendTime()
  22032. case messagerecords.FieldSourceType:
  22033. return m.SourceType()
  22034. case messagerecords.FieldSourceID:
  22035. return m.SourceID()
  22036. case messagerecords.FieldSubSourceID:
  22037. return m.SubSourceID()
  22038. case messagerecords.FieldOrganizationID:
  22039. return m.OrganizationID()
  22040. }
  22041. return nil, false
  22042. }
  22043. // OldField returns the old value of the field from the database. An error is
  22044. // returned if the mutation operation is not UpdateOne, or the query to the
  22045. // database failed.
  22046. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22047. switch name {
  22048. case messagerecords.FieldCreatedAt:
  22049. return m.OldCreatedAt(ctx)
  22050. case messagerecords.FieldUpdatedAt:
  22051. return m.OldUpdatedAt(ctx)
  22052. case messagerecords.FieldStatus:
  22053. return m.OldStatus(ctx)
  22054. case messagerecords.FieldBotWxid:
  22055. return m.OldBotWxid(ctx)
  22056. case messagerecords.FieldContactID:
  22057. return m.OldContactID(ctx)
  22058. case messagerecords.FieldContactType:
  22059. return m.OldContactType(ctx)
  22060. case messagerecords.FieldContactWxid:
  22061. return m.OldContactWxid(ctx)
  22062. case messagerecords.FieldContentType:
  22063. return m.OldContentType(ctx)
  22064. case messagerecords.FieldContent:
  22065. return m.OldContent(ctx)
  22066. case messagerecords.FieldMeta:
  22067. return m.OldMeta(ctx)
  22068. case messagerecords.FieldErrorDetail:
  22069. return m.OldErrorDetail(ctx)
  22070. case messagerecords.FieldSendTime:
  22071. return m.OldSendTime(ctx)
  22072. case messagerecords.FieldSourceType:
  22073. return m.OldSourceType(ctx)
  22074. case messagerecords.FieldSourceID:
  22075. return m.OldSourceID(ctx)
  22076. case messagerecords.FieldSubSourceID:
  22077. return m.OldSubSourceID(ctx)
  22078. case messagerecords.FieldOrganizationID:
  22079. return m.OldOrganizationID(ctx)
  22080. }
  22081. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  22082. }
  22083. // SetField sets the value of a field with the given name. It returns an error if
  22084. // the field is not defined in the schema, or if the type mismatched the field
  22085. // type.
  22086. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  22087. switch name {
  22088. case messagerecords.FieldCreatedAt:
  22089. v, ok := value.(time.Time)
  22090. if !ok {
  22091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22092. }
  22093. m.SetCreatedAt(v)
  22094. return nil
  22095. case messagerecords.FieldUpdatedAt:
  22096. v, ok := value.(time.Time)
  22097. if !ok {
  22098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22099. }
  22100. m.SetUpdatedAt(v)
  22101. return nil
  22102. case messagerecords.FieldStatus:
  22103. v, ok := value.(uint8)
  22104. if !ok {
  22105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22106. }
  22107. m.SetStatus(v)
  22108. return nil
  22109. case messagerecords.FieldBotWxid:
  22110. v, ok := value.(string)
  22111. if !ok {
  22112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22113. }
  22114. m.SetBotWxid(v)
  22115. return nil
  22116. case messagerecords.FieldContactID:
  22117. v, ok := value.(uint64)
  22118. if !ok {
  22119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22120. }
  22121. m.SetContactID(v)
  22122. return nil
  22123. case messagerecords.FieldContactType:
  22124. v, ok := value.(int)
  22125. if !ok {
  22126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22127. }
  22128. m.SetContactType(v)
  22129. return nil
  22130. case messagerecords.FieldContactWxid:
  22131. v, ok := value.(string)
  22132. if !ok {
  22133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22134. }
  22135. m.SetContactWxid(v)
  22136. return nil
  22137. case messagerecords.FieldContentType:
  22138. v, ok := value.(int)
  22139. if !ok {
  22140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22141. }
  22142. m.SetContentType(v)
  22143. return nil
  22144. case messagerecords.FieldContent:
  22145. v, ok := value.(string)
  22146. if !ok {
  22147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22148. }
  22149. m.SetContent(v)
  22150. return nil
  22151. case messagerecords.FieldMeta:
  22152. v, ok := value.(custom_types.Meta)
  22153. if !ok {
  22154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22155. }
  22156. m.SetMeta(v)
  22157. return nil
  22158. case messagerecords.FieldErrorDetail:
  22159. v, ok := value.(string)
  22160. if !ok {
  22161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22162. }
  22163. m.SetErrorDetail(v)
  22164. return nil
  22165. case messagerecords.FieldSendTime:
  22166. v, ok := value.(time.Time)
  22167. if !ok {
  22168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22169. }
  22170. m.SetSendTime(v)
  22171. return nil
  22172. case messagerecords.FieldSourceType:
  22173. v, ok := value.(int)
  22174. if !ok {
  22175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22176. }
  22177. m.SetSourceType(v)
  22178. return nil
  22179. case messagerecords.FieldSourceID:
  22180. v, ok := value.(uint64)
  22181. if !ok {
  22182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22183. }
  22184. m.SetSourceID(v)
  22185. return nil
  22186. case messagerecords.FieldSubSourceID:
  22187. v, ok := value.(uint64)
  22188. if !ok {
  22189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22190. }
  22191. m.SetSubSourceID(v)
  22192. return nil
  22193. case messagerecords.FieldOrganizationID:
  22194. v, ok := value.(uint64)
  22195. if !ok {
  22196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22197. }
  22198. m.SetOrganizationID(v)
  22199. return nil
  22200. }
  22201. return fmt.Errorf("unknown MessageRecords field %s", name)
  22202. }
  22203. // AddedFields returns all numeric fields that were incremented/decremented during
  22204. // this mutation.
  22205. func (m *MessageRecordsMutation) AddedFields() []string {
  22206. var fields []string
  22207. if m.addstatus != nil {
  22208. fields = append(fields, messagerecords.FieldStatus)
  22209. }
  22210. if m.addcontact_type != nil {
  22211. fields = append(fields, messagerecords.FieldContactType)
  22212. }
  22213. if m.addcontent_type != nil {
  22214. fields = append(fields, messagerecords.FieldContentType)
  22215. }
  22216. if m.addsource_type != nil {
  22217. fields = append(fields, messagerecords.FieldSourceType)
  22218. }
  22219. if m.addorganization_id != nil {
  22220. fields = append(fields, messagerecords.FieldOrganizationID)
  22221. }
  22222. return fields
  22223. }
  22224. // AddedField returns the numeric value that was incremented/decremented on a field
  22225. // with the given name. The second boolean return value indicates that this field
  22226. // was not set, or was not defined in the schema.
  22227. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  22228. switch name {
  22229. case messagerecords.FieldStatus:
  22230. return m.AddedStatus()
  22231. case messagerecords.FieldContactType:
  22232. return m.AddedContactType()
  22233. case messagerecords.FieldContentType:
  22234. return m.AddedContentType()
  22235. case messagerecords.FieldSourceType:
  22236. return m.AddedSourceType()
  22237. case messagerecords.FieldOrganizationID:
  22238. return m.AddedOrganizationID()
  22239. }
  22240. return nil, false
  22241. }
  22242. // AddField adds the value to the field with the given name. It returns an error if
  22243. // the field is not defined in the schema, or if the type mismatched the field
  22244. // type.
  22245. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  22246. switch name {
  22247. case messagerecords.FieldStatus:
  22248. v, ok := value.(int8)
  22249. if !ok {
  22250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22251. }
  22252. m.AddStatus(v)
  22253. return nil
  22254. case messagerecords.FieldContactType:
  22255. v, ok := value.(int)
  22256. if !ok {
  22257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22258. }
  22259. m.AddContactType(v)
  22260. return nil
  22261. case messagerecords.FieldContentType:
  22262. v, ok := value.(int)
  22263. if !ok {
  22264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22265. }
  22266. m.AddContentType(v)
  22267. return nil
  22268. case messagerecords.FieldSourceType:
  22269. v, ok := value.(int)
  22270. if !ok {
  22271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22272. }
  22273. m.AddSourceType(v)
  22274. return nil
  22275. case messagerecords.FieldOrganizationID:
  22276. v, ok := value.(int64)
  22277. if !ok {
  22278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22279. }
  22280. m.AddOrganizationID(v)
  22281. return nil
  22282. }
  22283. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  22284. }
  22285. // ClearedFields returns all nullable fields that were cleared during this
  22286. // mutation.
  22287. func (m *MessageRecordsMutation) ClearedFields() []string {
  22288. var fields []string
  22289. if m.FieldCleared(messagerecords.FieldStatus) {
  22290. fields = append(fields, messagerecords.FieldStatus)
  22291. }
  22292. if m.FieldCleared(messagerecords.FieldContactID) {
  22293. fields = append(fields, messagerecords.FieldContactID)
  22294. }
  22295. if m.FieldCleared(messagerecords.FieldMeta) {
  22296. fields = append(fields, messagerecords.FieldMeta)
  22297. }
  22298. if m.FieldCleared(messagerecords.FieldSendTime) {
  22299. fields = append(fields, messagerecords.FieldSendTime)
  22300. }
  22301. if m.FieldCleared(messagerecords.FieldSourceID) {
  22302. fields = append(fields, messagerecords.FieldSourceID)
  22303. }
  22304. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  22305. fields = append(fields, messagerecords.FieldSubSourceID)
  22306. }
  22307. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  22308. fields = append(fields, messagerecords.FieldOrganizationID)
  22309. }
  22310. return fields
  22311. }
  22312. // FieldCleared returns a boolean indicating if a field with the given name was
  22313. // cleared in this mutation.
  22314. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  22315. _, ok := m.clearedFields[name]
  22316. return ok
  22317. }
  22318. // ClearField clears the value of the field with the given name. It returns an
  22319. // error if the field is not defined in the schema.
  22320. func (m *MessageRecordsMutation) ClearField(name string) error {
  22321. switch name {
  22322. case messagerecords.FieldStatus:
  22323. m.ClearStatus()
  22324. return nil
  22325. case messagerecords.FieldContactID:
  22326. m.ClearContactID()
  22327. return nil
  22328. case messagerecords.FieldMeta:
  22329. m.ClearMeta()
  22330. return nil
  22331. case messagerecords.FieldSendTime:
  22332. m.ClearSendTime()
  22333. return nil
  22334. case messagerecords.FieldSourceID:
  22335. m.ClearSourceID()
  22336. return nil
  22337. case messagerecords.FieldSubSourceID:
  22338. m.ClearSubSourceID()
  22339. return nil
  22340. case messagerecords.FieldOrganizationID:
  22341. m.ClearOrganizationID()
  22342. return nil
  22343. }
  22344. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  22345. }
  22346. // ResetField resets all changes in the mutation for the field with the given name.
  22347. // It returns an error if the field is not defined in the schema.
  22348. func (m *MessageRecordsMutation) ResetField(name string) error {
  22349. switch name {
  22350. case messagerecords.FieldCreatedAt:
  22351. m.ResetCreatedAt()
  22352. return nil
  22353. case messagerecords.FieldUpdatedAt:
  22354. m.ResetUpdatedAt()
  22355. return nil
  22356. case messagerecords.FieldStatus:
  22357. m.ResetStatus()
  22358. return nil
  22359. case messagerecords.FieldBotWxid:
  22360. m.ResetBotWxid()
  22361. return nil
  22362. case messagerecords.FieldContactID:
  22363. m.ResetContactID()
  22364. return nil
  22365. case messagerecords.FieldContactType:
  22366. m.ResetContactType()
  22367. return nil
  22368. case messagerecords.FieldContactWxid:
  22369. m.ResetContactWxid()
  22370. return nil
  22371. case messagerecords.FieldContentType:
  22372. m.ResetContentType()
  22373. return nil
  22374. case messagerecords.FieldContent:
  22375. m.ResetContent()
  22376. return nil
  22377. case messagerecords.FieldMeta:
  22378. m.ResetMeta()
  22379. return nil
  22380. case messagerecords.FieldErrorDetail:
  22381. m.ResetErrorDetail()
  22382. return nil
  22383. case messagerecords.FieldSendTime:
  22384. m.ResetSendTime()
  22385. return nil
  22386. case messagerecords.FieldSourceType:
  22387. m.ResetSourceType()
  22388. return nil
  22389. case messagerecords.FieldSourceID:
  22390. m.ResetSourceID()
  22391. return nil
  22392. case messagerecords.FieldSubSourceID:
  22393. m.ResetSubSourceID()
  22394. return nil
  22395. case messagerecords.FieldOrganizationID:
  22396. m.ResetOrganizationID()
  22397. return nil
  22398. }
  22399. return fmt.Errorf("unknown MessageRecords field %s", name)
  22400. }
  22401. // AddedEdges returns all edge names that were set/added in this mutation.
  22402. func (m *MessageRecordsMutation) AddedEdges() []string {
  22403. edges := make([]string, 0, 3)
  22404. if m.sop_stage != nil {
  22405. edges = append(edges, messagerecords.EdgeSopStage)
  22406. }
  22407. if m.sop_node != nil {
  22408. edges = append(edges, messagerecords.EdgeSopNode)
  22409. }
  22410. if m.message_contact != nil {
  22411. edges = append(edges, messagerecords.EdgeMessageContact)
  22412. }
  22413. return edges
  22414. }
  22415. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22416. // name in this mutation.
  22417. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  22418. switch name {
  22419. case messagerecords.EdgeSopStage:
  22420. if id := m.sop_stage; id != nil {
  22421. return []ent.Value{*id}
  22422. }
  22423. case messagerecords.EdgeSopNode:
  22424. if id := m.sop_node; id != nil {
  22425. return []ent.Value{*id}
  22426. }
  22427. case messagerecords.EdgeMessageContact:
  22428. if id := m.message_contact; id != nil {
  22429. return []ent.Value{*id}
  22430. }
  22431. }
  22432. return nil
  22433. }
  22434. // RemovedEdges returns all edge names that were removed in this mutation.
  22435. func (m *MessageRecordsMutation) RemovedEdges() []string {
  22436. edges := make([]string, 0, 3)
  22437. return edges
  22438. }
  22439. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22440. // the given name in this mutation.
  22441. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  22442. return nil
  22443. }
  22444. // ClearedEdges returns all edge names that were cleared in this mutation.
  22445. func (m *MessageRecordsMutation) ClearedEdges() []string {
  22446. edges := make([]string, 0, 3)
  22447. if m.clearedsop_stage {
  22448. edges = append(edges, messagerecords.EdgeSopStage)
  22449. }
  22450. if m.clearedsop_node {
  22451. edges = append(edges, messagerecords.EdgeSopNode)
  22452. }
  22453. if m.clearedmessage_contact {
  22454. edges = append(edges, messagerecords.EdgeMessageContact)
  22455. }
  22456. return edges
  22457. }
  22458. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22459. // was cleared in this mutation.
  22460. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  22461. switch name {
  22462. case messagerecords.EdgeSopStage:
  22463. return m.clearedsop_stage
  22464. case messagerecords.EdgeSopNode:
  22465. return m.clearedsop_node
  22466. case messagerecords.EdgeMessageContact:
  22467. return m.clearedmessage_contact
  22468. }
  22469. return false
  22470. }
  22471. // ClearEdge clears the value of the edge with the given name. It returns an error
  22472. // if that edge is not defined in the schema.
  22473. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  22474. switch name {
  22475. case messagerecords.EdgeSopStage:
  22476. m.ClearSopStage()
  22477. return nil
  22478. case messagerecords.EdgeSopNode:
  22479. m.ClearSopNode()
  22480. return nil
  22481. case messagerecords.EdgeMessageContact:
  22482. m.ClearMessageContact()
  22483. return nil
  22484. }
  22485. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  22486. }
  22487. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22488. // It returns an error if the edge is not defined in the schema.
  22489. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  22490. switch name {
  22491. case messagerecords.EdgeSopStage:
  22492. m.ResetSopStage()
  22493. return nil
  22494. case messagerecords.EdgeSopNode:
  22495. m.ResetSopNode()
  22496. return nil
  22497. case messagerecords.EdgeMessageContact:
  22498. m.ResetMessageContact()
  22499. return nil
  22500. }
  22501. return fmt.Errorf("unknown MessageRecords edge %s", name)
  22502. }
  22503. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  22504. type MsgMutation struct {
  22505. config
  22506. op Op
  22507. typ string
  22508. id *uint64
  22509. created_at *time.Time
  22510. updated_at *time.Time
  22511. deleted_at *time.Time
  22512. status *uint8
  22513. addstatus *int8
  22514. fromwxid *string
  22515. toid *string
  22516. msgtype *int32
  22517. addmsgtype *int32
  22518. msg *string
  22519. batch_no *string
  22520. cc *string
  22521. phone *string
  22522. clearedFields map[string]struct{}
  22523. done bool
  22524. oldValue func(context.Context) (*Msg, error)
  22525. predicates []predicate.Msg
  22526. }
  22527. var _ ent.Mutation = (*MsgMutation)(nil)
  22528. // msgOption allows management of the mutation configuration using functional options.
  22529. type msgOption func(*MsgMutation)
  22530. // newMsgMutation creates new mutation for the Msg entity.
  22531. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  22532. m := &MsgMutation{
  22533. config: c,
  22534. op: op,
  22535. typ: TypeMsg,
  22536. clearedFields: make(map[string]struct{}),
  22537. }
  22538. for _, opt := range opts {
  22539. opt(m)
  22540. }
  22541. return m
  22542. }
  22543. // withMsgID sets the ID field of the mutation.
  22544. func withMsgID(id uint64) msgOption {
  22545. return func(m *MsgMutation) {
  22546. var (
  22547. err error
  22548. once sync.Once
  22549. value *Msg
  22550. )
  22551. m.oldValue = func(ctx context.Context) (*Msg, error) {
  22552. once.Do(func() {
  22553. if m.done {
  22554. err = errors.New("querying old values post mutation is not allowed")
  22555. } else {
  22556. value, err = m.Client().Msg.Get(ctx, id)
  22557. }
  22558. })
  22559. return value, err
  22560. }
  22561. m.id = &id
  22562. }
  22563. }
  22564. // withMsg sets the old Msg of the mutation.
  22565. func withMsg(node *Msg) msgOption {
  22566. return func(m *MsgMutation) {
  22567. m.oldValue = func(context.Context) (*Msg, error) {
  22568. return node, nil
  22569. }
  22570. m.id = &node.ID
  22571. }
  22572. }
  22573. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22574. // executed in a transaction (ent.Tx), a transactional client is returned.
  22575. func (m MsgMutation) Client() *Client {
  22576. client := &Client{config: m.config}
  22577. client.init()
  22578. return client
  22579. }
  22580. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22581. // it returns an error otherwise.
  22582. func (m MsgMutation) Tx() (*Tx, error) {
  22583. if _, ok := m.driver.(*txDriver); !ok {
  22584. return nil, errors.New("ent: mutation is not running in a transaction")
  22585. }
  22586. tx := &Tx{config: m.config}
  22587. tx.init()
  22588. return tx, nil
  22589. }
  22590. // SetID sets the value of the id field. Note that this
  22591. // operation is only accepted on creation of Msg entities.
  22592. func (m *MsgMutation) SetID(id uint64) {
  22593. m.id = &id
  22594. }
  22595. // ID returns the ID value in the mutation. Note that the ID is only available
  22596. // if it was provided to the builder or after it was returned from the database.
  22597. func (m *MsgMutation) ID() (id uint64, exists bool) {
  22598. if m.id == nil {
  22599. return
  22600. }
  22601. return *m.id, true
  22602. }
  22603. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22604. // That means, if the mutation is applied within a transaction with an isolation level such
  22605. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22606. // or updated by the mutation.
  22607. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  22608. switch {
  22609. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22610. id, exists := m.ID()
  22611. if exists {
  22612. return []uint64{id}, nil
  22613. }
  22614. fallthrough
  22615. case m.op.Is(OpUpdate | OpDelete):
  22616. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  22617. default:
  22618. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22619. }
  22620. }
  22621. // SetCreatedAt sets the "created_at" field.
  22622. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  22623. m.created_at = &t
  22624. }
  22625. // CreatedAt returns the value of the "created_at" field in the mutation.
  22626. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  22627. v := m.created_at
  22628. if v == nil {
  22629. return
  22630. }
  22631. return *v, true
  22632. }
  22633. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  22634. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22636. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22637. if !m.op.Is(OpUpdateOne) {
  22638. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22639. }
  22640. if m.id == nil || m.oldValue == nil {
  22641. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22642. }
  22643. oldValue, err := m.oldValue(ctx)
  22644. if err != nil {
  22645. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22646. }
  22647. return oldValue.CreatedAt, nil
  22648. }
  22649. // ResetCreatedAt resets all changes to the "created_at" field.
  22650. func (m *MsgMutation) ResetCreatedAt() {
  22651. m.created_at = nil
  22652. }
  22653. // SetUpdatedAt sets the "updated_at" field.
  22654. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  22655. m.updated_at = &t
  22656. }
  22657. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22658. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  22659. v := m.updated_at
  22660. if v == nil {
  22661. return
  22662. }
  22663. return *v, true
  22664. }
  22665. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  22666. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22668. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22669. if !m.op.Is(OpUpdateOne) {
  22670. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22671. }
  22672. if m.id == nil || m.oldValue == nil {
  22673. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22674. }
  22675. oldValue, err := m.oldValue(ctx)
  22676. if err != nil {
  22677. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22678. }
  22679. return oldValue.UpdatedAt, nil
  22680. }
  22681. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22682. func (m *MsgMutation) ResetUpdatedAt() {
  22683. m.updated_at = nil
  22684. }
  22685. // SetDeletedAt sets the "deleted_at" field.
  22686. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  22687. m.deleted_at = &t
  22688. }
  22689. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22690. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  22691. v := m.deleted_at
  22692. if v == nil {
  22693. return
  22694. }
  22695. return *v, true
  22696. }
  22697. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  22698. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22700. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22701. if !m.op.Is(OpUpdateOne) {
  22702. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22703. }
  22704. if m.id == nil || m.oldValue == nil {
  22705. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22706. }
  22707. oldValue, err := m.oldValue(ctx)
  22708. if err != nil {
  22709. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22710. }
  22711. return oldValue.DeletedAt, nil
  22712. }
  22713. // ClearDeletedAt clears the value of the "deleted_at" field.
  22714. func (m *MsgMutation) ClearDeletedAt() {
  22715. m.deleted_at = nil
  22716. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  22717. }
  22718. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22719. func (m *MsgMutation) DeletedAtCleared() bool {
  22720. _, ok := m.clearedFields[msg.FieldDeletedAt]
  22721. return ok
  22722. }
  22723. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22724. func (m *MsgMutation) ResetDeletedAt() {
  22725. m.deleted_at = nil
  22726. delete(m.clearedFields, msg.FieldDeletedAt)
  22727. }
  22728. // SetStatus sets the "status" field.
  22729. func (m *MsgMutation) SetStatus(u uint8) {
  22730. m.status = &u
  22731. m.addstatus = nil
  22732. }
  22733. // Status returns the value of the "status" field in the mutation.
  22734. func (m *MsgMutation) Status() (r uint8, exists bool) {
  22735. v := m.status
  22736. if v == nil {
  22737. return
  22738. }
  22739. return *v, true
  22740. }
  22741. // OldStatus returns the old "status" field's value of the Msg entity.
  22742. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22744. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22745. if !m.op.Is(OpUpdateOne) {
  22746. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22747. }
  22748. if m.id == nil || m.oldValue == nil {
  22749. return v, errors.New("OldStatus requires an ID field in the mutation")
  22750. }
  22751. oldValue, err := m.oldValue(ctx)
  22752. if err != nil {
  22753. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22754. }
  22755. return oldValue.Status, nil
  22756. }
  22757. // AddStatus adds u to the "status" field.
  22758. func (m *MsgMutation) AddStatus(u int8) {
  22759. if m.addstatus != nil {
  22760. *m.addstatus += u
  22761. } else {
  22762. m.addstatus = &u
  22763. }
  22764. }
  22765. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22766. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  22767. v := m.addstatus
  22768. if v == nil {
  22769. return
  22770. }
  22771. return *v, true
  22772. }
  22773. // ClearStatus clears the value of the "status" field.
  22774. func (m *MsgMutation) ClearStatus() {
  22775. m.status = nil
  22776. m.addstatus = nil
  22777. m.clearedFields[msg.FieldStatus] = struct{}{}
  22778. }
  22779. // StatusCleared returns if the "status" field was cleared in this mutation.
  22780. func (m *MsgMutation) StatusCleared() bool {
  22781. _, ok := m.clearedFields[msg.FieldStatus]
  22782. return ok
  22783. }
  22784. // ResetStatus resets all changes to the "status" field.
  22785. func (m *MsgMutation) ResetStatus() {
  22786. m.status = nil
  22787. m.addstatus = nil
  22788. delete(m.clearedFields, msg.FieldStatus)
  22789. }
  22790. // SetFromwxid sets the "fromwxid" field.
  22791. func (m *MsgMutation) SetFromwxid(s string) {
  22792. m.fromwxid = &s
  22793. }
  22794. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  22795. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  22796. v := m.fromwxid
  22797. if v == nil {
  22798. return
  22799. }
  22800. return *v, true
  22801. }
  22802. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  22803. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22805. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  22806. if !m.op.Is(OpUpdateOne) {
  22807. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  22808. }
  22809. if m.id == nil || m.oldValue == nil {
  22810. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  22811. }
  22812. oldValue, err := m.oldValue(ctx)
  22813. if err != nil {
  22814. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  22815. }
  22816. return oldValue.Fromwxid, nil
  22817. }
  22818. // ClearFromwxid clears the value of the "fromwxid" field.
  22819. func (m *MsgMutation) ClearFromwxid() {
  22820. m.fromwxid = nil
  22821. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  22822. }
  22823. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  22824. func (m *MsgMutation) FromwxidCleared() bool {
  22825. _, ok := m.clearedFields[msg.FieldFromwxid]
  22826. return ok
  22827. }
  22828. // ResetFromwxid resets all changes to the "fromwxid" field.
  22829. func (m *MsgMutation) ResetFromwxid() {
  22830. m.fromwxid = nil
  22831. delete(m.clearedFields, msg.FieldFromwxid)
  22832. }
  22833. // SetToid sets the "toid" field.
  22834. func (m *MsgMutation) SetToid(s string) {
  22835. m.toid = &s
  22836. }
  22837. // Toid returns the value of the "toid" field in the mutation.
  22838. func (m *MsgMutation) Toid() (r string, exists bool) {
  22839. v := m.toid
  22840. if v == nil {
  22841. return
  22842. }
  22843. return *v, true
  22844. }
  22845. // OldToid returns the old "toid" field's value of the Msg entity.
  22846. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22848. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  22849. if !m.op.Is(OpUpdateOne) {
  22850. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  22851. }
  22852. if m.id == nil || m.oldValue == nil {
  22853. return v, errors.New("OldToid requires an ID field in the mutation")
  22854. }
  22855. oldValue, err := m.oldValue(ctx)
  22856. if err != nil {
  22857. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  22858. }
  22859. return oldValue.Toid, nil
  22860. }
  22861. // ClearToid clears the value of the "toid" field.
  22862. func (m *MsgMutation) ClearToid() {
  22863. m.toid = nil
  22864. m.clearedFields[msg.FieldToid] = struct{}{}
  22865. }
  22866. // ToidCleared returns if the "toid" field was cleared in this mutation.
  22867. func (m *MsgMutation) ToidCleared() bool {
  22868. _, ok := m.clearedFields[msg.FieldToid]
  22869. return ok
  22870. }
  22871. // ResetToid resets all changes to the "toid" field.
  22872. func (m *MsgMutation) ResetToid() {
  22873. m.toid = nil
  22874. delete(m.clearedFields, msg.FieldToid)
  22875. }
  22876. // SetMsgtype sets the "msgtype" field.
  22877. func (m *MsgMutation) SetMsgtype(i int32) {
  22878. m.msgtype = &i
  22879. m.addmsgtype = nil
  22880. }
  22881. // Msgtype returns the value of the "msgtype" field in the mutation.
  22882. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  22883. v := m.msgtype
  22884. if v == nil {
  22885. return
  22886. }
  22887. return *v, true
  22888. }
  22889. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  22890. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22892. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  22893. if !m.op.Is(OpUpdateOne) {
  22894. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  22895. }
  22896. if m.id == nil || m.oldValue == nil {
  22897. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  22898. }
  22899. oldValue, err := m.oldValue(ctx)
  22900. if err != nil {
  22901. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  22902. }
  22903. return oldValue.Msgtype, nil
  22904. }
  22905. // AddMsgtype adds i to the "msgtype" field.
  22906. func (m *MsgMutation) AddMsgtype(i int32) {
  22907. if m.addmsgtype != nil {
  22908. *m.addmsgtype += i
  22909. } else {
  22910. m.addmsgtype = &i
  22911. }
  22912. }
  22913. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  22914. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  22915. v := m.addmsgtype
  22916. if v == nil {
  22917. return
  22918. }
  22919. return *v, true
  22920. }
  22921. // ClearMsgtype clears the value of the "msgtype" field.
  22922. func (m *MsgMutation) ClearMsgtype() {
  22923. m.msgtype = nil
  22924. m.addmsgtype = nil
  22925. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  22926. }
  22927. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  22928. func (m *MsgMutation) MsgtypeCleared() bool {
  22929. _, ok := m.clearedFields[msg.FieldMsgtype]
  22930. return ok
  22931. }
  22932. // ResetMsgtype resets all changes to the "msgtype" field.
  22933. func (m *MsgMutation) ResetMsgtype() {
  22934. m.msgtype = nil
  22935. m.addmsgtype = nil
  22936. delete(m.clearedFields, msg.FieldMsgtype)
  22937. }
  22938. // SetMsg sets the "msg" field.
  22939. func (m *MsgMutation) SetMsg(s string) {
  22940. m.msg = &s
  22941. }
  22942. // Msg returns the value of the "msg" field in the mutation.
  22943. func (m *MsgMutation) Msg() (r string, exists bool) {
  22944. v := m.msg
  22945. if v == nil {
  22946. return
  22947. }
  22948. return *v, true
  22949. }
  22950. // OldMsg returns the old "msg" field's value of the Msg entity.
  22951. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22953. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  22954. if !m.op.Is(OpUpdateOne) {
  22955. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  22956. }
  22957. if m.id == nil || m.oldValue == nil {
  22958. return v, errors.New("OldMsg requires an ID field in the mutation")
  22959. }
  22960. oldValue, err := m.oldValue(ctx)
  22961. if err != nil {
  22962. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  22963. }
  22964. return oldValue.Msg, nil
  22965. }
  22966. // ClearMsg clears the value of the "msg" field.
  22967. func (m *MsgMutation) ClearMsg() {
  22968. m.msg = nil
  22969. m.clearedFields[msg.FieldMsg] = struct{}{}
  22970. }
  22971. // MsgCleared returns if the "msg" field was cleared in this mutation.
  22972. func (m *MsgMutation) MsgCleared() bool {
  22973. _, ok := m.clearedFields[msg.FieldMsg]
  22974. return ok
  22975. }
  22976. // ResetMsg resets all changes to the "msg" field.
  22977. func (m *MsgMutation) ResetMsg() {
  22978. m.msg = nil
  22979. delete(m.clearedFields, msg.FieldMsg)
  22980. }
  22981. // SetBatchNo sets the "batch_no" field.
  22982. func (m *MsgMutation) SetBatchNo(s string) {
  22983. m.batch_no = &s
  22984. }
  22985. // BatchNo returns the value of the "batch_no" field in the mutation.
  22986. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  22987. v := m.batch_no
  22988. if v == nil {
  22989. return
  22990. }
  22991. return *v, true
  22992. }
  22993. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  22994. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22996. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  22997. if !m.op.Is(OpUpdateOne) {
  22998. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  22999. }
  23000. if m.id == nil || m.oldValue == nil {
  23001. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  23002. }
  23003. oldValue, err := m.oldValue(ctx)
  23004. if err != nil {
  23005. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  23006. }
  23007. return oldValue.BatchNo, nil
  23008. }
  23009. // ClearBatchNo clears the value of the "batch_no" field.
  23010. func (m *MsgMutation) ClearBatchNo() {
  23011. m.batch_no = nil
  23012. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  23013. }
  23014. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  23015. func (m *MsgMutation) BatchNoCleared() bool {
  23016. _, ok := m.clearedFields[msg.FieldBatchNo]
  23017. return ok
  23018. }
  23019. // ResetBatchNo resets all changes to the "batch_no" field.
  23020. func (m *MsgMutation) ResetBatchNo() {
  23021. m.batch_no = nil
  23022. delete(m.clearedFields, msg.FieldBatchNo)
  23023. }
  23024. // SetCc sets the "cc" field.
  23025. func (m *MsgMutation) SetCc(s string) {
  23026. m.cc = &s
  23027. }
  23028. // Cc returns the value of the "cc" field in the mutation.
  23029. func (m *MsgMutation) Cc() (r string, exists bool) {
  23030. v := m.cc
  23031. if v == nil {
  23032. return
  23033. }
  23034. return *v, true
  23035. }
  23036. // OldCc returns the old "cc" field's value of the Msg entity.
  23037. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23039. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  23040. if !m.op.Is(OpUpdateOne) {
  23041. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  23042. }
  23043. if m.id == nil || m.oldValue == nil {
  23044. return v, errors.New("OldCc requires an ID field in the mutation")
  23045. }
  23046. oldValue, err := m.oldValue(ctx)
  23047. if err != nil {
  23048. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  23049. }
  23050. return oldValue.Cc, nil
  23051. }
  23052. // ResetCc resets all changes to the "cc" field.
  23053. func (m *MsgMutation) ResetCc() {
  23054. m.cc = nil
  23055. }
  23056. // SetPhone sets the "phone" field.
  23057. func (m *MsgMutation) SetPhone(s string) {
  23058. m.phone = &s
  23059. }
  23060. // Phone returns the value of the "phone" field in the mutation.
  23061. func (m *MsgMutation) Phone() (r string, exists bool) {
  23062. v := m.phone
  23063. if v == nil {
  23064. return
  23065. }
  23066. return *v, true
  23067. }
  23068. // OldPhone returns the old "phone" field's value of the Msg entity.
  23069. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23071. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  23072. if !m.op.Is(OpUpdateOne) {
  23073. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  23074. }
  23075. if m.id == nil || m.oldValue == nil {
  23076. return v, errors.New("OldPhone requires an ID field in the mutation")
  23077. }
  23078. oldValue, err := m.oldValue(ctx)
  23079. if err != nil {
  23080. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  23081. }
  23082. return oldValue.Phone, nil
  23083. }
  23084. // ResetPhone resets all changes to the "phone" field.
  23085. func (m *MsgMutation) ResetPhone() {
  23086. m.phone = nil
  23087. }
  23088. // Where appends a list predicates to the MsgMutation builder.
  23089. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  23090. m.predicates = append(m.predicates, ps...)
  23091. }
  23092. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  23093. // users can use type-assertion to append predicates that do not depend on any generated package.
  23094. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  23095. p := make([]predicate.Msg, len(ps))
  23096. for i := range ps {
  23097. p[i] = ps[i]
  23098. }
  23099. m.Where(p...)
  23100. }
  23101. // Op returns the operation name.
  23102. func (m *MsgMutation) Op() Op {
  23103. return m.op
  23104. }
  23105. // SetOp allows setting the mutation operation.
  23106. func (m *MsgMutation) SetOp(op Op) {
  23107. m.op = op
  23108. }
  23109. // Type returns the node type of this mutation (Msg).
  23110. func (m *MsgMutation) Type() string {
  23111. return m.typ
  23112. }
  23113. // Fields returns all fields that were changed during this mutation. Note that in
  23114. // order to get all numeric fields that were incremented/decremented, call
  23115. // AddedFields().
  23116. func (m *MsgMutation) Fields() []string {
  23117. fields := make([]string, 0, 11)
  23118. if m.created_at != nil {
  23119. fields = append(fields, msg.FieldCreatedAt)
  23120. }
  23121. if m.updated_at != nil {
  23122. fields = append(fields, msg.FieldUpdatedAt)
  23123. }
  23124. if m.deleted_at != nil {
  23125. fields = append(fields, msg.FieldDeletedAt)
  23126. }
  23127. if m.status != nil {
  23128. fields = append(fields, msg.FieldStatus)
  23129. }
  23130. if m.fromwxid != nil {
  23131. fields = append(fields, msg.FieldFromwxid)
  23132. }
  23133. if m.toid != nil {
  23134. fields = append(fields, msg.FieldToid)
  23135. }
  23136. if m.msgtype != nil {
  23137. fields = append(fields, msg.FieldMsgtype)
  23138. }
  23139. if m.msg != nil {
  23140. fields = append(fields, msg.FieldMsg)
  23141. }
  23142. if m.batch_no != nil {
  23143. fields = append(fields, msg.FieldBatchNo)
  23144. }
  23145. if m.cc != nil {
  23146. fields = append(fields, msg.FieldCc)
  23147. }
  23148. if m.phone != nil {
  23149. fields = append(fields, msg.FieldPhone)
  23150. }
  23151. return fields
  23152. }
  23153. // Field returns the value of a field with the given name. The second boolean
  23154. // return value indicates that this field was not set, or was not defined in the
  23155. // schema.
  23156. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  23157. switch name {
  23158. case msg.FieldCreatedAt:
  23159. return m.CreatedAt()
  23160. case msg.FieldUpdatedAt:
  23161. return m.UpdatedAt()
  23162. case msg.FieldDeletedAt:
  23163. return m.DeletedAt()
  23164. case msg.FieldStatus:
  23165. return m.Status()
  23166. case msg.FieldFromwxid:
  23167. return m.Fromwxid()
  23168. case msg.FieldToid:
  23169. return m.Toid()
  23170. case msg.FieldMsgtype:
  23171. return m.Msgtype()
  23172. case msg.FieldMsg:
  23173. return m.Msg()
  23174. case msg.FieldBatchNo:
  23175. return m.BatchNo()
  23176. case msg.FieldCc:
  23177. return m.Cc()
  23178. case msg.FieldPhone:
  23179. return m.Phone()
  23180. }
  23181. return nil, false
  23182. }
  23183. // OldField returns the old value of the field from the database. An error is
  23184. // returned if the mutation operation is not UpdateOne, or the query to the
  23185. // database failed.
  23186. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23187. switch name {
  23188. case msg.FieldCreatedAt:
  23189. return m.OldCreatedAt(ctx)
  23190. case msg.FieldUpdatedAt:
  23191. return m.OldUpdatedAt(ctx)
  23192. case msg.FieldDeletedAt:
  23193. return m.OldDeletedAt(ctx)
  23194. case msg.FieldStatus:
  23195. return m.OldStatus(ctx)
  23196. case msg.FieldFromwxid:
  23197. return m.OldFromwxid(ctx)
  23198. case msg.FieldToid:
  23199. return m.OldToid(ctx)
  23200. case msg.FieldMsgtype:
  23201. return m.OldMsgtype(ctx)
  23202. case msg.FieldMsg:
  23203. return m.OldMsg(ctx)
  23204. case msg.FieldBatchNo:
  23205. return m.OldBatchNo(ctx)
  23206. case msg.FieldCc:
  23207. return m.OldCc(ctx)
  23208. case msg.FieldPhone:
  23209. return m.OldPhone(ctx)
  23210. }
  23211. return nil, fmt.Errorf("unknown Msg field %s", name)
  23212. }
  23213. // SetField sets the value of a field with the given name. It returns an error if
  23214. // the field is not defined in the schema, or if the type mismatched the field
  23215. // type.
  23216. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  23217. switch name {
  23218. case msg.FieldCreatedAt:
  23219. v, ok := value.(time.Time)
  23220. if !ok {
  23221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23222. }
  23223. m.SetCreatedAt(v)
  23224. return nil
  23225. case msg.FieldUpdatedAt:
  23226. v, ok := value.(time.Time)
  23227. if !ok {
  23228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23229. }
  23230. m.SetUpdatedAt(v)
  23231. return nil
  23232. case msg.FieldDeletedAt:
  23233. v, ok := value.(time.Time)
  23234. if !ok {
  23235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23236. }
  23237. m.SetDeletedAt(v)
  23238. return nil
  23239. case msg.FieldStatus:
  23240. v, ok := value.(uint8)
  23241. if !ok {
  23242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23243. }
  23244. m.SetStatus(v)
  23245. return nil
  23246. case msg.FieldFromwxid:
  23247. v, ok := value.(string)
  23248. if !ok {
  23249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23250. }
  23251. m.SetFromwxid(v)
  23252. return nil
  23253. case msg.FieldToid:
  23254. v, ok := value.(string)
  23255. if !ok {
  23256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23257. }
  23258. m.SetToid(v)
  23259. return nil
  23260. case msg.FieldMsgtype:
  23261. v, ok := value.(int32)
  23262. if !ok {
  23263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23264. }
  23265. m.SetMsgtype(v)
  23266. return nil
  23267. case msg.FieldMsg:
  23268. v, ok := value.(string)
  23269. if !ok {
  23270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23271. }
  23272. m.SetMsg(v)
  23273. return nil
  23274. case msg.FieldBatchNo:
  23275. v, ok := value.(string)
  23276. if !ok {
  23277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23278. }
  23279. m.SetBatchNo(v)
  23280. return nil
  23281. case msg.FieldCc:
  23282. v, ok := value.(string)
  23283. if !ok {
  23284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23285. }
  23286. m.SetCc(v)
  23287. return nil
  23288. case msg.FieldPhone:
  23289. v, ok := value.(string)
  23290. if !ok {
  23291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23292. }
  23293. m.SetPhone(v)
  23294. return nil
  23295. }
  23296. return fmt.Errorf("unknown Msg field %s", name)
  23297. }
  23298. // AddedFields returns all numeric fields that were incremented/decremented during
  23299. // this mutation.
  23300. func (m *MsgMutation) AddedFields() []string {
  23301. var fields []string
  23302. if m.addstatus != nil {
  23303. fields = append(fields, msg.FieldStatus)
  23304. }
  23305. if m.addmsgtype != nil {
  23306. fields = append(fields, msg.FieldMsgtype)
  23307. }
  23308. return fields
  23309. }
  23310. // AddedField returns the numeric value that was incremented/decremented on a field
  23311. // with the given name. The second boolean return value indicates that this field
  23312. // was not set, or was not defined in the schema.
  23313. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  23314. switch name {
  23315. case msg.FieldStatus:
  23316. return m.AddedStatus()
  23317. case msg.FieldMsgtype:
  23318. return m.AddedMsgtype()
  23319. }
  23320. return nil, false
  23321. }
  23322. // AddField adds the value to the field with the given name. It returns an error if
  23323. // the field is not defined in the schema, or if the type mismatched the field
  23324. // type.
  23325. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  23326. switch name {
  23327. case msg.FieldStatus:
  23328. v, ok := value.(int8)
  23329. if !ok {
  23330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23331. }
  23332. m.AddStatus(v)
  23333. return nil
  23334. case msg.FieldMsgtype:
  23335. v, ok := value.(int32)
  23336. if !ok {
  23337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23338. }
  23339. m.AddMsgtype(v)
  23340. return nil
  23341. }
  23342. return fmt.Errorf("unknown Msg numeric field %s", name)
  23343. }
  23344. // ClearedFields returns all nullable fields that were cleared during this
  23345. // mutation.
  23346. func (m *MsgMutation) ClearedFields() []string {
  23347. var fields []string
  23348. if m.FieldCleared(msg.FieldDeletedAt) {
  23349. fields = append(fields, msg.FieldDeletedAt)
  23350. }
  23351. if m.FieldCleared(msg.FieldStatus) {
  23352. fields = append(fields, msg.FieldStatus)
  23353. }
  23354. if m.FieldCleared(msg.FieldFromwxid) {
  23355. fields = append(fields, msg.FieldFromwxid)
  23356. }
  23357. if m.FieldCleared(msg.FieldToid) {
  23358. fields = append(fields, msg.FieldToid)
  23359. }
  23360. if m.FieldCleared(msg.FieldMsgtype) {
  23361. fields = append(fields, msg.FieldMsgtype)
  23362. }
  23363. if m.FieldCleared(msg.FieldMsg) {
  23364. fields = append(fields, msg.FieldMsg)
  23365. }
  23366. if m.FieldCleared(msg.FieldBatchNo) {
  23367. fields = append(fields, msg.FieldBatchNo)
  23368. }
  23369. return fields
  23370. }
  23371. // FieldCleared returns a boolean indicating if a field with the given name was
  23372. // cleared in this mutation.
  23373. func (m *MsgMutation) FieldCleared(name string) bool {
  23374. _, ok := m.clearedFields[name]
  23375. return ok
  23376. }
  23377. // ClearField clears the value of the field with the given name. It returns an
  23378. // error if the field is not defined in the schema.
  23379. func (m *MsgMutation) ClearField(name string) error {
  23380. switch name {
  23381. case msg.FieldDeletedAt:
  23382. m.ClearDeletedAt()
  23383. return nil
  23384. case msg.FieldStatus:
  23385. m.ClearStatus()
  23386. return nil
  23387. case msg.FieldFromwxid:
  23388. m.ClearFromwxid()
  23389. return nil
  23390. case msg.FieldToid:
  23391. m.ClearToid()
  23392. return nil
  23393. case msg.FieldMsgtype:
  23394. m.ClearMsgtype()
  23395. return nil
  23396. case msg.FieldMsg:
  23397. m.ClearMsg()
  23398. return nil
  23399. case msg.FieldBatchNo:
  23400. m.ClearBatchNo()
  23401. return nil
  23402. }
  23403. return fmt.Errorf("unknown Msg nullable field %s", name)
  23404. }
  23405. // ResetField resets all changes in the mutation for the field with the given name.
  23406. // It returns an error if the field is not defined in the schema.
  23407. func (m *MsgMutation) ResetField(name string) error {
  23408. switch name {
  23409. case msg.FieldCreatedAt:
  23410. m.ResetCreatedAt()
  23411. return nil
  23412. case msg.FieldUpdatedAt:
  23413. m.ResetUpdatedAt()
  23414. return nil
  23415. case msg.FieldDeletedAt:
  23416. m.ResetDeletedAt()
  23417. return nil
  23418. case msg.FieldStatus:
  23419. m.ResetStatus()
  23420. return nil
  23421. case msg.FieldFromwxid:
  23422. m.ResetFromwxid()
  23423. return nil
  23424. case msg.FieldToid:
  23425. m.ResetToid()
  23426. return nil
  23427. case msg.FieldMsgtype:
  23428. m.ResetMsgtype()
  23429. return nil
  23430. case msg.FieldMsg:
  23431. m.ResetMsg()
  23432. return nil
  23433. case msg.FieldBatchNo:
  23434. m.ResetBatchNo()
  23435. return nil
  23436. case msg.FieldCc:
  23437. m.ResetCc()
  23438. return nil
  23439. case msg.FieldPhone:
  23440. m.ResetPhone()
  23441. return nil
  23442. }
  23443. return fmt.Errorf("unknown Msg field %s", name)
  23444. }
  23445. // AddedEdges returns all edge names that were set/added in this mutation.
  23446. func (m *MsgMutation) AddedEdges() []string {
  23447. edges := make([]string, 0, 0)
  23448. return edges
  23449. }
  23450. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23451. // name in this mutation.
  23452. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  23453. return nil
  23454. }
  23455. // RemovedEdges returns all edge names that were removed in this mutation.
  23456. func (m *MsgMutation) RemovedEdges() []string {
  23457. edges := make([]string, 0, 0)
  23458. return edges
  23459. }
  23460. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23461. // the given name in this mutation.
  23462. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  23463. return nil
  23464. }
  23465. // ClearedEdges returns all edge names that were cleared in this mutation.
  23466. func (m *MsgMutation) ClearedEdges() []string {
  23467. edges := make([]string, 0, 0)
  23468. return edges
  23469. }
  23470. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23471. // was cleared in this mutation.
  23472. func (m *MsgMutation) EdgeCleared(name string) bool {
  23473. return false
  23474. }
  23475. // ClearEdge clears the value of the edge with the given name. It returns an error
  23476. // if that edge is not defined in the schema.
  23477. func (m *MsgMutation) ClearEdge(name string) error {
  23478. return fmt.Errorf("unknown Msg unique edge %s", name)
  23479. }
  23480. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23481. // It returns an error if the edge is not defined in the schema.
  23482. func (m *MsgMutation) ResetEdge(name string) error {
  23483. return fmt.Errorf("unknown Msg edge %s", name)
  23484. }
  23485. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  23486. type PayRechargeMutation struct {
  23487. config
  23488. op Op
  23489. typ string
  23490. id *uint64
  23491. created_at *time.Time
  23492. updated_at *time.Time
  23493. deleted_at *time.Time
  23494. user_id *string
  23495. number *float32
  23496. addnumber *float32
  23497. status *int
  23498. addstatus *int
  23499. money *float32
  23500. addmoney *float32
  23501. out_trade_no *string
  23502. organization_id *uint64
  23503. addorganization_id *int64
  23504. clearedFields map[string]struct{}
  23505. done bool
  23506. oldValue func(context.Context) (*PayRecharge, error)
  23507. predicates []predicate.PayRecharge
  23508. }
  23509. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  23510. // payrechargeOption allows management of the mutation configuration using functional options.
  23511. type payrechargeOption func(*PayRechargeMutation)
  23512. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  23513. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  23514. m := &PayRechargeMutation{
  23515. config: c,
  23516. op: op,
  23517. typ: TypePayRecharge,
  23518. clearedFields: make(map[string]struct{}),
  23519. }
  23520. for _, opt := range opts {
  23521. opt(m)
  23522. }
  23523. return m
  23524. }
  23525. // withPayRechargeID sets the ID field of the mutation.
  23526. func withPayRechargeID(id uint64) payrechargeOption {
  23527. return func(m *PayRechargeMutation) {
  23528. var (
  23529. err error
  23530. once sync.Once
  23531. value *PayRecharge
  23532. )
  23533. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  23534. once.Do(func() {
  23535. if m.done {
  23536. err = errors.New("querying old values post mutation is not allowed")
  23537. } else {
  23538. value, err = m.Client().PayRecharge.Get(ctx, id)
  23539. }
  23540. })
  23541. return value, err
  23542. }
  23543. m.id = &id
  23544. }
  23545. }
  23546. // withPayRecharge sets the old PayRecharge of the mutation.
  23547. func withPayRecharge(node *PayRecharge) payrechargeOption {
  23548. return func(m *PayRechargeMutation) {
  23549. m.oldValue = func(context.Context) (*PayRecharge, error) {
  23550. return node, nil
  23551. }
  23552. m.id = &node.ID
  23553. }
  23554. }
  23555. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23556. // executed in a transaction (ent.Tx), a transactional client is returned.
  23557. func (m PayRechargeMutation) Client() *Client {
  23558. client := &Client{config: m.config}
  23559. client.init()
  23560. return client
  23561. }
  23562. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23563. // it returns an error otherwise.
  23564. func (m PayRechargeMutation) Tx() (*Tx, error) {
  23565. if _, ok := m.driver.(*txDriver); !ok {
  23566. return nil, errors.New("ent: mutation is not running in a transaction")
  23567. }
  23568. tx := &Tx{config: m.config}
  23569. tx.init()
  23570. return tx, nil
  23571. }
  23572. // SetID sets the value of the id field. Note that this
  23573. // operation is only accepted on creation of PayRecharge entities.
  23574. func (m *PayRechargeMutation) SetID(id uint64) {
  23575. m.id = &id
  23576. }
  23577. // ID returns the ID value in the mutation. Note that the ID is only available
  23578. // if it was provided to the builder or after it was returned from the database.
  23579. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  23580. if m.id == nil {
  23581. return
  23582. }
  23583. return *m.id, true
  23584. }
  23585. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23586. // That means, if the mutation is applied within a transaction with an isolation level such
  23587. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23588. // or updated by the mutation.
  23589. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23590. switch {
  23591. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23592. id, exists := m.ID()
  23593. if exists {
  23594. return []uint64{id}, nil
  23595. }
  23596. fallthrough
  23597. case m.op.Is(OpUpdate | OpDelete):
  23598. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  23599. default:
  23600. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23601. }
  23602. }
  23603. // SetCreatedAt sets the "created_at" field.
  23604. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  23605. m.created_at = &t
  23606. }
  23607. // CreatedAt returns the value of the "created_at" field in the mutation.
  23608. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  23609. v := m.created_at
  23610. if v == nil {
  23611. return
  23612. }
  23613. return *v, true
  23614. }
  23615. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  23616. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23618. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23619. if !m.op.Is(OpUpdateOne) {
  23620. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23621. }
  23622. if m.id == nil || m.oldValue == nil {
  23623. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23624. }
  23625. oldValue, err := m.oldValue(ctx)
  23626. if err != nil {
  23627. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23628. }
  23629. return oldValue.CreatedAt, nil
  23630. }
  23631. // ResetCreatedAt resets all changes to the "created_at" field.
  23632. func (m *PayRechargeMutation) ResetCreatedAt() {
  23633. m.created_at = nil
  23634. }
  23635. // SetUpdatedAt sets the "updated_at" field.
  23636. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  23637. m.updated_at = &t
  23638. }
  23639. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23640. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  23641. v := m.updated_at
  23642. if v == nil {
  23643. return
  23644. }
  23645. return *v, true
  23646. }
  23647. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  23648. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23650. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23651. if !m.op.Is(OpUpdateOne) {
  23652. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23653. }
  23654. if m.id == nil || m.oldValue == nil {
  23655. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23656. }
  23657. oldValue, err := m.oldValue(ctx)
  23658. if err != nil {
  23659. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23660. }
  23661. return oldValue.UpdatedAt, nil
  23662. }
  23663. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23664. func (m *PayRechargeMutation) ResetUpdatedAt() {
  23665. m.updated_at = nil
  23666. }
  23667. // SetDeletedAt sets the "deleted_at" field.
  23668. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  23669. m.deleted_at = &t
  23670. }
  23671. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23672. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  23673. v := m.deleted_at
  23674. if v == nil {
  23675. return
  23676. }
  23677. return *v, true
  23678. }
  23679. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  23680. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23682. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23683. if !m.op.Is(OpUpdateOne) {
  23684. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23685. }
  23686. if m.id == nil || m.oldValue == nil {
  23687. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23688. }
  23689. oldValue, err := m.oldValue(ctx)
  23690. if err != nil {
  23691. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23692. }
  23693. return oldValue.DeletedAt, nil
  23694. }
  23695. // ClearDeletedAt clears the value of the "deleted_at" field.
  23696. func (m *PayRechargeMutation) ClearDeletedAt() {
  23697. m.deleted_at = nil
  23698. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  23699. }
  23700. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23701. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  23702. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  23703. return ok
  23704. }
  23705. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23706. func (m *PayRechargeMutation) ResetDeletedAt() {
  23707. m.deleted_at = nil
  23708. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  23709. }
  23710. // SetUserID sets the "user_id" field.
  23711. func (m *PayRechargeMutation) SetUserID(s string) {
  23712. m.user_id = &s
  23713. }
  23714. // UserID returns the value of the "user_id" field in the mutation.
  23715. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  23716. v := m.user_id
  23717. if v == nil {
  23718. return
  23719. }
  23720. return *v, true
  23721. }
  23722. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  23723. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23725. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  23726. if !m.op.Is(OpUpdateOne) {
  23727. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23728. }
  23729. if m.id == nil || m.oldValue == nil {
  23730. return v, errors.New("OldUserID requires an ID field in the mutation")
  23731. }
  23732. oldValue, err := m.oldValue(ctx)
  23733. if err != nil {
  23734. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23735. }
  23736. return oldValue.UserID, nil
  23737. }
  23738. // ResetUserID resets all changes to the "user_id" field.
  23739. func (m *PayRechargeMutation) ResetUserID() {
  23740. m.user_id = nil
  23741. }
  23742. // SetNumber sets the "number" field.
  23743. func (m *PayRechargeMutation) SetNumber(f float32) {
  23744. m.number = &f
  23745. m.addnumber = nil
  23746. }
  23747. // Number returns the value of the "number" field in the mutation.
  23748. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  23749. v := m.number
  23750. if v == nil {
  23751. return
  23752. }
  23753. return *v, true
  23754. }
  23755. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  23756. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23758. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  23759. if !m.op.Is(OpUpdateOne) {
  23760. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  23761. }
  23762. if m.id == nil || m.oldValue == nil {
  23763. return v, errors.New("OldNumber requires an ID field in the mutation")
  23764. }
  23765. oldValue, err := m.oldValue(ctx)
  23766. if err != nil {
  23767. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  23768. }
  23769. return oldValue.Number, nil
  23770. }
  23771. // AddNumber adds f to the "number" field.
  23772. func (m *PayRechargeMutation) AddNumber(f float32) {
  23773. if m.addnumber != nil {
  23774. *m.addnumber += f
  23775. } else {
  23776. m.addnumber = &f
  23777. }
  23778. }
  23779. // AddedNumber returns the value that was added to the "number" field in this mutation.
  23780. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  23781. v := m.addnumber
  23782. if v == nil {
  23783. return
  23784. }
  23785. return *v, true
  23786. }
  23787. // ResetNumber resets all changes to the "number" field.
  23788. func (m *PayRechargeMutation) ResetNumber() {
  23789. m.number = nil
  23790. m.addnumber = nil
  23791. }
  23792. // SetStatus sets the "status" field.
  23793. func (m *PayRechargeMutation) SetStatus(i int) {
  23794. m.status = &i
  23795. m.addstatus = nil
  23796. }
  23797. // Status returns the value of the "status" field in the mutation.
  23798. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  23799. v := m.status
  23800. if v == nil {
  23801. return
  23802. }
  23803. return *v, true
  23804. }
  23805. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  23806. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23808. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  23809. if !m.op.Is(OpUpdateOne) {
  23810. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23811. }
  23812. if m.id == nil || m.oldValue == nil {
  23813. return v, errors.New("OldStatus requires an ID field in the mutation")
  23814. }
  23815. oldValue, err := m.oldValue(ctx)
  23816. if err != nil {
  23817. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23818. }
  23819. return oldValue.Status, nil
  23820. }
  23821. // AddStatus adds i to the "status" field.
  23822. func (m *PayRechargeMutation) AddStatus(i int) {
  23823. if m.addstatus != nil {
  23824. *m.addstatus += i
  23825. } else {
  23826. m.addstatus = &i
  23827. }
  23828. }
  23829. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23830. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  23831. v := m.addstatus
  23832. if v == nil {
  23833. return
  23834. }
  23835. return *v, true
  23836. }
  23837. // ClearStatus clears the value of the "status" field.
  23838. func (m *PayRechargeMutation) ClearStatus() {
  23839. m.status = nil
  23840. m.addstatus = nil
  23841. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  23842. }
  23843. // StatusCleared returns if the "status" field was cleared in this mutation.
  23844. func (m *PayRechargeMutation) StatusCleared() bool {
  23845. _, ok := m.clearedFields[payrecharge.FieldStatus]
  23846. return ok
  23847. }
  23848. // ResetStatus resets all changes to the "status" field.
  23849. func (m *PayRechargeMutation) ResetStatus() {
  23850. m.status = nil
  23851. m.addstatus = nil
  23852. delete(m.clearedFields, payrecharge.FieldStatus)
  23853. }
  23854. // SetMoney sets the "money" field.
  23855. func (m *PayRechargeMutation) SetMoney(f float32) {
  23856. m.money = &f
  23857. m.addmoney = nil
  23858. }
  23859. // Money returns the value of the "money" field in the mutation.
  23860. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  23861. v := m.money
  23862. if v == nil {
  23863. return
  23864. }
  23865. return *v, true
  23866. }
  23867. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  23868. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23870. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  23871. if !m.op.Is(OpUpdateOne) {
  23872. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  23873. }
  23874. if m.id == nil || m.oldValue == nil {
  23875. return v, errors.New("OldMoney requires an ID field in the mutation")
  23876. }
  23877. oldValue, err := m.oldValue(ctx)
  23878. if err != nil {
  23879. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  23880. }
  23881. return oldValue.Money, nil
  23882. }
  23883. // AddMoney adds f to the "money" field.
  23884. func (m *PayRechargeMutation) AddMoney(f float32) {
  23885. if m.addmoney != nil {
  23886. *m.addmoney += f
  23887. } else {
  23888. m.addmoney = &f
  23889. }
  23890. }
  23891. // AddedMoney returns the value that was added to the "money" field in this mutation.
  23892. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  23893. v := m.addmoney
  23894. if v == nil {
  23895. return
  23896. }
  23897. return *v, true
  23898. }
  23899. // ClearMoney clears the value of the "money" field.
  23900. func (m *PayRechargeMutation) ClearMoney() {
  23901. m.money = nil
  23902. m.addmoney = nil
  23903. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  23904. }
  23905. // MoneyCleared returns if the "money" field was cleared in this mutation.
  23906. func (m *PayRechargeMutation) MoneyCleared() bool {
  23907. _, ok := m.clearedFields[payrecharge.FieldMoney]
  23908. return ok
  23909. }
  23910. // ResetMoney resets all changes to the "money" field.
  23911. func (m *PayRechargeMutation) ResetMoney() {
  23912. m.money = nil
  23913. m.addmoney = nil
  23914. delete(m.clearedFields, payrecharge.FieldMoney)
  23915. }
  23916. // SetOutTradeNo sets the "out_trade_no" field.
  23917. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  23918. m.out_trade_no = &s
  23919. }
  23920. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  23921. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  23922. v := m.out_trade_no
  23923. if v == nil {
  23924. return
  23925. }
  23926. return *v, true
  23927. }
  23928. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  23929. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23931. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  23932. if !m.op.Is(OpUpdateOne) {
  23933. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  23934. }
  23935. if m.id == nil || m.oldValue == nil {
  23936. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  23937. }
  23938. oldValue, err := m.oldValue(ctx)
  23939. if err != nil {
  23940. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  23941. }
  23942. return oldValue.OutTradeNo, nil
  23943. }
  23944. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  23945. func (m *PayRechargeMutation) ClearOutTradeNo() {
  23946. m.out_trade_no = nil
  23947. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  23948. }
  23949. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  23950. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  23951. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  23952. return ok
  23953. }
  23954. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  23955. func (m *PayRechargeMutation) ResetOutTradeNo() {
  23956. m.out_trade_no = nil
  23957. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  23958. }
  23959. // SetOrganizationID sets the "organization_id" field.
  23960. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  23961. m.organization_id = &u
  23962. m.addorganization_id = nil
  23963. }
  23964. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23965. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  23966. v := m.organization_id
  23967. if v == nil {
  23968. return
  23969. }
  23970. return *v, true
  23971. }
  23972. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  23973. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23975. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23976. if !m.op.Is(OpUpdateOne) {
  23977. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23978. }
  23979. if m.id == nil || m.oldValue == nil {
  23980. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23981. }
  23982. oldValue, err := m.oldValue(ctx)
  23983. if err != nil {
  23984. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23985. }
  23986. return oldValue.OrganizationID, nil
  23987. }
  23988. // AddOrganizationID adds u to the "organization_id" field.
  23989. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  23990. if m.addorganization_id != nil {
  23991. *m.addorganization_id += u
  23992. } else {
  23993. m.addorganization_id = &u
  23994. }
  23995. }
  23996. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23997. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  23998. v := m.addorganization_id
  23999. if v == nil {
  24000. return
  24001. }
  24002. return *v, true
  24003. }
  24004. // ResetOrganizationID resets all changes to the "organization_id" field.
  24005. func (m *PayRechargeMutation) ResetOrganizationID() {
  24006. m.organization_id = nil
  24007. m.addorganization_id = nil
  24008. }
  24009. // Where appends a list predicates to the PayRechargeMutation builder.
  24010. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  24011. m.predicates = append(m.predicates, ps...)
  24012. }
  24013. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  24014. // users can use type-assertion to append predicates that do not depend on any generated package.
  24015. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  24016. p := make([]predicate.PayRecharge, len(ps))
  24017. for i := range ps {
  24018. p[i] = ps[i]
  24019. }
  24020. m.Where(p...)
  24021. }
  24022. // Op returns the operation name.
  24023. func (m *PayRechargeMutation) Op() Op {
  24024. return m.op
  24025. }
  24026. // SetOp allows setting the mutation operation.
  24027. func (m *PayRechargeMutation) SetOp(op Op) {
  24028. m.op = op
  24029. }
  24030. // Type returns the node type of this mutation (PayRecharge).
  24031. func (m *PayRechargeMutation) Type() string {
  24032. return m.typ
  24033. }
  24034. // Fields returns all fields that were changed during this mutation. Note that in
  24035. // order to get all numeric fields that were incremented/decremented, call
  24036. // AddedFields().
  24037. func (m *PayRechargeMutation) Fields() []string {
  24038. fields := make([]string, 0, 9)
  24039. if m.created_at != nil {
  24040. fields = append(fields, payrecharge.FieldCreatedAt)
  24041. }
  24042. if m.updated_at != nil {
  24043. fields = append(fields, payrecharge.FieldUpdatedAt)
  24044. }
  24045. if m.deleted_at != nil {
  24046. fields = append(fields, payrecharge.FieldDeletedAt)
  24047. }
  24048. if m.user_id != nil {
  24049. fields = append(fields, payrecharge.FieldUserID)
  24050. }
  24051. if m.number != nil {
  24052. fields = append(fields, payrecharge.FieldNumber)
  24053. }
  24054. if m.status != nil {
  24055. fields = append(fields, payrecharge.FieldStatus)
  24056. }
  24057. if m.money != nil {
  24058. fields = append(fields, payrecharge.FieldMoney)
  24059. }
  24060. if m.out_trade_no != nil {
  24061. fields = append(fields, payrecharge.FieldOutTradeNo)
  24062. }
  24063. if m.organization_id != nil {
  24064. fields = append(fields, payrecharge.FieldOrganizationID)
  24065. }
  24066. return fields
  24067. }
  24068. // Field returns the value of a field with the given name. The second boolean
  24069. // return value indicates that this field was not set, or was not defined in the
  24070. // schema.
  24071. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  24072. switch name {
  24073. case payrecharge.FieldCreatedAt:
  24074. return m.CreatedAt()
  24075. case payrecharge.FieldUpdatedAt:
  24076. return m.UpdatedAt()
  24077. case payrecharge.FieldDeletedAt:
  24078. return m.DeletedAt()
  24079. case payrecharge.FieldUserID:
  24080. return m.UserID()
  24081. case payrecharge.FieldNumber:
  24082. return m.Number()
  24083. case payrecharge.FieldStatus:
  24084. return m.Status()
  24085. case payrecharge.FieldMoney:
  24086. return m.Money()
  24087. case payrecharge.FieldOutTradeNo:
  24088. return m.OutTradeNo()
  24089. case payrecharge.FieldOrganizationID:
  24090. return m.OrganizationID()
  24091. }
  24092. return nil, false
  24093. }
  24094. // OldField returns the old value of the field from the database. An error is
  24095. // returned if the mutation operation is not UpdateOne, or the query to the
  24096. // database failed.
  24097. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24098. switch name {
  24099. case payrecharge.FieldCreatedAt:
  24100. return m.OldCreatedAt(ctx)
  24101. case payrecharge.FieldUpdatedAt:
  24102. return m.OldUpdatedAt(ctx)
  24103. case payrecharge.FieldDeletedAt:
  24104. return m.OldDeletedAt(ctx)
  24105. case payrecharge.FieldUserID:
  24106. return m.OldUserID(ctx)
  24107. case payrecharge.FieldNumber:
  24108. return m.OldNumber(ctx)
  24109. case payrecharge.FieldStatus:
  24110. return m.OldStatus(ctx)
  24111. case payrecharge.FieldMoney:
  24112. return m.OldMoney(ctx)
  24113. case payrecharge.FieldOutTradeNo:
  24114. return m.OldOutTradeNo(ctx)
  24115. case payrecharge.FieldOrganizationID:
  24116. return m.OldOrganizationID(ctx)
  24117. }
  24118. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  24119. }
  24120. // SetField sets the value of a field with the given name. It returns an error if
  24121. // the field is not defined in the schema, or if the type mismatched the field
  24122. // type.
  24123. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  24124. switch name {
  24125. case payrecharge.FieldCreatedAt:
  24126. v, ok := value.(time.Time)
  24127. if !ok {
  24128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24129. }
  24130. m.SetCreatedAt(v)
  24131. return nil
  24132. case payrecharge.FieldUpdatedAt:
  24133. v, ok := value.(time.Time)
  24134. if !ok {
  24135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24136. }
  24137. m.SetUpdatedAt(v)
  24138. return nil
  24139. case payrecharge.FieldDeletedAt:
  24140. v, ok := value.(time.Time)
  24141. if !ok {
  24142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24143. }
  24144. m.SetDeletedAt(v)
  24145. return nil
  24146. case payrecharge.FieldUserID:
  24147. v, ok := value.(string)
  24148. if !ok {
  24149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24150. }
  24151. m.SetUserID(v)
  24152. return nil
  24153. case payrecharge.FieldNumber:
  24154. v, ok := value.(float32)
  24155. if !ok {
  24156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24157. }
  24158. m.SetNumber(v)
  24159. return nil
  24160. case payrecharge.FieldStatus:
  24161. v, ok := value.(int)
  24162. if !ok {
  24163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24164. }
  24165. m.SetStatus(v)
  24166. return nil
  24167. case payrecharge.FieldMoney:
  24168. v, ok := value.(float32)
  24169. if !ok {
  24170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24171. }
  24172. m.SetMoney(v)
  24173. return nil
  24174. case payrecharge.FieldOutTradeNo:
  24175. v, ok := value.(string)
  24176. if !ok {
  24177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24178. }
  24179. m.SetOutTradeNo(v)
  24180. return nil
  24181. case payrecharge.FieldOrganizationID:
  24182. v, ok := value.(uint64)
  24183. if !ok {
  24184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24185. }
  24186. m.SetOrganizationID(v)
  24187. return nil
  24188. }
  24189. return fmt.Errorf("unknown PayRecharge field %s", name)
  24190. }
  24191. // AddedFields returns all numeric fields that were incremented/decremented during
  24192. // this mutation.
  24193. func (m *PayRechargeMutation) AddedFields() []string {
  24194. var fields []string
  24195. if m.addnumber != nil {
  24196. fields = append(fields, payrecharge.FieldNumber)
  24197. }
  24198. if m.addstatus != nil {
  24199. fields = append(fields, payrecharge.FieldStatus)
  24200. }
  24201. if m.addmoney != nil {
  24202. fields = append(fields, payrecharge.FieldMoney)
  24203. }
  24204. if m.addorganization_id != nil {
  24205. fields = append(fields, payrecharge.FieldOrganizationID)
  24206. }
  24207. return fields
  24208. }
  24209. // AddedField returns the numeric value that was incremented/decremented on a field
  24210. // with the given name. The second boolean return value indicates that this field
  24211. // was not set, or was not defined in the schema.
  24212. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  24213. switch name {
  24214. case payrecharge.FieldNumber:
  24215. return m.AddedNumber()
  24216. case payrecharge.FieldStatus:
  24217. return m.AddedStatus()
  24218. case payrecharge.FieldMoney:
  24219. return m.AddedMoney()
  24220. case payrecharge.FieldOrganizationID:
  24221. return m.AddedOrganizationID()
  24222. }
  24223. return nil, false
  24224. }
  24225. // AddField adds the value to the field with the given name. It returns an error if
  24226. // the field is not defined in the schema, or if the type mismatched the field
  24227. // type.
  24228. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  24229. switch name {
  24230. case payrecharge.FieldNumber:
  24231. v, ok := value.(float32)
  24232. if !ok {
  24233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24234. }
  24235. m.AddNumber(v)
  24236. return nil
  24237. case payrecharge.FieldStatus:
  24238. v, ok := value.(int)
  24239. if !ok {
  24240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24241. }
  24242. m.AddStatus(v)
  24243. return nil
  24244. case payrecharge.FieldMoney:
  24245. v, ok := value.(float32)
  24246. if !ok {
  24247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24248. }
  24249. m.AddMoney(v)
  24250. return nil
  24251. case payrecharge.FieldOrganizationID:
  24252. v, ok := value.(int64)
  24253. if !ok {
  24254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24255. }
  24256. m.AddOrganizationID(v)
  24257. return nil
  24258. }
  24259. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  24260. }
  24261. // ClearedFields returns all nullable fields that were cleared during this
  24262. // mutation.
  24263. func (m *PayRechargeMutation) ClearedFields() []string {
  24264. var fields []string
  24265. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  24266. fields = append(fields, payrecharge.FieldDeletedAt)
  24267. }
  24268. if m.FieldCleared(payrecharge.FieldStatus) {
  24269. fields = append(fields, payrecharge.FieldStatus)
  24270. }
  24271. if m.FieldCleared(payrecharge.FieldMoney) {
  24272. fields = append(fields, payrecharge.FieldMoney)
  24273. }
  24274. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  24275. fields = append(fields, payrecharge.FieldOutTradeNo)
  24276. }
  24277. return fields
  24278. }
  24279. // FieldCleared returns a boolean indicating if a field with the given name was
  24280. // cleared in this mutation.
  24281. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  24282. _, ok := m.clearedFields[name]
  24283. return ok
  24284. }
  24285. // ClearField clears the value of the field with the given name. It returns an
  24286. // error if the field is not defined in the schema.
  24287. func (m *PayRechargeMutation) ClearField(name string) error {
  24288. switch name {
  24289. case payrecharge.FieldDeletedAt:
  24290. m.ClearDeletedAt()
  24291. return nil
  24292. case payrecharge.FieldStatus:
  24293. m.ClearStatus()
  24294. return nil
  24295. case payrecharge.FieldMoney:
  24296. m.ClearMoney()
  24297. return nil
  24298. case payrecharge.FieldOutTradeNo:
  24299. m.ClearOutTradeNo()
  24300. return nil
  24301. }
  24302. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  24303. }
  24304. // ResetField resets all changes in the mutation for the field with the given name.
  24305. // It returns an error if the field is not defined in the schema.
  24306. func (m *PayRechargeMutation) ResetField(name string) error {
  24307. switch name {
  24308. case payrecharge.FieldCreatedAt:
  24309. m.ResetCreatedAt()
  24310. return nil
  24311. case payrecharge.FieldUpdatedAt:
  24312. m.ResetUpdatedAt()
  24313. return nil
  24314. case payrecharge.FieldDeletedAt:
  24315. m.ResetDeletedAt()
  24316. return nil
  24317. case payrecharge.FieldUserID:
  24318. m.ResetUserID()
  24319. return nil
  24320. case payrecharge.FieldNumber:
  24321. m.ResetNumber()
  24322. return nil
  24323. case payrecharge.FieldStatus:
  24324. m.ResetStatus()
  24325. return nil
  24326. case payrecharge.FieldMoney:
  24327. m.ResetMoney()
  24328. return nil
  24329. case payrecharge.FieldOutTradeNo:
  24330. m.ResetOutTradeNo()
  24331. return nil
  24332. case payrecharge.FieldOrganizationID:
  24333. m.ResetOrganizationID()
  24334. return nil
  24335. }
  24336. return fmt.Errorf("unknown PayRecharge field %s", name)
  24337. }
  24338. // AddedEdges returns all edge names that were set/added in this mutation.
  24339. func (m *PayRechargeMutation) AddedEdges() []string {
  24340. edges := make([]string, 0, 0)
  24341. return edges
  24342. }
  24343. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24344. // name in this mutation.
  24345. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  24346. return nil
  24347. }
  24348. // RemovedEdges returns all edge names that were removed in this mutation.
  24349. func (m *PayRechargeMutation) RemovedEdges() []string {
  24350. edges := make([]string, 0, 0)
  24351. return edges
  24352. }
  24353. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24354. // the given name in this mutation.
  24355. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  24356. return nil
  24357. }
  24358. // ClearedEdges returns all edge names that were cleared in this mutation.
  24359. func (m *PayRechargeMutation) ClearedEdges() []string {
  24360. edges := make([]string, 0, 0)
  24361. return edges
  24362. }
  24363. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24364. // was cleared in this mutation.
  24365. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  24366. return false
  24367. }
  24368. // ClearEdge clears the value of the edge with the given name. It returns an error
  24369. // if that edge is not defined in the schema.
  24370. func (m *PayRechargeMutation) ClearEdge(name string) error {
  24371. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  24372. }
  24373. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24374. // It returns an error if the edge is not defined in the schema.
  24375. func (m *PayRechargeMutation) ResetEdge(name string) error {
  24376. return fmt.Errorf("unknown PayRecharge edge %s", name)
  24377. }
  24378. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  24379. type ServerMutation struct {
  24380. config
  24381. op Op
  24382. typ string
  24383. id *uint64
  24384. created_at *time.Time
  24385. updated_at *time.Time
  24386. status *uint8
  24387. addstatus *int8
  24388. deleted_at *time.Time
  24389. name *string
  24390. public_ip *string
  24391. private_ip *string
  24392. admin_port *string
  24393. clearedFields map[string]struct{}
  24394. wxs map[uint64]struct{}
  24395. removedwxs map[uint64]struct{}
  24396. clearedwxs bool
  24397. done bool
  24398. oldValue func(context.Context) (*Server, error)
  24399. predicates []predicate.Server
  24400. }
  24401. var _ ent.Mutation = (*ServerMutation)(nil)
  24402. // serverOption allows management of the mutation configuration using functional options.
  24403. type serverOption func(*ServerMutation)
  24404. // newServerMutation creates new mutation for the Server entity.
  24405. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  24406. m := &ServerMutation{
  24407. config: c,
  24408. op: op,
  24409. typ: TypeServer,
  24410. clearedFields: make(map[string]struct{}),
  24411. }
  24412. for _, opt := range opts {
  24413. opt(m)
  24414. }
  24415. return m
  24416. }
  24417. // withServerID sets the ID field of the mutation.
  24418. func withServerID(id uint64) serverOption {
  24419. return func(m *ServerMutation) {
  24420. var (
  24421. err error
  24422. once sync.Once
  24423. value *Server
  24424. )
  24425. m.oldValue = func(ctx context.Context) (*Server, error) {
  24426. once.Do(func() {
  24427. if m.done {
  24428. err = errors.New("querying old values post mutation is not allowed")
  24429. } else {
  24430. value, err = m.Client().Server.Get(ctx, id)
  24431. }
  24432. })
  24433. return value, err
  24434. }
  24435. m.id = &id
  24436. }
  24437. }
  24438. // withServer sets the old Server of the mutation.
  24439. func withServer(node *Server) serverOption {
  24440. return func(m *ServerMutation) {
  24441. m.oldValue = func(context.Context) (*Server, error) {
  24442. return node, nil
  24443. }
  24444. m.id = &node.ID
  24445. }
  24446. }
  24447. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24448. // executed in a transaction (ent.Tx), a transactional client is returned.
  24449. func (m ServerMutation) Client() *Client {
  24450. client := &Client{config: m.config}
  24451. client.init()
  24452. return client
  24453. }
  24454. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24455. // it returns an error otherwise.
  24456. func (m ServerMutation) Tx() (*Tx, error) {
  24457. if _, ok := m.driver.(*txDriver); !ok {
  24458. return nil, errors.New("ent: mutation is not running in a transaction")
  24459. }
  24460. tx := &Tx{config: m.config}
  24461. tx.init()
  24462. return tx, nil
  24463. }
  24464. // SetID sets the value of the id field. Note that this
  24465. // operation is only accepted on creation of Server entities.
  24466. func (m *ServerMutation) SetID(id uint64) {
  24467. m.id = &id
  24468. }
  24469. // ID returns the ID value in the mutation. Note that the ID is only available
  24470. // if it was provided to the builder or after it was returned from the database.
  24471. func (m *ServerMutation) ID() (id uint64, exists bool) {
  24472. if m.id == nil {
  24473. return
  24474. }
  24475. return *m.id, true
  24476. }
  24477. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24478. // That means, if the mutation is applied within a transaction with an isolation level such
  24479. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24480. // or updated by the mutation.
  24481. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  24482. switch {
  24483. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24484. id, exists := m.ID()
  24485. if exists {
  24486. return []uint64{id}, nil
  24487. }
  24488. fallthrough
  24489. case m.op.Is(OpUpdate | OpDelete):
  24490. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  24491. default:
  24492. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24493. }
  24494. }
  24495. // SetCreatedAt sets the "created_at" field.
  24496. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  24497. m.created_at = &t
  24498. }
  24499. // CreatedAt returns the value of the "created_at" field in the mutation.
  24500. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  24501. v := m.created_at
  24502. if v == nil {
  24503. return
  24504. }
  24505. return *v, true
  24506. }
  24507. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  24508. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24510. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24511. if !m.op.Is(OpUpdateOne) {
  24512. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24513. }
  24514. if m.id == nil || m.oldValue == nil {
  24515. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24516. }
  24517. oldValue, err := m.oldValue(ctx)
  24518. if err != nil {
  24519. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24520. }
  24521. return oldValue.CreatedAt, nil
  24522. }
  24523. // ResetCreatedAt resets all changes to the "created_at" field.
  24524. func (m *ServerMutation) ResetCreatedAt() {
  24525. m.created_at = nil
  24526. }
  24527. // SetUpdatedAt sets the "updated_at" field.
  24528. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  24529. m.updated_at = &t
  24530. }
  24531. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24532. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  24533. v := m.updated_at
  24534. if v == nil {
  24535. return
  24536. }
  24537. return *v, true
  24538. }
  24539. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  24540. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24542. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24543. if !m.op.Is(OpUpdateOne) {
  24544. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24545. }
  24546. if m.id == nil || m.oldValue == nil {
  24547. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24548. }
  24549. oldValue, err := m.oldValue(ctx)
  24550. if err != nil {
  24551. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24552. }
  24553. return oldValue.UpdatedAt, nil
  24554. }
  24555. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24556. func (m *ServerMutation) ResetUpdatedAt() {
  24557. m.updated_at = nil
  24558. }
  24559. // SetStatus sets the "status" field.
  24560. func (m *ServerMutation) SetStatus(u uint8) {
  24561. m.status = &u
  24562. m.addstatus = nil
  24563. }
  24564. // Status returns the value of the "status" field in the mutation.
  24565. func (m *ServerMutation) Status() (r uint8, exists bool) {
  24566. v := m.status
  24567. if v == nil {
  24568. return
  24569. }
  24570. return *v, true
  24571. }
  24572. // OldStatus returns the old "status" field's value of the Server entity.
  24573. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24575. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24576. if !m.op.Is(OpUpdateOne) {
  24577. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24578. }
  24579. if m.id == nil || m.oldValue == nil {
  24580. return v, errors.New("OldStatus requires an ID field in the mutation")
  24581. }
  24582. oldValue, err := m.oldValue(ctx)
  24583. if err != nil {
  24584. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24585. }
  24586. return oldValue.Status, nil
  24587. }
  24588. // AddStatus adds u to the "status" field.
  24589. func (m *ServerMutation) AddStatus(u int8) {
  24590. if m.addstatus != nil {
  24591. *m.addstatus += u
  24592. } else {
  24593. m.addstatus = &u
  24594. }
  24595. }
  24596. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24597. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  24598. v := m.addstatus
  24599. if v == nil {
  24600. return
  24601. }
  24602. return *v, true
  24603. }
  24604. // ClearStatus clears the value of the "status" field.
  24605. func (m *ServerMutation) ClearStatus() {
  24606. m.status = nil
  24607. m.addstatus = nil
  24608. m.clearedFields[server.FieldStatus] = struct{}{}
  24609. }
  24610. // StatusCleared returns if the "status" field was cleared in this mutation.
  24611. func (m *ServerMutation) StatusCleared() bool {
  24612. _, ok := m.clearedFields[server.FieldStatus]
  24613. return ok
  24614. }
  24615. // ResetStatus resets all changes to the "status" field.
  24616. func (m *ServerMutation) ResetStatus() {
  24617. m.status = nil
  24618. m.addstatus = nil
  24619. delete(m.clearedFields, server.FieldStatus)
  24620. }
  24621. // SetDeletedAt sets the "deleted_at" field.
  24622. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  24623. m.deleted_at = &t
  24624. }
  24625. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24626. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  24627. v := m.deleted_at
  24628. if v == nil {
  24629. return
  24630. }
  24631. return *v, true
  24632. }
  24633. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  24634. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24636. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24637. if !m.op.Is(OpUpdateOne) {
  24638. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24639. }
  24640. if m.id == nil || m.oldValue == nil {
  24641. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24642. }
  24643. oldValue, err := m.oldValue(ctx)
  24644. if err != nil {
  24645. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24646. }
  24647. return oldValue.DeletedAt, nil
  24648. }
  24649. // ClearDeletedAt clears the value of the "deleted_at" field.
  24650. func (m *ServerMutation) ClearDeletedAt() {
  24651. m.deleted_at = nil
  24652. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  24653. }
  24654. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24655. func (m *ServerMutation) DeletedAtCleared() bool {
  24656. _, ok := m.clearedFields[server.FieldDeletedAt]
  24657. return ok
  24658. }
  24659. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24660. func (m *ServerMutation) ResetDeletedAt() {
  24661. m.deleted_at = nil
  24662. delete(m.clearedFields, server.FieldDeletedAt)
  24663. }
  24664. // SetName sets the "name" field.
  24665. func (m *ServerMutation) SetName(s string) {
  24666. m.name = &s
  24667. }
  24668. // Name returns the value of the "name" field in the mutation.
  24669. func (m *ServerMutation) Name() (r string, exists bool) {
  24670. v := m.name
  24671. if v == nil {
  24672. return
  24673. }
  24674. return *v, true
  24675. }
  24676. // OldName returns the old "name" field's value of the Server entity.
  24677. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24679. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  24680. if !m.op.Is(OpUpdateOne) {
  24681. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24682. }
  24683. if m.id == nil || m.oldValue == nil {
  24684. return v, errors.New("OldName requires an ID field in the mutation")
  24685. }
  24686. oldValue, err := m.oldValue(ctx)
  24687. if err != nil {
  24688. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24689. }
  24690. return oldValue.Name, nil
  24691. }
  24692. // ResetName resets all changes to the "name" field.
  24693. func (m *ServerMutation) ResetName() {
  24694. m.name = nil
  24695. }
  24696. // SetPublicIP sets the "public_ip" field.
  24697. func (m *ServerMutation) SetPublicIP(s string) {
  24698. m.public_ip = &s
  24699. }
  24700. // PublicIP returns the value of the "public_ip" field in the mutation.
  24701. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  24702. v := m.public_ip
  24703. if v == nil {
  24704. return
  24705. }
  24706. return *v, true
  24707. }
  24708. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  24709. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24711. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  24712. if !m.op.Is(OpUpdateOne) {
  24713. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  24714. }
  24715. if m.id == nil || m.oldValue == nil {
  24716. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  24717. }
  24718. oldValue, err := m.oldValue(ctx)
  24719. if err != nil {
  24720. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  24721. }
  24722. return oldValue.PublicIP, nil
  24723. }
  24724. // ResetPublicIP resets all changes to the "public_ip" field.
  24725. func (m *ServerMutation) ResetPublicIP() {
  24726. m.public_ip = nil
  24727. }
  24728. // SetPrivateIP sets the "private_ip" field.
  24729. func (m *ServerMutation) SetPrivateIP(s string) {
  24730. m.private_ip = &s
  24731. }
  24732. // PrivateIP returns the value of the "private_ip" field in the mutation.
  24733. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  24734. v := m.private_ip
  24735. if v == nil {
  24736. return
  24737. }
  24738. return *v, true
  24739. }
  24740. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  24741. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24743. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  24744. if !m.op.Is(OpUpdateOne) {
  24745. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  24746. }
  24747. if m.id == nil || m.oldValue == nil {
  24748. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  24749. }
  24750. oldValue, err := m.oldValue(ctx)
  24751. if err != nil {
  24752. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  24753. }
  24754. return oldValue.PrivateIP, nil
  24755. }
  24756. // ResetPrivateIP resets all changes to the "private_ip" field.
  24757. func (m *ServerMutation) ResetPrivateIP() {
  24758. m.private_ip = nil
  24759. }
  24760. // SetAdminPort sets the "admin_port" field.
  24761. func (m *ServerMutation) SetAdminPort(s string) {
  24762. m.admin_port = &s
  24763. }
  24764. // AdminPort returns the value of the "admin_port" field in the mutation.
  24765. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  24766. v := m.admin_port
  24767. if v == nil {
  24768. return
  24769. }
  24770. return *v, true
  24771. }
  24772. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  24773. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24775. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  24776. if !m.op.Is(OpUpdateOne) {
  24777. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  24778. }
  24779. if m.id == nil || m.oldValue == nil {
  24780. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  24781. }
  24782. oldValue, err := m.oldValue(ctx)
  24783. if err != nil {
  24784. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  24785. }
  24786. return oldValue.AdminPort, nil
  24787. }
  24788. // ResetAdminPort resets all changes to the "admin_port" field.
  24789. func (m *ServerMutation) ResetAdminPort() {
  24790. m.admin_port = nil
  24791. }
  24792. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  24793. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  24794. if m.wxs == nil {
  24795. m.wxs = make(map[uint64]struct{})
  24796. }
  24797. for i := range ids {
  24798. m.wxs[ids[i]] = struct{}{}
  24799. }
  24800. }
  24801. // ClearWxs clears the "wxs" edge to the Wx entity.
  24802. func (m *ServerMutation) ClearWxs() {
  24803. m.clearedwxs = true
  24804. }
  24805. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  24806. func (m *ServerMutation) WxsCleared() bool {
  24807. return m.clearedwxs
  24808. }
  24809. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  24810. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  24811. if m.removedwxs == nil {
  24812. m.removedwxs = make(map[uint64]struct{})
  24813. }
  24814. for i := range ids {
  24815. delete(m.wxs, ids[i])
  24816. m.removedwxs[ids[i]] = struct{}{}
  24817. }
  24818. }
  24819. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  24820. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  24821. for id := range m.removedwxs {
  24822. ids = append(ids, id)
  24823. }
  24824. return
  24825. }
  24826. // WxsIDs returns the "wxs" edge IDs in the mutation.
  24827. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  24828. for id := range m.wxs {
  24829. ids = append(ids, id)
  24830. }
  24831. return
  24832. }
  24833. // ResetWxs resets all changes to the "wxs" edge.
  24834. func (m *ServerMutation) ResetWxs() {
  24835. m.wxs = nil
  24836. m.clearedwxs = false
  24837. m.removedwxs = nil
  24838. }
  24839. // Where appends a list predicates to the ServerMutation builder.
  24840. func (m *ServerMutation) Where(ps ...predicate.Server) {
  24841. m.predicates = append(m.predicates, ps...)
  24842. }
  24843. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  24844. // users can use type-assertion to append predicates that do not depend on any generated package.
  24845. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  24846. p := make([]predicate.Server, len(ps))
  24847. for i := range ps {
  24848. p[i] = ps[i]
  24849. }
  24850. m.Where(p...)
  24851. }
  24852. // Op returns the operation name.
  24853. func (m *ServerMutation) Op() Op {
  24854. return m.op
  24855. }
  24856. // SetOp allows setting the mutation operation.
  24857. func (m *ServerMutation) SetOp(op Op) {
  24858. m.op = op
  24859. }
  24860. // Type returns the node type of this mutation (Server).
  24861. func (m *ServerMutation) Type() string {
  24862. return m.typ
  24863. }
  24864. // Fields returns all fields that were changed during this mutation. Note that in
  24865. // order to get all numeric fields that were incremented/decremented, call
  24866. // AddedFields().
  24867. func (m *ServerMutation) Fields() []string {
  24868. fields := make([]string, 0, 8)
  24869. if m.created_at != nil {
  24870. fields = append(fields, server.FieldCreatedAt)
  24871. }
  24872. if m.updated_at != nil {
  24873. fields = append(fields, server.FieldUpdatedAt)
  24874. }
  24875. if m.status != nil {
  24876. fields = append(fields, server.FieldStatus)
  24877. }
  24878. if m.deleted_at != nil {
  24879. fields = append(fields, server.FieldDeletedAt)
  24880. }
  24881. if m.name != nil {
  24882. fields = append(fields, server.FieldName)
  24883. }
  24884. if m.public_ip != nil {
  24885. fields = append(fields, server.FieldPublicIP)
  24886. }
  24887. if m.private_ip != nil {
  24888. fields = append(fields, server.FieldPrivateIP)
  24889. }
  24890. if m.admin_port != nil {
  24891. fields = append(fields, server.FieldAdminPort)
  24892. }
  24893. return fields
  24894. }
  24895. // Field returns the value of a field with the given name. The second boolean
  24896. // return value indicates that this field was not set, or was not defined in the
  24897. // schema.
  24898. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  24899. switch name {
  24900. case server.FieldCreatedAt:
  24901. return m.CreatedAt()
  24902. case server.FieldUpdatedAt:
  24903. return m.UpdatedAt()
  24904. case server.FieldStatus:
  24905. return m.Status()
  24906. case server.FieldDeletedAt:
  24907. return m.DeletedAt()
  24908. case server.FieldName:
  24909. return m.Name()
  24910. case server.FieldPublicIP:
  24911. return m.PublicIP()
  24912. case server.FieldPrivateIP:
  24913. return m.PrivateIP()
  24914. case server.FieldAdminPort:
  24915. return m.AdminPort()
  24916. }
  24917. return nil, false
  24918. }
  24919. // OldField returns the old value of the field from the database. An error is
  24920. // returned if the mutation operation is not UpdateOne, or the query to the
  24921. // database failed.
  24922. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24923. switch name {
  24924. case server.FieldCreatedAt:
  24925. return m.OldCreatedAt(ctx)
  24926. case server.FieldUpdatedAt:
  24927. return m.OldUpdatedAt(ctx)
  24928. case server.FieldStatus:
  24929. return m.OldStatus(ctx)
  24930. case server.FieldDeletedAt:
  24931. return m.OldDeletedAt(ctx)
  24932. case server.FieldName:
  24933. return m.OldName(ctx)
  24934. case server.FieldPublicIP:
  24935. return m.OldPublicIP(ctx)
  24936. case server.FieldPrivateIP:
  24937. return m.OldPrivateIP(ctx)
  24938. case server.FieldAdminPort:
  24939. return m.OldAdminPort(ctx)
  24940. }
  24941. return nil, fmt.Errorf("unknown Server field %s", name)
  24942. }
  24943. // SetField sets the value of a field with the given name. It returns an error if
  24944. // the field is not defined in the schema, or if the type mismatched the field
  24945. // type.
  24946. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  24947. switch name {
  24948. case server.FieldCreatedAt:
  24949. v, ok := value.(time.Time)
  24950. if !ok {
  24951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24952. }
  24953. m.SetCreatedAt(v)
  24954. return nil
  24955. case server.FieldUpdatedAt:
  24956. v, ok := value.(time.Time)
  24957. if !ok {
  24958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24959. }
  24960. m.SetUpdatedAt(v)
  24961. return nil
  24962. case server.FieldStatus:
  24963. v, ok := value.(uint8)
  24964. if !ok {
  24965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24966. }
  24967. m.SetStatus(v)
  24968. return nil
  24969. case server.FieldDeletedAt:
  24970. v, ok := value.(time.Time)
  24971. if !ok {
  24972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24973. }
  24974. m.SetDeletedAt(v)
  24975. return nil
  24976. case server.FieldName:
  24977. v, ok := value.(string)
  24978. if !ok {
  24979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24980. }
  24981. m.SetName(v)
  24982. return nil
  24983. case server.FieldPublicIP:
  24984. v, ok := value.(string)
  24985. if !ok {
  24986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24987. }
  24988. m.SetPublicIP(v)
  24989. return nil
  24990. case server.FieldPrivateIP:
  24991. v, ok := value.(string)
  24992. if !ok {
  24993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24994. }
  24995. m.SetPrivateIP(v)
  24996. return nil
  24997. case server.FieldAdminPort:
  24998. v, ok := value.(string)
  24999. if !ok {
  25000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25001. }
  25002. m.SetAdminPort(v)
  25003. return nil
  25004. }
  25005. return fmt.Errorf("unknown Server field %s", name)
  25006. }
  25007. // AddedFields returns all numeric fields that were incremented/decremented during
  25008. // this mutation.
  25009. func (m *ServerMutation) AddedFields() []string {
  25010. var fields []string
  25011. if m.addstatus != nil {
  25012. fields = append(fields, server.FieldStatus)
  25013. }
  25014. return fields
  25015. }
  25016. // AddedField returns the numeric value that was incremented/decremented on a field
  25017. // with the given name. The second boolean return value indicates that this field
  25018. // was not set, or was not defined in the schema.
  25019. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  25020. switch name {
  25021. case server.FieldStatus:
  25022. return m.AddedStatus()
  25023. }
  25024. return nil, false
  25025. }
  25026. // AddField adds the value to the field with the given name. It returns an error if
  25027. // the field is not defined in the schema, or if the type mismatched the field
  25028. // type.
  25029. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  25030. switch name {
  25031. case server.FieldStatus:
  25032. v, ok := value.(int8)
  25033. if !ok {
  25034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25035. }
  25036. m.AddStatus(v)
  25037. return nil
  25038. }
  25039. return fmt.Errorf("unknown Server numeric field %s", name)
  25040. }
  25041. // ClearedFields returns all nullable fields that were cleared during this
  25042. // mutation.
  25043. func (m *ServerMutation) ClearedFields() []string {
  25044. var fields []string
  25045. if m.FieldCleared(server.FieldStatus) {
  25046. fields = append(fields, server.FieldStatus)
  25047. }
  25048. if m.FieldCleared(server.FieldDeletedAt) {
  25049. fields = append(fields, server.FieldDeletedAt)
  25050. }
  25051. return fields
  25052. }
  25053. // FieldCleared returns a boolean indicating if a field with the given name was
  25054. // cleared in this mutation.
  25055. func (m *ServerMutation) FieldCleared(name string) bool {
  25056. _, ok := m.clearedFields[name]
  25057. return ok
  25058. }
  25059. // ClearField clears the value of the field with the given name. It returns an
  25060. // error if the field is not defined in the schema.
  25061. func (m *ServerMutation) ClearField(name string) error {
  25062. switch name {
  25063. case server.FieldStatus:
  25064. m.ClearStatus()
  25065. return nil
  25066. case server.FieldDeletedAt:
  25067. m.ClearDeletedAt()
  25068. return nil
  25069. }
  25070. return fmt.Errorf("unknown Server nullable field %s", name)
  25071. }
  25072. // ResetField resets all changes in the mutation for the field with the given name.
  25073. // It returns an error if the field is not defined in the schema.
  25074. func (m *ServerMutation) ResetField(name string) error {
  25075. switch name {
  25076. case server.FieldCreatedAt:
  25077. m.ResetCreatedAt()
  25078. return nil
  25079. case server.FieldUpdatedAt:
  25080. m.ResetUpdatedAt()
  25081. return nil
  25082. case server.FieldStatus:
  25083. m.ResetStatus()
  25084. return nil
  25085. case server.FieldDeletedAt:
  25086. m.ResetDeletedAt()
  25087. return nil
  25088. case server.FieldName:
  25089. m.ResetName()
  25090. return nil
  25091. case server.FieldPublicIP:
  25092. m.ResetPublicIP()
  25093. return nil
  25094. case server.FieldPrivateIP:
  25095. m.ResetPrivateIP()
  25096. return nil
  25097. case server.FieldAdminPort:
  25098. m.ResetAdminPort()
  25099. return nil
  25100. }
  25101. return fmt.Errorf("unknown Server field %s", name)
  25102. }
  25103. // AddedEdges returns all edge names that were set/added in this mutation.
  25104. func (m *ServerMutation) AddedEdges() []string {
  25105. edges := make([]string, 0, 1)
  25106. if m.wxs != nil {
  25107. edges = append(edges, server.EdgeWxs)
  25108. }
  25109. return edges
  25110. }
  25111. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25112. // name in this mutation.
  25113. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  25114. switch name {
  25115. case server.EdgeWxs:
  25116. ids := make([]ent.Value, 0, len(m.wxs))
  25117. for id := range m.wxs {
  25118. ids = append(ids, id)
  25119. }
  25120. return ids
  25121. }
  25122. return nil
  25123. }
  25124. // RemovedEdges returns all edge names that were removed in this mutation.
  25125. func (m *ServerMutation) RemovedEdges() []string {
  25126. edges := make([]string, 0, 1)
  25127. if m.removedwxs != nil {
  25128. edges = append(edges, server.EdgeWxs)
  25129. }
  25130. return edges
  25131. }
  25132. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25133. // the given name in this mutation.
  25134. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  25135. switch name {
  25136. case server.EdgeWxs:
  25137. ids := make([]ent.Value, 0, len(m.removedwxs))
  25138. for id := range m.removedwxs {
  25139. ids = append(ids, id)
  25140. }
  25141. return ids
  25142. }
  25143. return nil
  25144. }
  25145. // ClearedEdges returns all edge names that were cleared in this mutation.
  25146. func (m *ServerMutation) ClearedEdges() []string {
  25147. edges := make([]string, 0, 1)
  25148. if m.clearedwxs {
  25149. edges = append(edges, server.EdgeWxs)
  25150. }
  25151. return edges
  25152. }
  25153. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25154. // was cleared in this mutation.
  25155. func (m *ServerMutation) EdgeCleared(name string) bool {
  25156. switch name {
  25157. case server.EdgeWxs:
  25158. return m.clearedwxs
  25159. }
  25160. return false
  25161. }
  25162. // ClearEdge clears the value of the edge with the given name. It returns an error
  25163. // if that edge is not defined in the schema.
  25164. func (m *ServerMutation) ClearEdge(name string) error {
  25165. switch name {
  25166. }
  25167. return fmt.Errorf("unknown Server unique edge %s", name)
  25168. }
  25169. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25170. // It returns an error if the edge is not defined in the schema.
  25171. func (m *ServerMutation) ResetEdge(name string) error {
  25172. switch name {
  25173. case server.EdgeWxs:
  25174. m.ResetWxs()
  25175. return nil
  25176. }
  25177. return fmt.Errorf("unknown Server edge %s", name)
  25178. }
  25179. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  25180. type SopNodeMutation struct {
  25181. config
  25182. op Op
  25183. typ string
  25184. id *uint64
  25185. created_at *time.Time
  25186. updated_at *time.Time
  25187. status *uint8
  25188. addstatus *int8
  25189. deleted_at *time.Time
  25190. parent_id *uint64
  25191. addparent_id *int64
  25192. name *string
  25193. condition_type *int
  25194. addcondition_type *int
  25195. condition_list *[]string
  25196. appendcondition_list []string
  25197. no_reply_condition *uint64
  25198. addno_reply_condition *int64
  25199. no_reply_unit *string
  25200. action_message *[]custom_types.Action
  25201. appendaction_message []custom_types.Action
  25202. action_label_add *[]uint64
  25203. appendaction_label_add []uint64
  25204. action_label_del *[]uint64
  25205. appendaction_label_del []uint64
  25206. action_forward **custom_types.ActionForward
  25207. clearedFields map[string]struct{}
  25208. sop_stage *uint64
  25209. clearedsop_stage bool
  25210. node_messages map[uint64]struct{}
  25211. removednode_messages map[uint64]struct{}
  25212. clearednode_messages bool
  25213. done bool
  25214. oldValue func(context.Context) (*SopNode, error)
  25215. predicates []predicate.SopNode
  25216. }
  25217. var _ ent.Mutation = (*SopNodeMutation)(nil)
  25218. // sopnodeOption allows management of the mutation configuration using functional options.
  25219. type sopnodeOption func(*SopNodeMutation)
  25220. // newSopNodeMutation creates new mutation for the SopNode entity.
  25221. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  25222. m := &SopNodeMutation{
  25223. config: c,
  25224. op: op,
  25225. typ: TypeSopNode,
  25226. clearedFields: make(map[string]struct{}),
  25227. }
  25228. for _, opt := range opts {
  25229. opt(m)
  25230. }
  25231. return m
  25232. }
  25233. // withSopNodeID sets the ID field of the mutation.
  25234. func withSopNodeID(id uint64) sopnodeOption {
  25235. return func(m *SopNodeMutation) {
  25236. var (
  25237. err error
  25238. once sync.Once
  25239. value *SopNode
  25240. )
  25241. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  25242. once.Do(func() {
  25243. if m.done {
  25244. err = errors.New("querying old values post mutation is not allowed")
  25245. } else {
  25246. value, err = m.Client().SopNode.Get(ctx, id)
  25247. }
  25248. })
  25249. return value, err
  25250. }
  25251. m.id = &id
  25252. }
  25253. }
  25254. // withSopNode sets the old SopNode of the mutation.
  25255. func withSopNode(node *SopNode) sopnodeOption {
  25256. return func(m *SopNodeMutation) {
  25257. m.oldValue = func(context.Context) (*SopNode, error) {
  25258. return node, nil
  25259. }
  25260. m.id = &node.ID
  25261. }
  25262. }
  25263. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25264. // executed in a transaction (ent.Tx), a transactional client is returned.
  25265. func (m SopNodeMutation) Client() *Client {
  25266. client := &Client{config: m.config}
  25267. client.init()
  25268. return client
  25269. }
  25270. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25271. // it returns an error otherwise.
  25272. func (m SopNodeMutation) Tx() (*Tx, error) {
  25273. if _, ok := m.driver.(*txDriver); !ok {
  25274. return nil, errors.New("ent: mutation is not running in a transaction")
  25275. }
  25276. tx := &Tx{config: m.config}
  25277. tx.init()
  25278. return tx, nil
  25279. }
  25280. // SetID sets the value of the id field. Note that this
  25281. // operation is only accepted on creation of SopNode entities.
  25282. func (m *SopNodeMutation) SetID(id uint64) {
  25283. m.id = &id
  25284. }
  25285. // ID returns the ID value in the mutation. Note that the ID is only available
  25286. // if it was provided to the builder or after it was returned from the database.
  25287. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  25288. if m.id == nil {
  25289. return
  25290. }
  25291. return *m.id, true
  25292. }
  25293. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25294. // That means, if the mutation is applied within a transaction with an isolation level such
  25295. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25296. // or updated by the mutation.
  25297. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  25298. switch {
  25299. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25300. id, exists := m.ID()
  25301. if exists {
  25302. return []uint64{id}, nil
  25303. }
  25304. fallthrough
  25305. case m.op.Is(OpUpdate | OpDelete):
  25306. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  25307. default:
  25308. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25309. }
  25310. }
  25311. // SetCreatedAt sets the "created_at" field.
  25312. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  25313. m.created_at = &t
  25314. }
  25315. // CreatedAt returns the value of the "created_at" field in the mutation.
  25316. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  25317. v := m.created_at
  25318. if v == nil {
  25319. return
  25320. }
  25321. return *v, true
  25322. }
  25323. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  25324. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25326. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25327. if !m.op.Is(OpUpdateOne) {
  25328. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25329. }
  25330. if m.id == nil || m.oldValue == nil {
  25331. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25332. }
  25333. oldValue, err := m.oldValue(ctx)
  25334. if err != nil {
  25335. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25336. }
  25337. return oldValue.CreatedAt, nil
  25338. }
  25339. // ResetCreatedAt resets all changes to the "created_at" field.
  25340. func (m *SopNodeMutation) ResetCreatedAt() {
  25341. m.created_at = nil
  25342. }
  25343. // SetUpdatedAt sets the "updated_at" field.
  25344. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  25345. m.updated_at = &t
  25346. }
  25347. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25348. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  25349. v := m.updated_at
  25350. if v == nil {
  25351. return
  25352. }
  25353. return *v, true
  25354. }
  25355. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  25356. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25358. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25359. if !m.op.Is(OpUpdateOne) {
  25360. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25361. }
  25362. if m.id == nil || m.oldValue == nil {
  25363. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25364. }
  25365. oldValue, err := m.oldValue(ctx)
  25366. if err != nil {
  25367. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25368. }
  25369. return oldValue.UpdatedAt, nil
  25370. }
  25371. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25372. func (m *SopNodeMutation) ResetUpdatedAt() {
  25373. m.updated_at = nil
  25374. }
  25375. // SetStatus sets the "status" field.
  25376. func (m *SopNodeMutation) SetStatus(u uint8) {
  25377. m.status = &u
  25378. m.addstatus = nil
  25379. }
  25380. // Status returns the value of the "status" field in the mutation.
  25381. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  25382. v := m.status
  25383. if v == nil {
  25384. return
  25385. }
  25386. return *v, true
  25387. }
  25388. // OldStatus returns the old "status" field's value of the SopNode entity.
  25389. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25391. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25392. if !m.op.Is(OpUpdateOne) {
  25393. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25394. }
  25395. if m.id == nil || m.oldValue == nil {
  25396. return v, errors.New("OldStatus requires an ID field in the mutation")
  25397. }
  25398. oldValue, err := m.oldValue(ctx)
  25399. if err != nil {
  25400. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25401. }
  25402. return oldValue.Status, nil
  25403. }
  25404. // AddStatus adds u to the "status" field.
  25405. func (m *SopNodeMutation) AddStatus(u int8) {
  25406. if m.addstatus != nil {
  25407. *m.addstatus += u
  25408. } else {
  25409. m.addstatus = &u
  25410. }
  25411. }
  25412. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25413. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  25414. v := m.addstatus
  25415. if v == nil {
  25416. return
  25417. }
  25418. return *v, true
  25419. }
  25420. // ClearStatus clears the value of the "status" field.
  25421. func (m *SopNodeMutation) ClearStatus() {
  25422. m.status = nil
  25423. m.addstatus = nil
  25424. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  25425. }
  25426. // StatusCleared returns if the "status" field was cleared in this mutation.
  25427. func (m *SopNodeMutation) StatusCleared() bool {
  25428. _, ok := m.clearedFields[sopnode.FieldStatus]
  25429. return ok
  25430. }
  25431. // ResetStatus resets all changes to the "status" field.
  25432. func (m *SopNodeMutation) ResetStatus() {
  25433. m.status = nil
  25434. m.addstatus = nil
  25435. delete(m.clearedFields, sopnode.FieldStatus)
  25436. }
  25437. // SetDeletedAt sets the "deleted_at" field.
  25438. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  25439. m.deleted_at = &t
  25440. }
  25441. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25442. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  25443. v := m.deleted_at
  25444. if v == nil {
  25445. return
  25446. }
  25447. return *v, true
  25448. }
  25449. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  25450. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25452. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25453. if !m.op.Is(OpUpdateOne) {
  25454. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25455. }
  25456. if m.id == nil || m.oldValue == nil {
  25457. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25458. }
  25459. oldValue, err := m.oldValue(ctx)
  25460. if err != nil {
  25461. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25462. }
  25463. return oldValue.DeletedAt, nil
  25464. }
  25465. // ClearDeletedAt clears the value of the "deleted_at" field.
  25466. func (m *SopNodeMutation) ClearDeletedAt() {
  25467. m.deleted_at = nil
  25468. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  25469. }
  25470. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25471. func (m *SopNodeMutation) DeletedAtCleared() bool {
  25472. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  25473. return ok
  25474. }
  25475. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25476. func (m *SopNodeMutation) ResetDeletedAt() {
  25477. m.deleted_at = nil
  25478. delete(m.clearedFields, sopnode.FieldDeletedAt)
  25479. }
  25480. // SetStageID sets the "stage_id" field.
  25481. func (m *SopNodeMutation) SetStageID(u uint64) {
  25482. m.sop_stage = &u
  25483. }
  25484. // StageID returns the value of the "stage_id" field in the mutation.
  25485. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  25486. v := m.sop_stage
  25487. if v == nil {
  25488. return
  25489. }
  25490. return *v, true
  25491. }
  25492. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  25493. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25495. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  25496. if !m.op.Is(OpUpdateOne) {
  25497. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  25498. }
  25499. if m.id == nil || m.oldValue == nil {
  25500. return v, errors.New("OldStageID requires an ID field in the mutation")
  25501. }
  25502. oldValue, err := m.oldValue(ctx)
  25503. if err != nil {
  25504. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  25505. }
  25506. return oldValue.StageID, nil
  25507. }
  25508. // ResetStageID resets all changes to the "stage_id" field.
  25509. func (m *SopNodeMutation) ResetStageID() {
  25510. m.sop_stage = nil
  25511. }
  25512. // SetParentID sets the "parent_id" field.
  25513. func (m *SopNodeMutation) SetParentID(u uint64) {
  25514. m.parent_id = &u
  25515. m.addparent_id = nil
  25516. }
  25517. // ParentID returns the value of the "parent_id" field in the mutation.
  25518. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  25519. v := m.parent_id
  25520. if v == nil {
  25521. return
  25522. }
  25523. return *v, true
  25524. }
  25525. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  25526. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25528. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  25529. if !m.op.Is(OpUpdateOne) {
  25530. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  25531. }
  25532. if m.id == nil || m.oldValue == nil {
  25533. return v, errors.New("OldParentID requires an ID field in the mutation")
  25534. }
  25535. oldValue, err := m.oldValue(ctx)
  25536. if err != nil {
  25537. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  25538. }
  25539. return oldValue.ParentID, nil
  25540. }
  25541. // AddParentID adds u to the "parent_id" field.
  25542. func (m *SopNodeMutation) AddParentID(u int64) {
  25543. if m.addparent_id != nil {
  25544. *m.addparent_id += u
  25545. } else {
  25546. m.addparent_id = &u
  25547. }
  25548. }
  25549. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  25550. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  25551. v := m.addparent_id
  25552. if v == nil {
  25553. return
  25554. }
  25555. return *v, true
  25556. }
  25557. // ResetParentID resets all changes to the "parent_id" field.
  25558. func (m *SopNodeMutation) ResetParentID() {
  25559. m.parent_id = nil
  25560. m.addparent_id = nil
  25561. }
  25562. // SetName sets the "name" field.
  25563. func (m *SopNodeMutation) SetName(s string) {
  25564. m.name = &s
  25565. }
  25566. // Name returns the value of the "name" field in the mutation.
  25567. func (m *SopNodeMutation) Name() (r string, exists bool) {
  25568. v := m.name
  25569. if v == nil {
  25570. return
  25571. }
  25572. return *v, true
  25573. }
  25574. // OldName returns the old "name" field's value of the SopNode entity.
  25575. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25577. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  25578. if !m.op.Is(OpUpdateOne) {
  25579. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25580. }
  25581. if m.id == nil || m.oldValue == nil {
  25582. return v, errors.New("OldName requires an ID field in the mutation")
  25583. }
  25584. oldValue, err := m.oldValue(ctx)
  25585. if err != nil {
  25586. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25587. }
  25588. return oldValue.Name, nil
  25589. }
  25590. // ResetName resets all changes to the "name" field.
  25591. func (m *SopNodeMutation) ResetName() {
  25592. m.name = nil
  25593. }
  25594. // SetConditionType sets the "condition_type" field.
  25595. func (m *SopNodeMutation) SetConditionType(i int) {
  25596. m.condition_type = &i
  25597. m.addcondition_type = nil
  25598. }
  25599. // ConditionType returns the value of the "condition_type" field in the mutation.
  25600. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  25601. v := m.condition_type
  25602. if v == nil {
  25603. return
  25604. }
  25605. return *v, true
  25606. }
  25607. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  25608. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25610. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25611. if !m.op.Is(OpUpdateOne) {
  25612. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25613. }
  25614. if m.id == nil || m.oldValue == nil {
  25615. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25616. }
  25617. oldValue, err := m.oldValue(ctx)
  25618. if err != nil {
  25619. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25620. }
  25621. return oldValue.ConditionType, nil
  25622. }
  25623. // AddConditionType adds i to the "condition_type" field.
  25624. func (m *SopNodeMutation) AddConditionType(i int) {
  25625. if m.addcondition_type != nil {
  25626. *m.addcondition_type += i
  25627. } else {
  25628. m.addcondition_type = &i
  25629. }
  25630. }
  25631. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25632. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  25633. v := m.addcondition_type
  25634. if v == nil {
  25635. return
  25636. }
  25637. return *v, true
  25638. }
  25639. // ResetConditionType resets all changes to the "condition_type" field.
  25640. func (m *SopNodeMutation) ResetConditionType() {
  25641. m.condition_type = nil
  25642. m.addcondition_type = nil
  25643. }
  25644. // SetConditionList sets the "condition_list" field.
  25645. func (m *SopNodeMutation) SetConditionList(s []string) {
  25646. m.condition_list = &s
  25647. m.appendcondition_list = nil
  25648. }
  25649. // ConditionList returns the value of the "condition_list" field in the mutation.
  25650. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  25651. v := m.condition_list
  25652. if v == nil {
  25653. return
  25654. }
  25655. return *v, true
  25656. }
  25657. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  25658. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25660. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  25661. if !m.op.Is(OpUpdateOne) {
  25662. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25663. }
  25664. if m.id == nil || m.oldValue == nil {
  25665. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25666. }
  25667. oldValue, err := m.oldValue(ctx)
  25668. if err != nil {
  25669. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25670. }
  25671. return oldValue.ConditionList, nil
  25672. }
  25673. // AppendConditionList adds s to the "condition_list" field.
  25674. func (m *SopNodeMutation) AppendConditionList(s []string) {
  25675. m.appendcondition_list = append(m.appendcondition_list, s...)
  25676. }
  25677. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25678. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  25679. if len(m.appendcondition_list) == 0 {
  25680. return nil, false
  25681. }
  25682. return m.appendcondition_list, true
  25683. }
  25684. // ClearConditionList clears the value of the "condition_list" field.
  25685. func (m *SopNodeMutation) ClearConditionList() {
  25686. m.condition_list = nil
  25687. m.appendcondition_list = nil
  25688. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  25689. }
  25690. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  25691. func (m *SopNodeMutation) ConditionListCleared() bool {
  25692. _, ok := m.clearedFields[sopnode.FieldConditionList]
  25693. return ok
  25694. }
  25695. // ResetConditionList resets all changes to the "condition_list" field.
  25696. func (m *SopNodeMutation) ResetConditionList() {
  25697. m.condition_list = nil
  25698. m.appendcondition_list = nil
  25699. delete(m.clearedFields, sopnode.FieldConditionList)
  25700. }
  25701. // SetNoReplyCondition sets the "no_reply_condition" field.
  25702. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  25703. m.no_reply_condition = &u
  25704. m.addno_reply_condition = nil
  25705. }
  25706. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  25707. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  25708. v := m.no_reply_condition
  25709. if v == nil {
  25710. return
  25711. }
  25712. return *v, true
  25713. }
  25714. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  25715. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25717. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  25718. if !m.op.Is(OpUpdateOne) {
  25719. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  25720. }
  25721. if m.id == nil || m.oldValue == nil {
  25722. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  25723. }
  25724. oldValue, err := m.oldValue(ctx)
  25725. if err != nil {
  25726. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  25727. }
  25728. return oldValue.NoReplyCondition, nil
  25729. }
  25730. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  25731. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  25732. if m.addno_reply_condition != nil {
  25733. *m.addno_reply_condition += u
  25734. } else {
  25735. m.addno_reply_condition = &u
  25736. }
  25737. }
  25738. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  25739. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  25740. v := m.addno_reply_condition
  25741. if v == nil {
  25742. return
  25743. }
  25744. return *v, true
  25745. }
  25746. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  25747. func (m *SopNodeMutation) ResetNoReplyCondition() {
  25748. m.no_reply_condition = nil
  25749. m.addno_reply_condition = nil
  25750. }
  25751. // SetNoReplyUnit sets the "no_reply_unit" field.
  25752. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  25753. m.no_reply_unit = &s
  25754. }
  25755. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  25756. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  25757. v := m.no_reply_unit
  25758. if v == nil {
  25759. return
  25760. }
  25761. return *v, true
  25762. }
  25763. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  25764. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25766. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  25767. if !m.op.Is(OpUpdateOne) {
  25768. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  25769. }
  25770. if m.id == nil || m.oldValue == nil {
  25771. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  25772. }
  25773. oldValue, err := m.oldValue(ctx)
  25774. if err != nil {
  25775. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  25776. }
  25777. return oldValue.NoReplyUnit, nil
  25778. }
  25779. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  25780. func (m *SopNodeMutation) ResetNoReplyUnit() {
  25781. m.no_reply_unit = nil
  25782. }
  25783. // SetActionMessage sets the "action_message" field.
  25784. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  25785. m.action_message = &ct
  25786. m.appendaction_message = nil
  25787. }
  25788. // ActionMessage returns the value of the "action_message" field in the mutation.
  25789. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25790. v := m.action_message
  25791. if v == nil {
  25792. return
  25793. }
  25794. return *v, true
  25795. }
  25796. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  25797. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25799. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25800. if !m.op.Is(OpUpdateOne) {
  25801. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25802. }
  25803. if m.id == nil || m.oldValue == nil {
  25804. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25805. }
  25806. oldValue, err := m.oldValue(ctx)
  25807. if err != nil {
  25808. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25809. }
  25810. return oldValue.ActionMessage, nil
  25811. }
  25812. // AppendActionMessage adds ct to the "action_message" field.
  25813. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  25814. m.appendaction_message = append(m.appendaction_message, ct...)
  25815. }
  25816. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25817. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25818. if len(m.appendaction_message) == 0 {
  25819. return nil, false
  25820. }
  25821. return m.appendaction_message, true
  25822. }
  25823. // ClearActionMessage clears the value of the "action_message" field.
  25824. func (m *SopNodeMutation) ClearActionMessage() {
  25825. m.action_message = nil
  25826. m.appendaction_message = nil
  25827. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  25828. }
  25829. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25830. func (m *SopNodeMutation) ActionMessageCleared() bool {
  25831. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  25832. return ok
  25833. }
  25834. // ResetActionMessage resets all changes to the "action_message" field.
  25835. func (m *SopNodeMutation) ResetActionMessage() {
  25836. m.action_message = nil
  25837. m.appendaction_message = nil
  25838. delete(m.clearedFields, sopnode.FieldActionMessage)
  25839. }
  25840. // SetActionLabelAdd sets the "action_label_add" field.
  25841. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  25842. m.action_label_add = &u
  25843. m.appendaction_label_add = nil
  25844. }
  25845. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25846. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25847. v := m.action_label_add
  25848. if v == nil {
  25849. return
  25850. }
  25851. return *v, true
  25852. }
  25853. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  25854. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25856. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25857. if !m.op.Is(OpUpdateOne) {
  25858. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25859. }
  25860. if m.id == nil || m.oldValue == nil {
  25861. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25862. }
  25863. oldValue, err := m.oldValue(ctx)
  25864. if err != nil {
  25865. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25866. }
  25867. return oldValue.ActionLabelAdd, nil
  25868. }
  25869. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25870. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  25871. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25872. }
  25873. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25874. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25875. if len(m.appendaction_label_add) == 0 {
  25876. return nil, false
  25877. }
  25878. return m.appendaction_label_add, true
  25879. }
  25880. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25881. func (m *SopNodeMutation) ClearActionLabelAdd() {
  25882. m.action_label_add = nil
  25883. m.appendaction_label_add = nil
  25884. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  25885. }
  25886. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25887. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  25888. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  25889. return ok
  25890. }
  25891. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25892. func (m *SopNodeMutation) ResetActionLabelAdd() {
  25893. m.action_label_add = nil
  25894. m.appendaction_label_add = nil
  25895. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  25896. }
  25897. // SetActionLabelDel sets the "action_label_del" field.
  25898. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  25899. m.action_label_del = &u
  25900. m.appendaction_label_del = nil
  25901. }
  25902. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25903. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  25904. v := m.action_label_del
  25905. if v == nil {
  25906. return
  25907. }
  25908. return *v, true
  25909. }
  25910. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  25911. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25913. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25914. if !m.op.Is(OpUpdateOne) {
  25915. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25916. }
  25917. if m.id == nil || m.oldValue == nil {
  25918. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25919. }
  25920. oldValue, err := m.oldValue(ctx)
  25921. if err != nil {
  25922. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25923. }
  25924. return oldValue.ActionLabelDel, nil
  25925. }
  25926. // AppendActionLabelDel adds u to the "action_label_del" field.
  25927. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  25928. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25929. }
  25930. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25931. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25932. if len(m.appendaction_label_del) == 0 {
  25933. return nil, false
  25934. }
  25935. return m.appendaction_label_del, true
  25936. }
  25937. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25938. func (m *SopNodeMutation) ClearActionLabelDel() {
  25939. m.action_label_del = nil
  25940. m.appendaction_label_del = nil
  25941. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  25942. }
  25943. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25944. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  25945. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  25946. return ok
  25947. }
  25948. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25949. func (m *SopNodeMutation) ResetActionLabelDel() {
  25950. m.action_label_del = nil
  25951. m.appendaction_label_del = nil
  25952. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  25953. }
  25954. // SetActionForward sets the "action_forward" field.
  25955. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25956. m.action_forward = &ctf
  25957. }
  25958. // ActionForward returns the value of the "action_forward" field in the mutation.
  25959. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25960. v := m.action_forward
  25961. if v == nil {
  25962. return
  25963. }
  25964. return *v, true
  25965. }
  25966. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  25967. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25969. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25970. if !m.op.Is(OpUpdateOne) {
  25971. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25972. }
  25973. if m.id == nil || m.oldValue == nil {
  25974. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25975. }
  25976. oldValue, err := m.oldValue(ctx)
  25977. if err != nil {
  25978. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25979. }
  25980. return oldValue.ActionForward, nil
  25981. }
  25982. // ClearActionForward clears the value of the "action_forward" field.
  25983. func (m *SopNodeMutation) ClearActionForward() {
  25984. m.action_forward = nil
  25985. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  25986. }
  25987. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25988. func (m *SopNodeMutation) ActionForwardCleared() bool {
  25989. _, ok := m.clearedFields[sopnode.FieldActionForward]
  25990. return ok
  25991. }
  25992. // ResetActionForward resets all changes to the "action_forward" field.
  25993. func (m *SopNodeMutation) ResetActionForward() {
  25994. m.action_forward = nil
  25995. delete(m.clearedFields, sopnode.FieldActionForward)
  25996. }
  25997. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25998. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  25999. m.sop_stage = &id
  26000. }
  26001. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  26002. func (m *SopNodeMutation) ClearSopStage() {
  26003. m.clearedsop_stage = true
  26004. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  26005. }
  26006. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  26007. func (m *SopNodeMutation) SopStageCleared() bool {
  26008. return m.clearedsop_stage
  26009. }
  26010. // SopStageID returns the "sop_stage" edge ID in the mutation.
  26011. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  26012. if m.sop_stage != nil {
  26013. return *m.sop_stage, true
  26014. }
  26015. return
  26016. }
  26017. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  26018. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26019. // SopStageID instead. It exists only for internal usage by the builders.
  26020. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  26021. if id := m.sop_stage; id != nil {
  26022. ids = append(ids, *id)
  26023. }
  26024. return
  26025. }
  26026. // ResetSopStage resets all changes to the "sop_stage" edge.
  26027. func (m *SopNodeMutation) ResetSopStage() {
  26028. m.sop_stage = nil
  26029. m.clearedsop_stage = false
  26030. }
  26031. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  26032. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  26033. if m.node_messages == nil {
  26034. m.node_messages = make(map[uint64]struct{})
  26035. }
  26036. for i := range ids {
  26037. m.node_messages[ids[i]] = struct{}{}
  26038. }
  26039. }
  26040. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  26041. func (m *SopNodeMutation) ClearNodeMessages() {
  26042. m.clearednode_messages = true
  26043. }
  26044. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  26045. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  26046. return m.clearednode_messages
  26047. }
  26048. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  26049. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  26050. if m.removednode_messages == nil {
  26051. m.removednode_messages = make(map[uint64]struct{})
  26052. }
  26053. for i := range ids {
  26054. delete(m.node_messages, ids[i])
  26055. m.removednode_messages[ids[i]] = struct{}{}
  26056. }
  26057. }
  26058. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  26059. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  26060. for id := range m.removednode_messages {
  26061. ids = append(ids, id)
  26062. }
  26063. return
  26064. }
  26065. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  26066. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  26067. for id := range m.node_messages {
  26068. ids = append(ids, id)
  26069. }
  26070. return
  26071. }
  26072. // ResetNodeMessages resets all changes to the "node_messages" edge.
  26073. func (m *SopNodeMutation) ResetNodeMessages() {
  26074. m.node_messages = nil
  26075. m.clearednode_messages = false
  26076. m.removednode_messages = nil
  26077. }
  26078. // Where appends a list predicates to the SopNodeMutation builder.
  26079. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  26080. m.predicates = append(m.predicates, ps...)
  26081. }
  26082. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  26083. // users can use type-assertion to append predicates that do not depend on any generated package.
  26084. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  26085. p := make([]predicate.SopNode, len(ps))
  26086. for i := range ps {
  26087. p[i] = ps[i]
  26088. }
  26089. m.Where(p...)
  26090. }
  26091. // Op returns the operation name.
  26092. func (m *SopNodeMutation) Op() Op {
  26093. return m.op
  26094. }
  26095. // SetOp allows setting the mutation operation.
  26096. func (m *SopNodeMutation) SetOp(op Op) {
  26097. m.op = op
  26098. }
  26099. // Type returns the node type of this mutation (SopNode).
  26100. func (m *SopNodeMutation) Type() string {
  26101. return m.typ
  26102. }
  26103. // Fields returns all fields that were changed during this mutation. Note that in
  26104. // order to get all numeric fields that were incremented/decremented, call
  26105. // AddedFields().
  26106. func (m *SopNodeMutation) Fields() []string {
  26107. fields := make([]string, 0, 15)
  26108. if m.created_at != nil {
  26109. fields = append(fields, sopnode.FieldCreatedAt)
  26110. }
  26111. if m.updated_at != nil {
  26112. fields = append(fields, sopnode.FieldUpdatedAt)
  26113. }
  26114. if m.status != nil {
  26115. fields = append(fields, sopnode.FieldStatus)
  26116. }
  26117. if m.deleted_at != nil {
  26118. fields = append(fields, sopnode.FieldDeletedAt)
  26119. }
  26120. if m.sop_stage != nil {
  26121. fields = append(fields, sopnode.FieldStageID)
  26122. }
  26123. if m.parent_id != nil {
  26124. fields = append(fields, sopnode.FieldParentID)
  26125. }
  26126. if m.name != nil {
  26127. fields = append(fields, sopnode.FieldName)
  26128. }
  26129. if m.condition_type != nil {
  26130. fields = append(fields, sopnode.FieldConditionType)
  26131. }
  26132. if m.condition_list != nil {
  26133. fields = append(fields, sopnode.FieldConditionList)
  26134. }
  26135. if m.no_reply_condition != nil {
  26136. fields = append(fields, sopnode.FieldNoReplyCondition)
  26137. }
  26138. if m.no_reply_unit != nil {
  26139. fields = append(fields, sopnode.FieldNoReplyUnit)
  26140. }
  26141. if m.action_message != nil {
  26142. fields = append(fields, sopnode.FieldActionMessage)
  26143. }
  26144. if m.action_label_add != nil {
  26145. fields = append(fields, sopnode.FieldActionLabelAdd)
  26146. }
  26147. if m.action_label_del != nil {
  26148. fields = append(fields, sopnode.FieldActionLabelDel)
  26149. }
  26150. if m.action_forward != nil {
  26151. fields = append(fields, sopnode.FieldActionForward)
  26152. }
  26153. return fields
  26154. }
  26155. // Field returns the value of a field with the given name. The second boolean
  26156. // return value indicates that this field was not set, or was not defined in the
  26157. // schema.
  26158. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  26159. switch name {
  26160. case sopnode.FieldCreatedAt:
  26161. return m.CreatedAt()
  26162. case sopnode.FieldUpdatedAt:
  26163. return m.UpdatedAt()
  26164. case sopnode.FieldStatus:
  26165. return m.Status()
  26166. case sopnode.FieldDeletedAt:
  26167. return m.DeletedAt()
  26168. case sopnode.FieldStageID:
  26169. return m.StageID()
  26170. case sopnode.FieldParentID:
  26171. return m.ParentID()
  26172. case sopnode.FieldName:
  26173. return m.Name()
  26174. case sopnode.FieldConditionType:
  26175. return m.ConditionType()
  26176. case sopnode.FieldConditionList:
  26177. return m.ConditionList()
  26178. case sopnode.FieldNoReplyCondition:
  26179. return m.NoReplyCondition()
  26180. case sopnode.FieldNoReplyUnit:
  26181. return m.NoReplyUnit()
  26182. case sopnode.FieldActionMessage:
  26183. return m.ActionMessage()
  26184. case sopnode.FieldActionLabelAdd:
  26185. return m.ActionLabelAdd()
  26186. case sopnode.FieldActionLabelDel:
  26187. return m.ActionLabelDel()
  26188. case sopnode.FieldActionForward:
  26189. return m.ActionForward()
  26190. }
  26191. return nil, false
  26192. }
  26193. // OldField returns the old value of the field from the database. An error is
  26194. // returned if the mutation operation is not UpdateOne, or the query to the
  26195. // database failed.
  26196. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26197. switch name {
  26198. case sopnode.FieldCreatedAt:
  26199. return m.OldCreatedAt(ctx)
  26200. case sopnode.FieldUpdatedAt:
  26201. return m.OldUpdatedAt(ctx)
  26202. case sopnode.FieldStatus:
  26203. return m.OldStatus(ctx)
  26204. case sopnode.FieldDeletedAt:
  26205. return m.OldDeletedAt(ctx)
  26206. case sopnode.FieldStageID:
  26207. return m.OldStageID(ctx)
  26208. case sopnode.FieldParentID:
  26209. return m.OldParentID(ctx)
  26210. case sopnode.FieldName:
  26211. return m.OldName(ctx)
  26212. case sopnode.FieldConditionType:
  26213. return m.OldConditionType(ctx)
  26214. case sopnode.FieldConditionList:
  26215. return m.OldConditionList(ctx)
  26216. case sopnode.FieldNoReplyCondition:
  26217. return m.OldNoReplyCondition(ctx)
  26218. case sopnode.FieldNoReplyUnit:
  26219. return m.OldNoReplyUnit(ctx)
  26220. case sopnode.FieldActionMessage:
  26221. return m.OldActionMessage(ctx)
  26222. case sopnode.FieldActionLabelAdd:
  26223. return m.OldActionLabelAdd(ctx)
  26224. case sopnode.FieldActionLabelDel:
  26225. return m.OldActionLabelDel(ctx)
  26226. case sopnode.FieldActionForward:
  26227. return m.OldActionForward(ctx)
  26228. }
  26229. return nil, fmt.Errorf("unknown SopNode field %s", name)
  26230. }
  26231. // SetField sets the value of a field with the given name. It returns an error if
  26232. // the field is not defined in the schema, or if the type mismatched the field
  26233. // type.
  26234. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  26235. switch name {
  26236. case sopnode.FieldCreatedAt:
  26237. v, ok := value.(time.Time)
  26238. if !ok {
  26239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26240. }
  26241. m.SetCreatedAt(v)
  26242. return nil
  26243. case sopnode.FieldUpdatedAt:
  26244. v, ok := value.(time.Time)
  26245. if !ok {
  26246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26247. }
  26248. m.SetUpdatedAt(v)
  26249. return nil
  26250. case sopnode.FieldStatus:
  26251. v, ok := value.(uint8)
  26252. if !ok {
  26253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26254. }
  26255. m.SetStatus(v)
  26256. return nil
  26257. case sopnode.FieldDeletedAt:
  26258. v, ok := value.(time.Time)
  26259. if !ok {
  26260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26261. }
  26262. m.SetDeletedAt(v)
  26263. return nil
  26264. case sopnode.FieldStageID:
  26265. v, ok := value.(uint64)
  26266. if !ok {
  26267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26268. }
  26269. m.SetStageID(v)
  26270. return nil
  26271. case sopnode.FieldParentID:
  26272. v, ok := value.(uint64)
  26273. if !ok {
  26274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26275. }
  26276. m.SetParentID(v)
  26277. return nil
  26278. case sopnode.FieldName:
  26279. v, ok := value.(string)
  26280. if !ok {
  26281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26282. }
  26283. m.SetName(v)
  26284. return nil
  26285. case sopnode.FieldConditionType:
  26286. v, ok := value.(int)
  26287. if !ok {
  26288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26289. }
  26290. m.SetConditionType(v)
  26291. return nil
  26292. case sopnode.FieldConditionList:
  26293. v, ok := value.([]string)
  26294. if !ok {
  26295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26296. }
  26297. m.SetConditionList(v)
  26298. return nil
  26299. case sopnode.FieldNoReplyCondition:
  26300. v, ok := value.(uint64)
  26301. if !ok {
  26302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26303. }
  26304. m.SetNoReplyCondition(v)
  26305. return nil
  26306. case sopnode.FieldNoReplyUnit:
  26307. v, ok := value.(string)
  26308. if !ok {
  26309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26310. }
  26311. m.SetNoReplyUnit(v)
  26312. return nil
  26313. case sopnode.FieldActionMessage:
  26314. v, ok := value.([]custom_types.Action)
  26315. if !ok {
  26316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26317. }
  26318. m.SetActionMessage(v)
  26319. return nil
  26320. case sopnode.FieldActionLabelAdd:
  26321. v, ok := value.([]uint64)
  26322. if !ok {
  26323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26324. }
  26325. m.SetActionLabelAdd(v)
  26326. return nil
  26327. case sopnode.FieldActionLabelDel:
  26328. v, ok := value.([]uint64)
  26329. if !ok {
  26330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26331. }
  26332. m.SetActionLabelDel(v)
  26333. return nil
  26334. case sopnode.FieldActionForward:
  26335. v, ok := value.(*custom_types.ActionForward)
  26336. if !ok {
  26337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26338. }
  26339. m.SetActionForward(v)
  26340. return nil
  26341. }
  26342. return fmt.Errorf("unknown SopNode field %s", name)
  26343. }
  26344. // AddedFields returns all numeric fields that were incremented/decremented during
  26345. // this mutation.
  26346. func (m *SopNodeMutation) AddedFields() []string {
  26347. var fields []string
  26348. if m.addstatus != nil {
  26349. fields = append(fields, sopnode.FieldStatus)
  26350. }
  26351. if m.addparent_id != nil {
  26352. fields = append(fields, sopnode.FieldParentID)
  26353. }
  26354. if m.addcondition_type != nil {
  26355. fields = append(fields, sopnode.FieldConditionType)
  26356. }
  26357. if m.addno_reply_condition != nil {
  26358. fields = append(fields, sopnode.FieldNoReplyCondition)
  26359. }
  26360. return fields
  26361. }
  26362. // AddedField returns the numeric value that was incremented/decremented on a field
  26363. // with the given name. The second boolean return value indicates that this field
  26364. // was not set, or was not defined in the schema.
  26365. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  26366. switch name {
  26367. case sopnode.FieldStatus:
  26368. return m.AddedStatus()
  26369. case sopnode.FieldParentID:
  26370. return m.AddedParentID()
  26371. case sopnode.FieldConditionType:
  26372. return m.AddedConditionType()
  26373. case sopnode.FieldNoReplyCondition:
  26374. return m.AddedNoReplyCondition()
  26375. }
  26376. return nil, false
  26377. }
  26378. // AddField adds the value to the field with the given name. It returns an error if
  26379. // the field is not defined in the schema, or if the type mismatched the field
  26380. // type.
  26381. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  26382. switch name {
  26383. case sopnode.FieldStatus:
  26384. v, ok := value.(int8)
  26385. if !ok {
  26386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26387. }
  26388. m.AddStatus(v)
  26389. return nil
  26390. case sopnode.FieldParentID:
  26391. v, ok := value.(int64)
  26392. if !ok {
  26393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26394. }
  26395. m.AddParentID(v)
  26396. return nil
  26397. case sopnode.FieldConditionType:
  26398. v, ok := value.(int)
  26399. if !ok {
  26400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26401. }
  26402. m.AddConditionType(v)
  26403. return nil
  26404. case sopnode.FieldNoReplyCondition:
  26405. v, ok := value.(int64)
  26406. if !ok {
  26407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26408. }
  26409. m.AddNoReplyCondition(v)
  26410. return nil
  26411. }
  26412. return fmt.Errorf("unknown SopNode numeric field %s", name)
  26413. }
  26414. // ClearedFields returns all nullable fields that were cleared during this
  26415. // mutation.
  26416. func (m *SopNodeMutation) ClearedFields() []string {
  26417. var fields []string
  26418. if m.FieldCleared(sopnode.FieldStatus) {
  26419. fields = append(fields, sopnode.FieldStatus)
  26420. }
  26421. if m.FieldCleared(sopnode.FieldDeletedAt) {
  26422. fields = append(fields, sopnode.FieldDeletedAt)
  26423. }
  26424. if m.FieldCleared(sopnode.FieldConditionList) {
  26425. fields = append(fields, sopnode.FieldConditionList)
  26426. }
  26427. if m.FieldCleared(sopnode.FieldActionMessage) {
  26428. fields = append(fields, sopnode.FieldActionMessage)
  26429. }
  26430. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  26431. fields = append(fields, sopnode.FieldActionLabelAdd)
  26432. }
  26433. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  26434. fields = append(fields, sopnode.FieldActionLabelDel)
  26435. }
  26436. if m.FieldCleared(sopnode.FieldActionForward) {
  26437. fields = append(fields, sopnode.FieldActionForward)
  26438. }
  26439. return fields
  26440. }
  26441. // FieldCleared returns a boolean indicating if a field with the given name was
  26442. // cleared in this mutation.
  26443. func (m *SopNodeMutation) FieldCleared(name string) bool {
  26444. _, ok := m.clearedFields[name]
  26445. return ok
  26446. }
  26447. // ClearField clears the value of the field with the given name. It returns an
  26448. // error if the field is not defined in the schema.
  26449. func (m *SopNodeMutation) ClearField(name string) error {
  26450. switch name {
  26451. case sopnode.FieldStatus:
  26452. m.ClearStatus()
  26453. return nil
  26454. case sopnode.FieldDeletedAt:
  26455. m.ClearDeletedAt()
  26456. return nil
  26457. case sopnode.FieldConditionList:
  26458. m.ClearConditionList()
  26459. return nil
  26460. case sopnode.FieldActionMessage:
  26461. m.ClearActionMessage()
  26462. return nil
  26463. case sopnode.FieldActionLabelAdd:
  26464. m.ClearActionLabelAdd()
  26465. return nil
  26466. case sopnode.FieldActionLabelDel:
  26467. m.ClearActionLabelDel()
  26468. return nil
  26469. case sopnode.FieldActionForward:
  26470. m.ClearActionForward()
  26471. return nil
  26472. }
  26473. return fmt.Errorf("unknown SopNode nullable field %s", name)
  26474. }
  26475. // ResetField resets all changes in the mutation for the field with the given name.
  26476. // It returns an error if the field is not defined in the schema.
  26477. func (m *SopNodeMutation) ResetField(name string) error {
  26478. switch name {
  26479. case sopnode.FieldCreatedAt:
  26480. m.ResetCreatedAt()
  26481. return nil
  26482. case sopnode.FieldUpdatedAt:
  26483. m.ResetUpdatedAt()
  26484. return nil
  26485. case sopnode.FieldStatus:
  26486. m.ResetStatus()
  26487. return nil
  26488. case sopnode.FieldDeletedAt:
  26489. m.ResetDeletedAt()
  26490. return nil
  26491. case sopnode.FieldStageID:
  26492. m.ResetStageID()
  26493. return nil
  26494. case sopnode.FieldParentID:
  26495. m.ResetParentID()
  26496. return nil
  26497. case sopnode.FieldName:
  26498. m.ResetName()
  26499. return nil
  26500. case sopnode.FieldConditionType:
  26501. m.ResetConditionType()
  26502. return nil
  26503. case sopnode.FieldConditionList:
  26504. m.ResetConditionList()
  26505. return nil
  26506. case sopnode.FieldNoReplyCondition:
  26507. m.ResetNoReplyCondition()
  26508. return nil
  26509. case sopnode.FieldNoReplyUnit:
  26510. m.ResetNoReplyUnit()
  26511. return nil
  26512. case sopnode.FieldActionMessage:
  26513. m.ResetActionMessage()
  26514. return nil
  26515. case sopnode.FieldActionLabelAdd:
  26516. m.ResetActionLabelAdd()
  26517. return nil
  26518. case sopnode.FieldActionLabelDel:
  26519. m.ResetActionLabelDel()
  26520. return nil
  26521. case sopnode.FieldActionForward:
  26522. m.ResetActionForward()
  26523. return nil
  26524. }
  26525. return fmt.Errorf("unknown SopNode field %s", name)
  26526. }
  26527. // AddedEdges returns all edge names that were set/added in this mutation.
  26528. func (m *SopNodeMutation) AddedEdges() []string {
  26529. edges := make([]string, 0, 2)
  26530. if m.sop_stage != nil {
  26531. edges = append(edges, sopnode.EdgeSopStage)
  26532. }
  26533. if m.node_messages != nil {
  26534. edges = append(edges, sopnode.EdgeNodeMessages)
  26535. }
  26536. return edges
  26537. }
  26538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26539. // name in this mutation.
  26540. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  26541. switch name {
  26542. case sopnode.EdgeSopStage:
  26543. if id := m.sop_stage; id != nil {
  26544. return []ent.Value{*id}
  26545. }
  26546. case sopnode.EdgeNodeMessages:
  26547. ids := make([]ent.Value, 0, len(m.node_messages))
  26548. for id := range m.node_messages {
  26549. ids = append(ids, id)
  26550. }
  26551. return ids
  26552. }
  26553. return nil
  26554. }
  26555. // RemovedEdges returns all edge names that were removed in this mutation.
  26556. func (m *SopNodeMutation) RemovedEdges() []string {
  26557. edges := make([]string, 0, 2)
  26558. if m.removednode_messages != nil {
  26559. edges = append(edges, sopnode.EdgeNodeMessages)
  26560. }
  26561. return edges
  26562. }
  26563. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26564. // the given name in this mutation.
  26565. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  26566. switch name {
  26567. case sopnode.EdgeNodeMessages:
  26568. ids := make([]ent.Value, 0, len(m.removednode_messages))
  26569. for id := range m.removednode_messages {
  26570. ids = append(ids, id)
  26571. }
  26572. return ids
  26573. }
  26574. return nil
  26575. }
  26576. // ClearedEdges returns all edge names that were cleared in this mutation.
  26577. func (m *SopNodeMutation) ClearedEdges() []string {
  26578. edges := make([]string, 0, 2)
  26579. if m.clearedsop_stage {
  26580. edges = append(edges, sopnode.EdgeSopStage)
  26581. }
  26582. if m.clearednode_messages {
  26583. edges = append(edges, sopnode.EdgeNodeMessages)
  26584. }
  26585. return edges
  26586. }
  26587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26588. // was cleared in this mutation.
  26589. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  26590. switch name {
  26591. case sopnode.EdgeSopStage:
  26592. return m.clearedsop_stage
  26593. case sopnode.EdgeNodeMessages:
  26594. return m.clearednode_messages
  26595. }
  26596. return false
  26597. }
  26598. // ClearEdge clears the value of the edge with the given name. It returns an error
  26599. // if that edge is not defined in the schema.
  26600. func (m *SopNodeMutation) ClearEdge(name string) error {
  26601. switch name {
  26602. case sopnode.EdgeSopStage:
  26603. m.ClearSopStage()
  26604. return nil
  26605. }
  26606. return fmt.Errorf("unknown SopNode unique edge %s", name)
  26607. }
  26608. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26609. // It returns an error if the edge is not defined in the schema.
  26610. func (m *SopNodeMutation) ResetEdge(name string) error {
  26611. switch name {
  26612. case sopnode.EdgeSopStage:
  26613. m.ResetSopStage()
  26614. return nil
  26615. case sopnode.EdgeNodeMessages:
  26616. m.ResetNodeMessages()
  26617. return nil
  26618. }
  26619. return fmt.Errorf("unknown SopNode edge %s", name)
  26620. }
  26621. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  26622. type SopStageMutation struct {
  26623. config
  26624. op Op
  26625. typ string
  26626. id *uint64
  26627. created_at *time.Time
  26628. updated_at *time.Time
  26629. status *uint8
  26630. addstatus *int8
  26631. deleted_at *time.Time
  26632. name *string
  26633. condition_type *int
  26634. addcondition_type *int
  26635. condition_operator *int
  26636. addcondition_operator *int
  26637. condition_list *[]custom_types.Condition
  26638. appendcondition_list []custom_types.Condition
  26639. action_message *[]custom_types.Action
  26640. appendaction_message []custom_types.Action
  26641. action_label_add *[]uint64
  26642. appendaction_label_add []uint64
  26643. action_label_del *[]uint64
  26644. appendaction_label_del []uint64
  26645. action_forward **custom_types.ActionForward
  26646. index_sort *int
  26647. addindex_sort *int
  26648. clearedFields map[string]struct{}
  26649. sop_task *uint64
  26650. clearedsop_task bool
  26651. stage_nodes map[uint64]struct{}
  26652. removedstage_nodes map[uint64]struct{}
  26653. clearedstage_nodes bool
  26654. stage_messages map[uint64]struct{}
  26655. removedstage_messages map[uint64]struct{}
  26656. clearedstage_messages bool
  26657. done bool
  26658. oldValue func(context.Context) (*SopStage, error)
  26659. predicates []predicate.SopStage
  26660. }
  26661. var _ ent.Mutation = (*SopStageMutation)(nil)
  26662. // sopstageOption allows management of the mutation configuration using functional options.
  26663. type sopstageOption func(*SopStageMutation)
  26664. // newSopStageMutation creates new mutation for the SopStage entity.
  26665. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  26666. m := &SopStageMutation{
  26667. config: c,
  26668. op: op,
  26669. typ: TypeSopStage,
  26670. clearedFields: make(map[string]struct{}),
  26671. }
  26672. for _, opt := range opts {
  26673. opt(m)
  26674. }
  26675. return m
  26676. }
  26677. // withSopStageID sets the ID field of the mutation.
  26678. func withSopStageID(id uint64) sopstageOption {
  26679. return func(m *SopStageMutation) {
  26680. var (
  26681. err error
  26682. once sync.Once
  26683. value *SopStage
  26684. )
  26685. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  26686. once.Do(func() {
  26687. if m.done {
  26688. err = errors.New("querying old values post mutation is not allowed")
  26689. } else {
  26690. value, err = m.Client().SopStage.Get(ctx, id)
  26691. }
  26692. })
  26693. return value, err
  26694. }
  26695. m.id = &id
  26696. }
  26697. }
  26698. // withSopStage sets the old SopStage of the mutation.
  26699. func withSopStage(node *SopStage) sopstageOption {
  26700. return func(m *SopStageMutation) {
  26701. m.oldValue = func(context.Context) (*SopStage, error) {
  26702. return node, nil
  26703. }
  26704. m.id = &node.ID
  26705. }
  26706. }
  26707. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26708. // executed in a transaction (ent.Tx), a transactional client is returned.
  26709. func (m SopStageMutation) Client() *Client {
  26710. client := &Client{config: m.config}
  26711. client.init()
  26712. return client
  26713. }
  26714. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26715. // it returns an error otherwise.
  26716. func (m SopStageMutation) Tx() (*Tx, error) {
  26717. if _, ok := m.driver.(*txDriver); !ok {
  26718. return nil, errors.New("ent: mutation is not running in a transaction")
  26719. }
  26720. tx := &Tx{config: m.config}
  26721. tx.init()
  26722. return tx, nil
  26723. }
  26724. // SetID sets the value of the id field. Note that this
  26725. // operation is only accepted on creation of SopStage entities.
  26726. func (m *SopStageMutation) SetID(id uint64) {
  26727. m.id = &id
  26728. }
  26729. // ID returns the ID value in the mutation. Note that the ID is only available
  26730. // if it was provided to the builder or after it was returned from the database.
  26731. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  26732. if m.id == nil {
  26733. return
  26734. }
  26735. return *m.id, true
  26736. }
  26737. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26738. // That means, if the mutation is applied within a transaction with an isolation level such
  26739. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26740. // or updated by the mutation.
  26741. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  26742. switch {
  26743. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26744. id, exists := m.ID()
  26745. if exists {
  26746. return []uint64{id}, nil
  26747. }
  26748. fallthrough
  26749. case m.op.Is(OpUpdate | OpDelete):
  26750. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  26751. default:
  26752. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26753. }
  26754. }
  26755. // SetCreatedAt sets the "created_at" field.
  26756. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  26757. m.created_at = &t
  26758. }
  26759. // CreatedAt returns the value of the "created_at" field in the mutation.
  26760. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  26761. v := m.created_at
  26762. if v == nil {
  26763. return
  26764. }
  26765. return *v, true
  26766. }
  26767. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  26768. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26770. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26771. if !m.op.Is(OpUpdateOne) {
  26772. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26773. }
  26774. if m.id == nil || m.oldValue == nil {
  26775. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26776. }
  26777. oldValue, err := m.oldValue(ctx)
  26778. if err != nil {
  26779. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26780. }
  26781. return oldValue.CreatedAt, nil
  26782. }
  26783. // ResetCreatedAt resets all changes to the "created_at" field.
  26784. func (m *SopStageMutation) ResetCreatedAt() {
  26785. m.created_at = nil
  26786. }
  26787. // SetUpdatedAt sets the "updated_at" field.
  26788. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  26789. m.updated_at = &t
  26790. }
  26791. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26792. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  26793. v := m.updated_at
  26794. if v == nil {
  26795. return
  26796. }
  26797. return *v, true
  26798. }
  26799. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  26800. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26802. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26803. if !m.op.Is(OpUpdateOne) {
  26804. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26805. }
  26806. if m.id == nil || m.oldValue == nil {
  26807. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26808. }
  26809. oldValue, err := m.oldValue(ctx)
  26810. if err != nil {
  26811. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26812. }
  26813. return oldValue.UpdatedAt, nil
  26814. }
  26815. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26816. func (m *SopStageMutation) ResetUpdatedAt() {
  26817. m.updated_at = nil
  26818. }
  26819. // SetStatus sets the "status" field.
  26820. func (m *SopStageMutation) SetStatus(u uint8) {
  26821. m.status = &u
  26822. m.addstatus = nil
  26823. }
  26824. // Status returns the value of the "status" field in the mutation.
  26825. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  26826. v := m.status
  26827. if v == nil {
  26828. return
  26829. }
  26830. return *v, true
  26831. }
  26832. // OldStatus returns the old "status" field's value of the SopStage entity.
  26833. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26835. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26836. if !m.op.Is(OpUpdateOne) {
  26837. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26838. }
  26839. if m.id == nil || m.oldValue == nil {
  26840. return v, errors.New("OldStatus requires an ID field in the mutation")
  26841. }
  26842. oldValue, err := m.oldValue(ctx)
  26843. if err != nil {
  26844. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26845. }
  26846. return oldValue.Status, nil
  26847. }
  26848. // AddStatus adds u to the "status" field.
  26849. func (m *SopStageMutation) AddStatus(u int8) {
  26850. if m.addstatus != nil {
  26851. *m.addstatus += u
  26852. } else {
  26853. m.addstatus = &u
  26854. }
  26855. }
  26856. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26857. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  26858. v := m.addstatus
  26859. if v == nil {
  26860. return
  26861. }
  26862. return *v, true
  26863. }
  26864. // ClearStatus clears the value of the "status" field.
  26865. func (m *SopStageMutation) ClearStatus() {
  26866. m.status = nil
  26867. m.addstatus = nil
  26868. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  26869. }
  26870. // StatusCleared returns if the "status" field was cleared in this mutation.
  26871. func (m *SopStageMutation) StatusCleared() bool {
  26872. _, ok := m.clearedFields[sopstage.FieldStatus]
  26873. return ok
  26874. }
  26875. // ResetStatus resets all changes to the "status" field.
  26876. func (m *SopStageMutation) ResetStatus() {
  26877. m.status = nil
  26878. m.addstatus = nil
  26879. delete(m.clearedFields, sopstage.FieldStatus)
  26880. }
  26881. // SetDeletedAt sets the "deleted_at" field.
  26882. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  26883. m.deleted_at = &t
  26884. }
  26885. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26886. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  26887. v := m.deleted_at
  26888. if v == nil {
  26889. return
  26890. }
  26891. return *v, true
  26892. }
  26893. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  26894. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26896. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26897. if !m.op.Is(OpUpdateOne) {
  26898. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26899. }
  26900. if m.id == nil || m.oldValue == nil {
  26901. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26902. }
  26903. oldValue, err := m.oldValue(ctx)
  26904. if err != nil {
  26905. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26906. }
  26907. return oldValue.DeletedAt, nil
  26908. }
  26909. // ClearDeletedAt clears the value of the "deleted_at" field.
  26910. func (m *SopStageMutation) ClearDeletedAt() {
  26911. m.deleted_at = nil
  26912. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  26913. }
  26914. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26915. func (m *SopStageMutation) DeletedAtCleared() bool {
  26916. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  26917. return ok
  26918. }
  26919. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26920. func (m *SopStageMutation) ResetDeletedAt() {
  26921. m.deleted_at = nil
  26922. delete(m.clearedFields, sopstage.FieldDeletedAt)
  26923. }
  26924. // SetTaskID sets the "task_id" field.
  26925. func (m *SopStageMutation) SetTaskID(u uint64) {
  26926. m.sop_task = &u
  26927. }
  26928. // TaskID returns the value of the "task_id" field in the mutation.
  26929. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  26930. v := m.sop_task
  26931. if v == nil {
  26932. return
  26933. }
  26934. return *v, true
  26935. }
  26936. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  26937. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26939. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  26940. if !m.op.Is(OpUpdateOne) {
  26941. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  26942. }
  26943. if m.id == nil || m.oldValue == nil {
  26944. return v, errors.New("OldTaskID requires an ID field in the mutation")
  26945. }
  26946. oldValue, err := m.oldValue(ctx)
  26947. if err != nil {
  26948. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  26949. }
  26950. return oldValue.TaskID, nil
  26951. }
  26952. // ResetTaskID resets all changes to the "task_id" field.
  26953. func (m *SopStageMutation) ResetTaskID() {
  26954. m.sop_task = nil
  26955. }
  26956. // SetName sets the "name" field.
  26957. func (m *SopStageMutation) SetName(s string) {
  26958. m.name = &s
  26959. }
  26960. // Name returns the value of the "name" field in the mutation.
  26961. func (m *SopStageMutation) Name() (r string, exists bool) {
  26962. v := m.name
  26963. if v == nil {
  26964. return
  26965. }
  26966. return *v, true
  26967. }
  26968. // OldName returns the old "name" field's value of the SopStage entity.
  26969. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26971. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  26972. if !m.op.Is(OpUpdateOne) {
  26973. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26974. }
  26975. if m.id == nil || m.oldValue == nil {
  26976. return v, errors.New("OldName requires an ID field in the mutation")
  26977. }
  26978. oldValue, err := m.oldValue(ctx)
  26979. if err != nil {
  26980. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26981. }
  26982. return oldValue.Name, nil
  26983. }
  26984. // ResetName resets all changes to the "name" field.
  26985. func (m *SopStageMutation) ResetName() {
  26986. m.name = nil
  26987. }
  26988. // SetConditionType sets the "condition_type" field.
  26989. func (m *SopStageMutation) SetConditionType(i int) {
  26990. m.condition_type = &i
  26991. m.addcondition_type = nil
  26992. }
  26993. // ConditionType returns the value of the "condition_type" field in the mutation.
  26994. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  26995. v := m.condition_type
  26996. if v == nil {
  26997. return
  26998. }
  26999. return *v, true
  27000. }
  27001. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  27002. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27004. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  27005. if !m.op.Is(OpUpdateOne) {
  27006. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  27007. }
  27008. if m.id == nil || m.oldValue == nil {
  27009. return v, errors.New("OldConditionType requires an ID field in the mutation")
  27010. }
  27011. oldValue, err := m.oldValue(ctx)
  27012. if err != nil {
  27013. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  27014. }
  27015. return oldValue.ConditionType, nil
  27016. }
  27017. // AddConditionType adds i to the "condition_type" field.
  27018. func (m *SopStageMutation) AddConditionType(i int) {
  27019. if m.addcondition_type != nil {
  27020. *m.addcondition_type += i
  27021. } else {
  27022. m.addcondition_type = &i
  27023. }
  27024. }
  27025. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  27026. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  27027. v := m.addcondition_type
  27028. if v == nil {
  27029. return
  27030. }
  27031. return *v, true
  27032. }
  27033. // ResetConditionType resets all changes to the "condition_type" field.
  27034. func (m *SopStageMutation) ResetConditionType() {
  27035. m.condition_type = nil
  27036. m.addcondition_type = nil
  27037. }
  27038. // SetConditionOperator sets the "condition_operator" field.
  27039. func (m *SopStageMutation) SetConditionOperator(i int) {
  27040. m.condition_operator = &i
  27041. m.addcondition_operator = nil
  27042. }
  27043. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  27044. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  27045. v := m.condition_operator
  27046. if v == nil {
  27047. return
  27048. }
  27049. return *v, true
  27050. }
  27051. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  27052. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27054. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  27055. if !m.op.Is(OpUpdateOne) {
  27056. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  27057. }
  27058. if m.id == nil || m.oldValue == nil {
  27059. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  27060. }
  27061. oldValue, err := m.oldValue(ctx)
  27062. if err != nil {
  27063. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  27064. }
  27065. return oldValue.ConditionOperator, nil
  27066. }
  27067. // AddConditionOperator adds i to the "condition_operator" field.
  27068. func (m *SopStageMutation) AddConditionOperator(i int) {
  27069. if m.addcondition_operator != nil {
  27070. *m.addcondition_operator += i
  27071. } else {
  27072. m.addcondition_operator = &i
  27073. }
  27074. }
  27075. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  27076. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  27077. v := m.addcondition_operator
  27078. if v == nil {
  27079. return
  27080. }
  27081. return *v, true
  27082. }
  27083. // ResetConditionOperator resets all changes to the "condition_operator" field.
  27084. func (m *SopStageMutation) ResetConditionOperator() {
  27085. m.condition_operator = nil
  27086. m.addcondition_operator = nil
  27087. }
  27088. // SetConditionList sets the "condition_list" field.
  27089. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  27090. m.condition_list = &ct
  27091. m.appendcondition_list = nil
  27092. }
  27093. // ConditionList returns the value of the "condition_list" field in the mutation.
  27094. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  27095. v := m.condition_list
  27096. if v == nil {
  27097. return
  27098. }
  27099. return *v, true
  27100. }
  27101. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  27102. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27104. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  27105. if !m.op.Is(OpUpdateOne) {
  27106. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  27107. }
  27108. if m.id == nil || m.oldValue == nil {
  27109. return v, errors.New("OldConditionList requires an ID field in the mutation")
  27110. }
  27111. oldValue, err := m.oldValue(ctx)
  27112. if err != nil {
  27113. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27114. }
  27115. return oldValue.ConditionList, nil
  27116. }
  27117. // AppendConditionList adds ct to the "condition_list" field.
  27118. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  27119. m.appendcondition_list = append(m.appendcondition_list, ct...)
  27120. }
  27121. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27122. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  27123. if len(m.appendcondition_list) == 0 {
  27124. return nil, false
  27125. }
  27126. return m.appendcondition_list, true
  27127. }
  27128. // ResetConditionList resets all changes to the "condition_list" field.
  27129. func (m *SopStageMutation) ResetConditionList() {
  27130. m.condition_list = nil
  27131. m.appendcondition_list = nil
  27132. }
  27133. // SetActionMessage sets the "action_message" field.
  27134. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  27135. m.action_message = &ct
  27136. m.appendaction_message = nil
  27137. }
  27138. // ActionMessage returns the value of the "action_message" field in the mutation.
  27139. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27140. v := m.action_message
  27141. if v == nil {
  27142. return
  27143. }
  27144. return *v, true
  27145. }
  27146. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  27147. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27149. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  27150. if !m.op.Is(OpUpdateOne) {
  27151. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  27152. }
  27153. if m.id == nil || m.oldValue == nil {
  27154. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  27155. }
  27156. oldValue, err := m.oldValue(ctx)
  27157. if err != nil {
  27158. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  27159. }
  27160. return oldValue.ActionMessage, nil
  27161. }
  27162. // AppendActionMessage adds ct to the "action_message" field.
  27163. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  27164. m.appendaction_message = append(m.appendaction_message, ct...)
  27165. }
  27166. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  27167. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  27168. if len(m.appendaction_message) == 0 {
  27169. return nil, false
  27170. }
  27171. return m.appendaction_message, true
  27172. }
  27173. // ClearActionMessage clears the value of the "action_message" field.
  27174. func (m *SopStageMutation) ClearActionMessage() {
  27175. m.action_message = nil
  27176. m.appendaction_message = nil
  27177. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  27178. }
  27179. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  27180. func (m *SopStageMutation) ActionMessageCleared() bool {
  27181. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  27182. return ok
  27183. }
  27184. // ResetActionMessage resets all changes to the "action_message" field.
  27185. func (m *SopStageMutation) ResetActionMessage() {
  27186. m.action_message = nil
  27187. m.appendaction_message = nil
  27188. delete(m.clearedFields, sopstage.FieldActionMessage)
  27189. }
  27190. // SetActionLabelAdd sets the "action_label_add" field.
  27191. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  27192. m.action_label_add = &u
  27193. m.appendaction_label_add = nil
  27194. }
  27195. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  27196. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  27197. v := m.action_label_add
  27198. if v == nil {
  27199. return
  27200. }
  27201. return *v, true
  27202. }
  27203. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  27204. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27206. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  27207. if !m.op.Is(OpUpdateOne) {
  27208. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  27209. }
  27210. if m.id == nil || m.oldValue == nil {
  27211. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  27212. }
  27213. oldValue, err := m.oldValue(ctx)
  27214. if err != nil {
  27215. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  27216. }
  27217. return oldValue.ActionLabelAdd, nil
  27218. }
  27219. // AppendActionLabelAdd adds u to the "action_label_add" field.
  27220. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  27221. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  27222. }
  27223. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  27224. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  27225. if len(m.appendaction_label_add) == 0 {
  27226. return nil, false
  27227. }
  27228. return m.appendaction_label_add, true
  27229. }
  27230. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  27231. func (m *SopStageMutation) ClearActionLabelAdd() {
  27232. m.action_label_add = nil
  27233. m.appendaction_label_add = nil
  27234. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  27235. }
  27236. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  27237. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  27238. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  27239. return ok
  27240. }
  27241. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  27242. func (m *SopStageMutation) ResetActionLabelAdd() {
  27243. m.action_label_add = nil
  27244. m.appendaction_label_add = nil
  27245. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  27246. }
  27247. // SetActionLabelDel sets the "action_label_del" field.
  27248. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  27249. m.action_label_del = &u
  27250. m.appendaction_label_del = nil
  27251. }
  27252. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  27253. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  27254. v := m.action_label_del
  27255. if v == nil {
  27256. return
  27257. }
  27258. return *v, true
  27259. }
  27260. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  27261. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27263. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  27264. if !m.op.Is(OpUpdateOne) {
  27265. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  27266. }
  27267. if m.id == nil || m.oldValue == nil {
  27268. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  27269. }
  27270. oldValue, err := m.oldValue(ctx)
  27271. if err != nil {
  27272. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  27273. }
  27274. return oldValue.ActionLabelDel, nil
  27275. }
  27276. // AppendActionLabelDel adds u to the "action_label_del" field.
  27277. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  27278. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  27279. }
  27280. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  27281. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  27282. if len(m.appendaction_label_del) == 0 {
  27283. return nil, false
  27284. }
  27285. return m.appendaction_label_del, true
  27286. }
  27287. // ClearActionLabelDel clears the value of the "action_label_del" field.
  27288. func (m *SopStageMutation) ClearActionLabelDel() {
  27289. m.action_label_del = nil
  27290. m.appendaction_label_del = nil
  27291. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  27292. }
  27293. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  27294. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  27295. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  27296. return ok
  27297. }
  27298. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  27299. func (m *SopStageMutation) ResetActionLabelDel() {
  27300. m.action_label_del = nil
  27301. m.appendaction_label_del = nil
  27302. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  27303. }
  27304. // SetActionForward sets the "action_forward" field.
  27305. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  27306. m.action_forward = &ctf
  27307. }
  27308. // ActionForward returns the value of the "action_forward" field in the mutation.
  27309. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  27310. v := m.action_forward
  27311. if v == nil {
  27312. return
  27313. }
  27314. return *v, true
  27315. }
  27316. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  27317. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27319. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  27320. if !m.op.Is(OpUpdateOne) {
  27321. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  27322. }
  27323. if m.id == nil || m.oldValue == nil {
  27324. return v, errors.New("OldActionForward requires an ID field in the mutation")
  27325. }
  27326. oldValue, err := m.oldValue(ctx)
  27327. if err != nil {
  27328. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  27329. }
  27330. return oldValue.ActionForward, nil
  27331. }
  27332. // ClearActionForward clears the value of the "action_forward" field.
  27333. func (m *SopStageMutation) ClearActionForward() {
  27334. m.action_forward = nil
  27335. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  27336. }
  27337. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  27338. func (m *SopStageMutation) ActionForwardCleared() bool {
  27339. _, ok := m.clearedFields[sopstage.FieldActionForward]
  27340. return ok
  27341. }
  27342. // ResetActionForward resets all changes to the "action_forward" field.
  27343. func (m *SopStageMutation) ResetActionForward() {
  27344. m.action_forward = nil
  27345. delete(m.clearedFields, sopstage.FieldActionForward)
  27346. }
  27347. // SetIndexSort sets the "index_sort" field.
  27348. func (m *SopStageMutation) SetIndexSort(i int) {
  27349. m.index_sort = &i
  27350. m.addindex_sort = nil
  27351. }
  27352. // IndexSort returns the value of the "index_sort" field in the mutation.
  27353. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  27354. v := m.index_sort
  27355. if v == nil {
  27356. return
  27357. }
  27358. return *v, true
  27359. }
  27360. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  27361. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27363. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  27364. if !m.op.Is(OpUpdateOne) {
  27365. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  27366. }
  27367. if m.id == nil || m.oldValue == nil {
  27368. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  27369. }
  27370. oldValue, err := m.oldValue(ctx)
  27371. if err != nil {
  27372. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  27373. }
  27374. return oldValue.IndexSort, nil
  27375. }
  27376. // AddIndexSort adds i to the "index_sort" field.
  27377. func (m *SopStageMutation) AddIndexSort(i int) {
  27378. if m.addindex_sort != nil {
  27379. *m.addindex_sort += i
  27380. } else {
  27381. m.addindex_sort = &i
  27382. }
  27383. }
  27384. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  27385. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  27386. v := m.addindex_sort
  27387. if v == nil {
  27388. return
  27389. }
  27390. return *v, true
  27391. }
  27392. // ClearIndexSort clears the value of the "index_sort" field.
  27393. func (m *SopStageMutation) ClearIndexSort() {
  27394. m.index_sort = nil
  27395. m.addindex_sort = nil
  27396. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  27397. }
  27398. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  27399. func (m *SopStageMutation) IndexSortCleared() bool {
  27400. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  27401. return ok
  27402. }
  27403. // ResetIndexSort resets all changes to the "index_sort" field.
  27404. func (m *SopStageMutation) ResetIndexSort() {
  27405. m.index_sort = nil
  27406. m.addindex_sort = nil
  27407. delete(m.clearedFields, sopstage.FieldIndexSort)
  27408. }
  27409. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  27410. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  27411. m.sop_task = &id
  27412. }
  27413. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  27414. func (m *SopStageMutation) ClearSopTask() {
  27415. m.clearedsop_task = true
  27416. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  27417. }
  27418. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  27419. func (m *SopStageMutation) SopTaskCleared() bool {
  27420. return m.clearedsop_task
  27421. }
  27422. // SopTaskID returns the "sop_task" edge ID in the mutation.
  27423. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  27424. if m.sop_task != nil {
  27425. return *m.sop_task, true
  27426. }
  27427. return
  27428. }
  27429. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  27430. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27431. // SopTaskID instead. It exists only for internal usage by the builders.
  27432. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  27433. if id := m.sop_task; id != nil {
  27434. ids = append(ids, *id)
  27435. }
  27436. return
  27437. }
  27438. // ResetSopTask resets all changes to the "sop_task" edge.
  27439. func (m *SopStageMutation) ResetSopTask() {
  27440. m.sop_task = nil
  27441. m.clearedsop_task = false
  27442. }
  27443. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  27444. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  27445. if m.stage_nodes == nil {
  27446. m.stage_nodes = make(map[uint64]struct{})
  27447. }
  27448. for i := range ids {
  27449. m.stage_nodes[ids[i]] = struct{}{}
  27450. }
  27451. }
  27452. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  27453. func (m *SopStageMutation) ClearStageNodes() {
  27454. m.clearedstage_nodes = true
  27455. }
  27456. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  27457. func (m *SopStageMutation) StageNodesCleared() bool {
  27458. return m.clearedstage_nodes
  27459. }
  27460. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  27461. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  27462. if m.removedstage_nodes == nil {
  27463. m.removedstage_nodes = make(map[uint64]struct{})
  27464. }
  27465. for i := range ids {
  27466. delete(m.stage_nodes, ids[i])
  27467. m.removedstage_nodes[ids[i]] = struct{}{}
  27468. }
  27469. }
  27470. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  27471. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  27472. for id := range m.removedstage_nodes {
  27473. ids = append(ids, id)
  27474. }
  27475. return
  27476. }
  27477. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  27478. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  27479. for id := range m.stage_nodes {
  27480. ids = append(ids, id)
  27481. }
  27482. return
  27483. }
  27484. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  27485. func (m *SopStageMutation) ResetStageNodes() {
  27486. m.stage_nodes = nil
  27487. m.clearedstage_nodes = false
  27488. m.removedstage_nodes = nil
  27489. }
  27490. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  27491. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  27492. if m.stage_messages == nil {
  27493. m.stage_messages = make(map[uint64]struct{})
  27494. }
  27495. for i := range ids {
  27496. m.stage_messages[ids[i]] = struct{}{}
  27497. }
  27498. }
  27499. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  27500. func (m *SopStageMutation) ClearStageMessages() {
  27501. m.clearedstage_messages = true
  27502. }
  27503. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  27504. func (m *SopStageMutation) StageMessagesCleared() bool {
  27505. return m.clearedstage_messages
  27506. }
  27507. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  27508. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  27509. if m.removedstage_messages == nil {
  27510. m.removedstage_messages = make(map[uint64]struct{})
  27511. }
  27512. for i := range ids {
  27513. delete(m.stage_messages, ids[i])
  27514. m.removedstage_messages[ids[i]] = struct{}{}
  27515. }
  27516. }
  27517. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  27518. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  27519. for id := range m.removedstage_messages {
  27520. ids = append(ids, id)
  27521. }
  27522. return
  27523. }
  27524. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  27525. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  27526. for id := range m.stage_messages {
  27527. ids = append(ids, id)
  27528. }
  27529. return
  27530. }
  27531. // ResetStageMessages resets all changes to the "stage_messages" edge.
  27532. func (m *SopStageMutation) ResetStageMessages() {
  27533. m.stage_messages = nil
  27534. m.clearedstage_messages = false
  27535. m.removedstage_messages = nil
  27536. }
  27537. // Where appends a list predicates to the SopStageMutation builder.
  27538. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  27539. m.predicates = append(m.predicates, ps...)
  27540. }
  27541. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  27542. // users can use type-assertion to append predicates that do not depend on any generated package.
  27543. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  27544. p := make([]predicate.SopStage, len(ps))
  27545. for i := range ps {
  27546. p[i] = ps[i]
  27547. }
  27548. m.Where(p...)
  27549. }
  27550. // Op returns the operation name.
  27551. func (m *SopStageMutation) Op() Op {
  27552. return m.op
  27553. }
  27554. // SetOp allows setting the mutation operation.
  27555. func (m *SopStageMutation) SetOp(op Op) {
  27556. m.op = op
  27557. }
  27558. // Type returns the node type of this mutation (SopStage).
  27559. func (m *SopStageMutation) Type() string {
  27560. return m.typ
  27561. }
  27562. // Fields returns all fields that were changed during this mutation. Note that in
  27563. // order to get all numeric fields that were incremented/decremented, call
  27564. // AddedFields().
  27565. func (m *SopStageMutation) Fields() []string {
  27566. fields := make([]string, 0, 14)
  27567. if m.created_at != nil {
  27568. fields = append(fields, sopstage.FieldCreatedAt)
  27569. }
  27570. if m.updated_at != nil {
  27571. fields = append(fields, sopstage.FieldUpdatedAt)
  27572. }
  27573. if m.status != nil {
  27574. fields = append(fields, sopstage.FieldStatus)
  27575. }
  27576. if m.deleted_at != nil {
  27577. fields = append(fields, sopstage.FieldDeletedAt)
  27578. }
  27579. if m.sop_task != nil {
  27580. fields = append(fields, sopstage.FieldTaskID)
  27581. }
  27582. if m.name != nil {
  27583. fields = append(fields, sopstage.FieldName)
  27584. }
  27585. if m.condition_type != nil {
  27586. fields = append(fields, sopstage.FieldConditionType)
  27587. }
  27588. if m.condition_operator != nil {
  27589. fields = append(fields, sopstage.FieldConditionOperator)
  27590. }
  27591. if m.condition_list != nil {
  27592. fields = append(fields, sopstage.FieldConditionList)
  27593. }
  27594. if m.action_message != nil {
  27595. fields = append(fields, sopstage.FieldActionMessage)
  27596. }
  27597. if m.action_label_add != nil {
  27598. fields = append(fields, sopstage.FieldActionLabelAdd)
  27599. }
  27600. if m.action_label_del != nil {
  27601. fields = append(fields, sopstage.FieldActionLabelDel)
  27602. }
  27603. if m.action_forward != nil {
  27604. fields = append(fields, sopstage.FieldActionForward)
  27605. }
  27606. if m.index_sort != nil {
  27607. fields = append(fields, sopstage.FieldIndexSort)
  27608. }
  27609. return fields
  27610. }
  27611. // Field returns the value of a field with the given name. The second boolean
  27612. // return value indicates that this field was not set, or was not defined in the
  27613. // schema.
  27614. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  27615. switch name {
  27616. case sopstage.FieldCreatedAt:
  27617. return m.CreatedAt()
  27618. case sopstage.FieldUpdatedAt:
  27619. return m.UpdatedAt()
  27620. case sopstage.FieldStatus:
  27621. return m.Status()
  27622. case sopstage.FieldDeletedAt:
  27623. return m.DeletedAt()
  27624. case sopstage.FieldTaskID:
  27625. return m.TaskID()
  27626. case sopstage.FieldName:
  27627. return m.Name()
  27628. case sopstage.FieldConditionType:
  27629. return m.ConditionType()
  27630. case sopstage.FieldConditionOperator:
  27631. return m.ConditionOperator()
  27632. case sopstage.FieldConditionList:
  27633. return m.ConditionList()
  27634. case sopstage.FieldActionMessage:
  27635. return m.ActionMessage()
  27636. case sopstage.FieldActionLabelAdd:
  27637. return m.ActionLabelAdd()
  27638. case sopstage.FieldActionLabelDel:
  27639. return m.ActionLabelDel()
  27640. case sopstage.FieldActionForward:
  27641. return m.ActionForward()
  27642. case sopstage.FieldIndexSort:
  27643. return m.IndexSort()
  27644. }
  27645. return nil, false
  27646. }
  27647. // OldField returns the old value of the field from the database. An error is
  27648. // returned if the mutation operation is not UpdateOne, or the query to the
  27649. // database failed.
  27650. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27651. switch name {
  27652. case sopstage.FieldCreatedAt:
  27653. return m.OldCreatedAt(ctx)
  27654. case sopstage.FieldUpdatedAt:
  27655. return m.OldUpdatedAt(ctx)
  27656. case sopstage.FieldStatus:
  27657. return m.OldStatus(ctx)
  27658. case sopstage.FieldDeletedAt:
  27659. return m.OldDeletedAt(ctx)
  27660. case sopstage.FieldTaskID:
  27661. return m.OldTaskID(ctx)
  27662. case sopstage.FieldName:
  27663. return m.OldName(ctx)
  27664. case sopstage.FieldConditionType:
  27665. return m.OldConditionType(ctx)
  27666. case sopstage.FieldConditionOperator:
  27667. return m.OldConditionOperator(ctx)
  27668. case sopstage.FieldConditionList:
  27669. return m.OldConditionList(ctx)
  27670. case sopstage.FieldActionMessage:
  27671. return m.OldActionMessage(ctx)
  27672. case sopstage.FieldActionLabelAdd:
  27673. return m.OldActionLabelAdd(ctx)
  27674. case sopstage.FieldActionLabelDel:
  27675. return m.OldActionLabelDel(ctx)
  27676. case sopstage.FieldActionForward:
  27677. return m.OldActionForward(ctx)
  27678. case sopstage.FieldIndexSort:
  27679. return m.OldIndexSort(ctx)
  27680. }
  27681. return nil, fmt.Errorf("unknown SopStage field %s", name)
  27682. }
  27683. // SetField sets the value of a field with the given name. It returns an error if
  27684. // the field is not defined in the schema, or if the type mismatched the field
  27685. // type.
  27686. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  27687. switch name {
  27688. case sopstage.FieldCreatedAt:
  27689. v, ok := value.(time.Time)
  27690. if !ok {
  27691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27692. }
  27693. m.SetCreatedAt(v)
  27694. return nil
  27695. case sopstage.FieldUpdatedAt:
  27696. v, ok := value.(time.Time)
  27697. if !ok {
  27698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27699. }
  27700. m.SetUpdatedAt(v)
  27701. return nil
  27702. case sopstage.FieldStatus:
  27703. v, ok := value.(uint8)
  27704. if !ok {
  27705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27706. }
  27707. m.SetStatus(v)
  27708. return nil
  27709. case sopstage.FieldDeletedAt:
  27710. v, ok := value.(time.Time)
  27711. if !ok {
  27712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27713. }
  27714. m.SetDeletedAt(v)
  27715. return nil
  27716. case sopstage.FieldTaskID:
  27717. v, ok := value.(uint64)
  27718. if !ok {
  27719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27720. }
  27721. m.SetTaskID(v)
  27722. return nil
  27723. case sopstage.FieldName:
  27724. v, ok := value.(string)
  27725. if !ok {
  27726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27727. }
  27728. m.SetName(v)
  27729. return nil
  27730. case sopstage.FieldConditionType:
  27731. v, ok := value.(int)
  27732. if !ok {
  27733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27734. }
  27735. m.SetConditionType(v)
  27736. return nil
  27737. case sopstage.FieldConditionOperator:
  27738. v, ok := value.(int)
  27739. if !ok {
  27740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27741. }
  27742. m.SetConditionOperator(v)
  27743. return nil
  27744. case sopstage.FieldConditionList:
  27745. v, ok := value.([]custom_types.Condition)
  27746. if !ok {
  27747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27748. }
  27749. m.SetConditionList(v)
  27750. return nil
  27751. case sopstage.FieldActionMessage:
  27752. v, ok := value.([]custom_types.Action)
  27753. if !ok {
  27754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27755. }
  27756. m.SetActionMessage(v)
  27757. return nil
  27758. case sopstage.FieldActionLabelAdd:
  27759. v, ok := value.([]uint64)
  27760. if !ok {
  27761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27762. }
  27763. m.SetActionLabelAdd(v)
  27764. return nil
  27765. case sopstage.FieldActionLabelDel:
  27766. v, ok := value.([]uint64)
  27767. if !ok {
  27768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27769. }
  27770. m.SetActionLabelDel(v)
  27771. return nil
  27772. case sopstage.FieldActionForward:
  27773. v, ok := value.(*custom_types.ActionForward)
  27774. if !ok {
  27775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27776. }
  27777. m.SetActionForward(v)
  27778. return nil
  27779. case sopstage.FieldIndexSort:
  27780. v, ok := value.(int)
  27781. if !ok {
  27782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27783. }
  27784. m.SetIndexSort(v)
  27785. return nil
  27786. }
  27787. return fmt.Errorf("unknown SopStage field %s", name)
  27788. }
  27789. // AddedFields returns all numeric fields that were incremented/decremented during
  27790. // this mutation.
  27791. func (m *SopStageMutation) AddedFields() []string {
  27792. var fields []string
  27793. if m.addstatus != nil {
  27794. fields = append(fields, sopstage.FieldStatus)
  27795. }
  27796. if m.addcondition_type != nil {
  27797. fields = append(fields, sopstage.FieldConditionType)
  27798. }
  27799. if m.addcondition_operator != nil {
  27800. fields = append(fields, sopstage.FieldConditionOperator)
  27801. }
  27802. if m.addindex_sort != nil {
  27803. fields = append(fields, sopstage.FieldIndexSort)
  27804. }
  27805. return fields
  27806. }
  27807. // AddedField returns the numeric value that was incremented/decremented on a field
  27808. // with the given name. The second boolean return value indicates that this field
  27809. // was not set, or was not defined in the schema.
  27810. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  27811. switch name {
  27812. case sopstage.FieldStatus:
  27813. return m.AddedStatus()
  27814. case sopstage.FieldConditionType:
  27815. return m.AddedConditionType()
  27816. case sopstage.FieldConditionOperator:
  27817. return m.AddedConditionOperator()
  27818. case sopstage.FieldIndexSort:
  27819. return m.AddedIndexSort()
  27820. }
  27821. return nil, false
  27822. }
  27823. // AddField adds the value to the field with the given name. It returns an error if
  27824. // the field is not defined in the schema, or if the type mismatched the field
  27825. // type.
  27826. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  27827. switch name {
  27828. case sopstage.FieldStatus:
  27829. v, ok := value.(int8)
  27830. if !ok {
  27831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27832. }
  27833. m.AddStatus(v)
  27834. return nil
  27835. case sopstage.FieldConditionType:
  27836. v, ok := value.(int)
  27837. if !ok {
  27838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27839. }
  27840. m.AddConditionType(v)
  27841. return nil
  27842. case sopstage.FieldConditionOperator:
  27843. v, ok := value.(int)
  27844. if !ok {
  27845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27846. }
  27847. m.AddConditionOperator(v)
  27848. return nil
  27849. case sopstage.FieldIndexSort:
  27850. v, ok := value.(int)
  27851. if !ok {
  27852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27853. }
  27854. m.AddIndexSort(v)
  27855. return nil
  27856. }
  27857. return fmt.Errorf("unknown SopStage numeric field %s", name)
  27858. }
  27859. // ClearedFields returns all nullable fields that were cleared during this
  27860. // mutation.
  27861. func (m *SopStageMutation) ClearedFields() []string {
  27862. var fields []string
  27863. if m.FieldCleared(sopstage.FieldStatus) {
  27864. fields = append(fields, sopstage.FieldStatus)
  27865. }
  27866. if m.FieldCleared(sopstage.FieldDeletedAt) {
  27867. fields = append(fields, sopstage.FieldDeletedAt)
  27868. }
  27869. if m.FieldCleared(sopstage.FieldActionMessage) {
  27870. fields = append(fields, sopstage.FieldActionMessage)
  27871. }
  27872. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  27873. fields = append(fields, sopstage.FieldActionLabelAdd)
  27874. }
  27875. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  27876. fields = append(fields, sopstage.FieldActionLabelDel)
  27877. }
  27878. if m.FieldCleared(sopstage.FieldActionForward) {
  27879. fields = append(fields, sopstage.FieldActionForward)
  27880. }
  27881. if m.FieldCleared(sopstage.FieldIndexSort) {
  27882. fields = append(fields, sopstage.FieldIndexSort)
  27883. }
  27884. return fields
  27885. }
  27886. // FieldCleared returns a boolean indicating if a field with the given name was
  27887. // cleared in this mutation.
  27888. func (m *SopStageMutation) FieldCleared(name string) bool {
  27889. _, ok := m.clearedFields[name]
  27890. return ok
  27891. }
  27892. // ClearField clears the value of the field with the given name. It returns an
  27893. // error if the field is not defined in the schema.
  27894. func (m *SopStageMutation) ClearField(name string) error {
  27895. switch name {
  27896. case sopstage.FieldStatus:
  27897. m.ClearStatus()
  27898. return nil
  27899. case sopstage.FieldDeletedAt:
  27900. m.ClearDeletedAt()
  27901. return nil
  27902. case sopstage.FieldActionMessage:
  27903. m.ClearActionMessage()
  27904. return nil
  27905. case sopstage.FieldActionLabelAdd:
  27906. m.ClearActionLabelAdd()
  27907. return nil
  27908. case sopstage.FieldActionLabelDel:
  27909. m.ClearActionLabelDel()
  27910. return nil
  27911. case sopstage.FieldActionForward:
  27912. m.ClearActionForward()
  27913. return nil
  27914. case sopstage.FieldIndexSort:
  27915. m.ClearIndexSort()
  27916. return nil
  27917. }
  27918. return fmt.Errorf("unknown SopStage nullable field %s", name)
  27919. }
  27920. // ResetField resets all changes in the mutation for the field with the given name.
  27921. // It returns an error if the field is not defined in the schema.
  27922. func (m *SopStageMutation) ResetField(name string) error {
  27923. switch name {
  27924. case sopstage.FieldCreatedAt:
  27925. m.ResetCreatedAt()
  27926. return nil
  27927. case sopstage.FieldUpdatedAt:
  27928. m.ResetUpdatedAt()
  27929. return nil
  27930. case sopstage.FieldStatus:
  27931. m.ResetStatus()
  27932. return nil
  27933. case sopstage.FieldDeletedAt:
  27934. m.ResetDeletedAt()
  27935. return nil
  27936. case sopstage.FieldTaskID:
  27937. m.ResetTaskID()
  27938. return nil
  27939. case sopstage.FieldName:
  27940. m.ResetName()
  27941. return nil
  27942. case sopstage.FieldConditionType:
  27943. m.ResetConditionType()
  27944. return nil
  27945. case sopstage.FieldConditionOperator:
  27946. m.ResetConditionOperator()
  27947. return nil
  27948. case sopstage.FieldConditionList:
  27949. m.ResetConditionList()
  27950. return nil
  27951. case sopstage.FieldActionMessage:
  27952. m.ResetActionMessage()
  27953. return nil
  27954. case sopstage.FieldActionLabelAdd:
  27955. m.ResetActionLabelAdd()
  27956. return nil
  27957. case sopstage.FieldActionLabelDel:
  27958. m.ResetActionLabelDel()
  27959. return nil
  27960. case sopstage.FieldActionForward:
  27961. m.ResetActionForward()
  27962. return nil
  27963. case sopstage.FieldIndexSort:
  27964. m.ResetIndexSort()
  27965. return nil
  27966. }
  27967. return fmt.Errorf("unknown SopStage field %s", name)
  27968. }
  27969. // AddedEdges returns all edge names that were set/added in this mutation.
  27970. func (m *SopStageMutation) AddedEdges() []string {
  27971. edges := make([]string, 0, 3)
  27972. if m.sop_task != nil {
  27973. edges = append(edges, sopstage.EdgeSopTask)
  27974. }
  27975. if m.stage_nodes != nil {
  27976. edges = append(edges, sopstage.EdgeStageNodes)
  27977. }
  27978. if m.stage_messages != nil {
  27979. edges = append(edges, sopstage.EdgeStageMessages)
  27980. }
  27981. return edges
  27982. }
  27983. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27984. // name in this mutation.
  27985. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  27986. switch name {
  27987. case sopstage.EdgeSopTask:
  27988. if id := m.sop_task; id != nil {
  27989. return []ent.Value{*id}
  27990. }
  27991. case sopstage.EdgeStageNodes:
  27992. ids := make([]ent.Value, 0, len(m.stage_nodes))
  27993. for id := range m.stage_nodes {
  27994. ids = append(ids, id)
  27995. }
  27996. return ids
  27997. case sopstage.EdgeStageMessages:
  27998. ids := make([]ent.Value, 0, len(m.stage_messages))
  27999. for id := range m.stage_messages {
  28000. ids = append(ids, id)
  28001. }
  28002. return ids
  28003. }
  28004. return nil
  28005. }
  28006. // RemovedEdges returns all edge names that were removed in this mutation.
  28007. func (m *SopStageMutation) RemovedEdges() []string {
  28008. edges := make([]string, 0, 3)
  28009. if m.removedstage_nodes != nil {
  28010. edges = append(edges, sopstage.EdgeStageNodes)
  28011. }
  28012. if m.removedstage_messages != nil {
  28013. edges = append(edges, sopstage.EdgeStageMessages)
  28014. }
  28015. return edges
  28016. }
  28017. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28018. // the given name in this mutation.
  28019. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  28020. switch name {
  28021. case sopstage.EdgeStageNodes:
  28022. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  28023. for id := range m.removedstage_nodes {
  28024. ids = append(ids, id)
  28025. }
  28026. return ids
  28027. case sopstage.EdgeStageMessages:
  28028. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  28029. for id := range m.removedstage_messages {
  28030. ids = append(ids, id)
  28031. }
  28032. return ids
  28033. }
  28034. return nil
  28035. }
  28036. // ClearedEdges returns all edge names that were cleared in this mutation.
  28037. func (m *SopStageMutation) ClearedEdges() []string {
  28038. edges := make([]string, 0, 3)
  28039. if m.clearedsop_task {
  28040. edges = append(edges, sopstage.EdgeSopTask)
  28041. }
  28042. if m.clearedstage_nodes {
  28043. edges = append(edges, sopstage.EdgeStageNodes)
  28044. }
  28045. if m.clearedstage_messages {
  28046. edges = append(edges, sopstage.EdgeStageMessages)
  28047. }
  28048. return edges
  28049. }
  28050. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28051. // was cleared in this mutation.
  28052. func (m *SopStageMutation) EdgeCleared(name string) bool {
  28053. switch name {
  28054. case sopstage.EdgeSopTask:
  28055. return m.clearedsop_task
  28056. case sopstage.EdgeStageNodes:
  28057. return m.clearedstage_nodes
  28058. case sopstage.EdgeStageMessages:
  28059. return m.clearedstage_messages
  28060. }
  28061. return false
  28062. }
  28063. // ClearEdge clears the value of the edge with the given name. It returns an error
  28064. // if that edge is not defined in the schema.
  28065. func (m *SopStageMutation) ClearEdge(name string) error {
  28066. switch name {
  28067. case sopstage.EdgeSopTask:
  28068. m.ClearSopTask()
  28069. return nil
  28070. }
  28071. return fmt.Errorf("unknown SopStage unique edge %s", name)
  28072. }
  28073. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28074. // It returns an error if the edge is not defined in the schema.
  28075. func (m *SopStageMutation) ResetEdge(name string) error {
  28076. switch name {
  28077. case sopstage.EdgeSopTask:
  28078. m.ResetSopTask()
  28079. return nil
  28080. case sopstage.EdgeStageNodes:
  28081. m.ResetStageNodes()
  28082. return nil
  28083. case sopstage.EdgeStageMessages:
  28084. m.ResetStageMessages()
  28085. return nil
  28086. }
  28087. return fmt.Errorf("unknown SopStage edge %s", name)
  28088. }
  28089. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  28090. type SopTaskMutation struct {
  28091. config
  28092. op Op
  28093. typ string
  28094. id *uint64
  28095. created_at *time.Time
  28096. updated_at *time.Time
  28097. status *uint8
  28098. addstatus *int8
  28099. deleted_at *time.Time
  28100. name *string
  28101. bot_wxid_list *[]string
  28102. appendbot_wxid_list []string
  28103. _type *int
  28104. add_type *int
  28105. plan_start_time *time.Time
  28106. plan_end_time *time.Time
  28107. creator_id *string
  28108. organization_id *uint64
  28109. addorganization_id *int64
  28110. token *[]string
  28111. appendtoken []string
  28112. clearedFields map[string]struct{}
  28113. task_stages map[uint64]struct{}
  28114. removedtask_stages map[uint64]struct{}
  28115. clearedtask_stages bool
  28116. done bool
  28117. oldValue func(context.Context) (*SopTask, error)
  28118. predicates []predicate.SopTask
  28119. }
  28120. var _ ent.Mutation = (*SopTaskMutation)(nil)
  28121. // soptaskOption allows management of the mutation configuration using functional options.
  28122. type soptaskOption func(*SopTaskMutation)
  28123. // newSopTaskMutation creates new mutation for the SopTask entity.
  28124. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  28125. m := &SopTaskMutation{
  28126. config: c,
  28127. op: op,
  28128. typ: TypeSopTask,
  28129. clearedFields: make(map[string]struct{}),
  28130. }
  28131. for _, opt := range opts {
  28132. opt(m)
  28133. }
  28134. return m
  28135. }
  28136. // withSopTaskID sets the ID field of the mutation.
  28137. func withSopTaskID(id uint64) soptaskOption {
  28138. return func(m *SopTaskMutation) {
  28139. var (
  28140. err error
  28141. once sync.Once
  28142. value *SopTask
  28143. )
  28144. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  28145. once.Do(func() {
  28146. if m.done {
  28147. err = errors.New("querying old values post mutation is not allowed")
  28148. } else {
  28149. value, err = m.Client().SopTask.Get(ctx, id)
  28150. }
  28151. })
  28152. return value, err
  28153. }
  28154. m.id = &id
  28155. }
  28156. }
  28157. // withSopTask sets the old SopTask of the mutation.
  28158. func withSopTask(node *SopTask) soptaskOption {
  28159. return func(m *SopTaskMutation) {
  28160. m.oldValue = func(context.Context) (*SopTask, error) {
  28161. return node, nil
  28162. }
  28163. m.id = &node.ID
  28164. }
  28165. }
  28166. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28167. // executed in a transaction (ent.Tx), a transactional client is returned.
  28168. func (m SopTaskMutation) Client() *Client {
  28169. client := &Client{config: m.config}
  28170. client.init()
  28171. return client
  28172. }
  28173. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28174. // it returns an error otherwise.
  28175. func (m SopTaskMutation) Tx() (*Tx, error) {
  28176. if _, ok := m.driver.(*txDriver); !ok {
  28177. return nil, errors.New("ent: mutation is not running in a transaction")
  28178. }
  28179. tx := &Tx{config: m.config}
  28180. tx.init()
  28181. return tx, nil
  28182. }
  28183. // SetID sets the value of the id field. Note that this
  28184. // operation is only accepted on creation of SopTask entities.
  28185. func (m *SopTaskMutation) SetID(id uint64) {
  28186. m.id = &id
  28187. }
  28188. // ID returns the ID value in the mutation. Note that the ID is only available
  28189. // if it was provided to the builder or after it was returned from the database.
  28190. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  28191. if m.id == nil {
  28192. return
  28193. }
  28194. return *m.id, true
  28195. }
  28196. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28197. // That means, if the mutation is applied within a transaction with an isolation level such
  28198. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28199. // or updated by the mutation.
  28200. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  28201. switch {
  28202. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28203. id, exists := m.ID()
  28204. if exists {
  28205. return []uint64{id}, nil
  28206. }
  28207. fallthrough
  28208. case m.op.Is(OpUpdate | OpDelete):
  28209. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  28210. default:
  28211. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28212. }
  28213. }
  28214. // SetCreatedAt sets the "created_at" field.
  28215. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  28216. m.created_at = &t
  28217. }
  28218. // CreatedAt returns the value of the "created_at" field in the mutation.
  28219. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  28220. v := m.created_at
  28221. if v == nil {
  28222. return
  28223. }
  28224. return *v, true
  28225. }
  28226. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  28227. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28229. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28230. if !m.op.Is(OpUpdateOne) {
  28231. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28232. }
  28233. if m.id == nil || m.oldValue == nil {
  28234. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28235. }
  28236. oldValue, err := m.oldValue(ctx)
  28237. if err != nil {
  28238. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28239. }
  28240. return oldValue.CreatedAt, nil
  28241. }
  28242. // ResetCreatedAt resets all changes to the "created_at" field.
  28243. func (m *SopTaskMutation) ResetCreatedAt() {
  28244. m.created_at = nil
  28245. }
  28246. // SetUpdatedAt sets the "updated_at" field.
  28247. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  28248. m.updated_at = &t
  28249. }
  28250. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28251. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  28252. v := m.updated_at
  28253. if v == nil {
  28254. return
  28255. }
  28256. return *v, true
  28257. }
  28258. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  28259. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28261. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28262. if !m.op.Is(OpUpdateOne) {
  28263. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28264. }
  28265. if m.id == nil || m.oldValue == nil {
  28266. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28267. }
  28268. oldValue, err := m.oldValue(ctx)
  28269. if err != nil {
  28270. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28271. }
  28272. return oldValue.UpdatedAt, nil
  28273. }
  28274. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28275. func (m *SopTaskMutation) ResetUpdatedAt() {
  28276. m.updated_at = nil
  28277. }
  28278. // SetStatus sets the "status" field.
  28279. func (m *SopTaskMutation) SetStatus(u uint8) {
  28280. m.status = &u
  28281. m.addstatus = nil
  28282. }
  28283. // Status returns the value of the "status" field in the mutation.
  28284. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  28285. v := m.status
  28286. if v == nil {
  28287. return
  28288. }
  28289. return *v, true
  28290. }
  28291. // OldStatus returns the old "status" field's value of the SopTask entity.
  28292. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28294. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28295. if !m.op.Is(OpUpdateOne) {
  28296. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28297. }
  28298. if m.id == nil || m.oldValue == nil {
  28299. return v, errors.New("OldStatus requires an ID field in the mutation")
  28300. }
  28301. oldValue, err := m.oldValue(ctx)
  28302. if err != nil {
  28303. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28304. }
  28305. return oldValue.Status, nil
  28306. }
  28307. // AddStatus adds u to the "status" field.
  28308. func (m *SopTaskMutation) AddStatus(u int8) {
  28309. if m.addstatus != nil {
  28310. *m.addstatus += u
  28311. } else {
  28312. m.addstatus = &u
  28313. }
  28314. }
  28315. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28316. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  28317. v := m.addstatus
  28318. if v == nil {
  28319. return
  28320. }
  28321. return *v, true
  28322. }
  28323. // ClearStatus clears the value of the "status" field.
  28324. func (m *SopTaskMutation) ClearStatus() {
  28325. m.status = nil
  28326. m.addstatus = nil
  28327. m.clearedFields[soptask.FieldStatus] = struct{}{}
  28328. }
  28329. // StatusCleared returns if the "status" field was cleared in this mutation.
  28330. func (m *SopTaskMutation) StatusCleared() bool {
  28331. _, ok := m.clearedFields[soptask.FieldStatus]
  28332. return ok
  28333. }
  28334. // ResetStatus resets all changes to the "status" field.
  28335. func (m *SopTaskMutation) ResetStatus() {
  28336. m.status = nil
  28337. m.addstatus = nil
  28338. delete(m.clearedFields, soptask.FieldStatus)
  28339. }
  28340. // SetDeletedAt sets the "deleted_at" field.
  28341. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  28342. m.deleted_at = &t
  28343. }
  28344. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28345. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  28346. v := m.deleted_at
  28347. if v == nil {
  28348. return
  28349. }
  28350. return *v, true
  28351. }
  28352. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  28353. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28355. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28356. if !m.op.Is(OpUpdateOne) {
  28357. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28358. }
  28359. if m.id == nil || m.oldValue == nil {
  28360. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28361. }
  28362. oldValue, err := m.oldValue(ctx)
  28363. if err != nil {
  28364. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28365. }
  28366. return oldValue.DeletedAt, nil
  28367. }
  28368. // ClearDeletedAt clears the value of the "deleted_at" field.
  28369. func (m *SopTaskMutation) ClearDeletedAt() {
  28370. m.deleted_at = nil
  28371. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  28372. }
  28373. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28374. func (m *SopTaskMutation) DeletedAtCleared() bool {
  28375. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  28376. return ok
  28377. }
  28378. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28379. func (m *SopTaskMutation) ResetDeletedAt() {
  28380. m.deleted_at = nil
  28381. delete(m.clearedFields, soptask.FieldDeletedAt)
  28382. }
  28383. // SetName sets the "name" field.
  28384. func (m *SopTaskMutation) SetName(s string) {
  28385. m.name = &s
  28386. }
  28387. // Name returns the value of the "name" field in the mutation.
  28388. func (m *SopTaskMutation) Name() (r string, exists bool) {
  28389. v := m.name
  28390. if v == nil {
  28391. return
  28392. }
  28393. return *v, true
  28394. }
  28395. // OldName returns the old "name" field's value of the SopTask entity.
  28396. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28398. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  28399. if !m.op.Is(OpUpdateOne) {
  28400. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28401. }
  28402. if m.id == nil || m.oldValue == nil {
  28403. return v, errors.New("OldName requires an ID field in the mutation")
  28404. }
  28405. oldValue, err := m.oldValue(ctx)
  28406. if err != nil {
  28407. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28408. }
  28409. return oldValue.Name, nil
  28410. }
  28411. // ResetName resets all changes to the "name" field.
  28412. func (m *SopTaskMutation) ResetName() {
  28413. m.name = nil
  28414. }
  28415. // SetBotWxidList sets the "bot_wxid_list" field.
  28416. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  28417. m.bot_wxid_list = &s
  28418. m.appendbot_wxid_list = nil
  28419. }
  28420. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  28421. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  28422. v := m.bot_wxid_list
  28423. if v == nil {
  28424. return
  28425. }
  28426. return *v, true
  28427. }
  28428. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  28429. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28431. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  28432. if !m.op.Is(OpUpdateOne) {
  28433. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  28434. }
  28435. if m.id == nil || m.oldValue == nil {
  28436. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  28437. }
  28438. oldValue, err := m.oldValue(ctx)
  28439. if err != nil {
  28440. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  28441. }
  28442. return oldValue.BotWxidList, nil
  28443. }
  28444. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  28445. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  28446. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  28447. }
  28448. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  28449. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  28450. if len(m.appendbot_wxid_list) == 0 {
  28451. return nil, false
  28452. }
  28453. return m.appendbot_wxid_list, true
  28454. }
  28455. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  28456. func (m *SopTaskMutation) ClearBotWxidList() {
  28457. m.bot_wxid_list = nil
  28458. m.appendbot_wxid_list = nil
  28459. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  28460. }
  28461. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  28462. func (m *SopTaskMutation) BotWxidListCleared() bool {
  28463. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  28464. return ok
  28465. }
  28466. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  28467. func (m *SopTaskMutation) ResetBotWxidList() {
  28468. m.bot_wxid_list = nil
  28469. m.appendbot_wxid_list = nil
  28470. delete(m.clearedFields, soptask.FieldBotWxidList)
  28471. }
  28472. // SetType sets the "type" field.
  28473. func (m *SopTaskMutation) SetType(i int) {
  28474. m._type = &i
  28475. m.add_type = nil
  28476. }
  28477. // GetType returns the value of the "type" field in the mutation.
  28478. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  28479. v := m._type
  28480. if v == nil {
  28481. return
  28482. }
  28483. return *v, true
  28484. }
  28485. // OldType returns the old "type" field's value of the SopTask entity.
  28486. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28488. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  28489. if !m.op.Is(OpUpdateOne) {
  28490. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28491. }
  28492. if m.id == nil || m.oldValue == nil {
  28493. return v, errors.New("OldType requires an ID field in the mutation")
  28494. }
  28495. oldValue, err := m.oldValue(ctx)
  28496. if err != nil {
  28497. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28498. }
  28499. return oldValue.Type, nil
  28500. }
  28501. // AddType adds i to the "type" field.
  28502. func (m *SopTaskMutation) AddType(i int) {
  28503. if m.add_type != nil {
  28504. *m.add_type += i
  28505. } else {
  28506. m.add_type = &i
  28507. }
  28508. }
  28509. // AddedType returns the value that was added to the "type" field in this mutation.
  28510. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  28511. v := m.add_type
  28512. if v == nil {
  28513. return
  28514. }
  28515. return *v, true
  28516. }
  28517. // ResetType resets all changes to the "type" field.
  28518. func (m *SopTaskMutation) ResetType() {
  28519. m._type = nil
  28520. m.add_type = nil
  28521. }
  28522. // SetPlanStartTime sets the "plan_start_time" field.
  28523. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  28524. m.plan_start_time = &t
  28525. }
  28526. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  28527. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  28528. v := m.plan_start_time
  28529. if v == nil {
  28530. return
  28531. }
  28532. return *v, true
  28533. }
  28534. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  28535. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28537. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  28538. if !m.op.Is(OpUpdateOne) {
  28539. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  28540. }
  28541. if m.id == nil || m.oldValue == nil {
  28542. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  28543. }
  28544. oldValue, err := m.oldValue(ctx)
  28545. if err != nil {
  28546. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  28547. }
  28548. return oldValue.PlanStartTime, nil
  28549. }
  28550. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  28551. func (m *SopTaskMutation) ClearPlanStartTime() {
  28552. m.plan_start_time = nil
  28553. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  28554. }
  28555. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  28556. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  28557. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  28558. return ok
  28559. }
  28560. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  28561. func (m *SopTaskMutation) ResetPlanStartTime() {
  28562. m.plan_start_time = nil
  28563. delete(m.clearedFields, soptask.FieldPlanStartTime)
  28564. }
  28565. // SetPlanEndTime sets the "plan_end_time" field.
  28566. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  28567. m.plan_end_time = &t
  28568. }
  28569. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  28570. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  28571. v := m.plan_end_time
  28572. if v == nil {
  28573. return
  28574. }
  28575. return *v, true
  28576. }
  28577. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  28578. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28580. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  28581. if !m.op.Is(OpUpdateOne) {
  28582. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  28583. }
  28584. if m.id == nil || m.oldValue == nil {
  28585. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  28586. }
  28587. oldValue, err := m.oldValue(ctx)
  28588. if err != nil {
  28589. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  28590. }
  28591. return oldValue.PlanEndTime, nil
  28592. }
  28593. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  28594. func (m *SopTaskMutation) ClearPlanEndTime() {
  28595. m.plan_end_time = nil
  28596. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  28597. }
  28598. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  28599. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  28600. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  28601. return ok
  28602. }
  28603. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  28604. func (m *SopTaskMutation) ResetPlanEndTime() {
  28605. m.plan_end_time = nil
  28606. delete(m.clearedFields, soptask.FieldPlanEndTime)
  28607. }
  28608. // SetCreatorID sets the "creator_id" field.
  28609. func (m *SopTaskMutation) SetCreatorID(s string) {
  28610. m.creator_id = &s
  28611. }
  28612. // CreatorID returns the value of the "creator_id" field in the mutation.
  28613. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  28614. v := m.creator_id
  28615. if v == nil {
  28616. return
  28617. }
  28618. return *v, true
  28619. }
  28620. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  28621. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28623. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  28624. if !m.op.Is(OpUpdateOne) {
  28625. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  28626. }
  28627. if m.id == nil || m.oldValue == nil {
  28628. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  28629. }
  28630. oldValue, err := m.oldValue(ctx)
  28631. if err != nil {
  28632. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  28633. }
  28634. return oldValue.CreatorID, nil
  28635. }
  28636. // ClearCreatorID clears the value of the "creator_id" field.
  28637. func (m *SopTaskMutation) ClearCreatorID() {
  28638. m.creator_id = nil
  28639. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  28640. }
  28641. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  28642. func (m *SopTaskMutation) CreatorIDCleared() bool {
  28643. _, ok := m.clearedFields[soptask.FieldCreatorID]
  28644. return ok
  28645. }
  28646. // ResetCreatorID resets all changes to the "creator_id" field.
  28647. func (m *SopTaskMutation) ResetCreatorID() {
  28648. m.creator_id = nil
  28649. delete(m.clearedFields, soptask.FieldCreatorID)
  28650. }
  28651. // SetOrganizationID sets the "organization_id" field.
  28652. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  28653. m.organization_id = &u
  28654. m.addorganization_id = nil
  28655. }
  28656. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28657. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  28658. v := m.organization_id
  28659. if v == nil {
  28660. return
  28661. }
  28662. return *v, true
  28663. }
  28664. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  28665. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28667. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28668. if !m.op.Is(OpUpdateOne) {
  28669. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28670. }
  28671. if m.id == nil || m.oldValue == nil {
  28672. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28673. }
  28674. oldValue, err := m.oldValue(ctx)
  28675. if err != nil {
  28676. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28677. }
  28678. return oldValue.OrganizationID, nil
  28679. }
  28680. // AddOrganizationID adds u to the "organization_id" field.
  28681. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  28682. if m.addorganization_id != nil {
  28683. *m.addorganization_id += u
  28684. } else {
  28685. m.addorganization_id = &u
  28686. }
  28687. }
  28688. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28689. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  28690. v := m.addorganization_id
  28691. if v == nil {
  28692. return
  28693. }
  28694. return *v, true
  28695. }
  28696. // ClearOrganizationID clears the value of the "organization_id" field.
  28697. func (m *SopTaskMutation) ClearOrganizationID() {
  28698. m.organization_id = nil
  28699. m.addorganization_id = nil
  28700. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  28701. }
  28702. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28703. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  28704. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  28705. return ok
  28706. }
  28707. // ResetOrganizationID resets all changes to the "organization_id" field.
  28708. func (m *SopTaskMutation) ResetOrganizationID() {
  28709. m.organization_id = nil
  28710. m.addorganization_id = nil
  28711. delete(m.clearedFields, soptask.FieldOrganizationID)
  28712. }
  28713. // SetToken sets the "token" field.
  28714. func (m *SopTaskMutation) SetToken(s []string) {
  28715. m.token = &s
  28716. m.appendtoken = nil
  28717. }
  28718. // Token returns the value of the "token" field in the mutation.
  28719. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  28720. v := m.token
  28721. if v == nil {
  28722. return
  28723. }
  28724. return *v, true
  28725. }
  28726. // OldToken returns the old "token" field's value of the SopTask entity.
  28727. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28729. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  28730. if !m.op.Is(OpUpdateOne) {
  28731. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28732. }
  28733. if m.id == nil || m.oldValue == nil {
  28734. return v, errors.New("OldToken requires an ID field in the mutation")
  28735. }
  28736. oldValue, err := m.oldValue(ctx)
  28737. if err != nil {
  28738. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28739. }
  28740. return oldValue.Token, nil
  28741. }
  28742. // AppendToken adds s to the "token" field.
  28743. func (m *SopTaskMutation) AppendToken(s []string) {
  28744. m.appendtoken = append(m.appendtoken, s...)
  28745. }
  28746. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  28747. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  28748. if len(m.appendtoken) == 0 {
  28749. return nil, false
  28750. }
  28751. return m.appendtoken, true
  28752. }
  28753. // ClearToken clears the value of the "token" field.
  28754. func (m *SopTaskMutation) ClearToken() {
  28755. m.token = nil
  28756. m.appendtoken = nil
  28757. m.clearedFields[soptask.FieldToken] = struct{}{}
  28758. }
  28759. // TokenCleared returns if the "token" field was cleared in this mutation.
  28760. func (m *SopTaskMutation) TokenCleared() bool {
  28761. _, ok := m.clearedFields[soptask.FieldToken]
  28762. return ok
  28763. }
  28764. // ResetToken resets all changes to the "token" field.
  28765. func (m *SopTaskMutation) ResetToken() {
  28766. m.token = nil
  28767. m.appendtoken = nil
  28768. delete(m.clearedFields, soptask.FieldToken)
  28769. }
  28770. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  28771. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  28772. if m.task_stages == nil {
  28773. m.task_stages = make(map[uint64]struct{})
  28774. }
  28775. for i := range ids {
  28776. m.task_stages[ids[i]] = struct{}{}
  28777. }
  28778. }
  28779. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  28780. func (m *SopTaskMutation) ClearTaskStages() {
  28781. m.clearedtask_stages = true
  28782. }
  28783. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  28784. func (m *SopTaskMutation) TaskStagesCleared() bool {
  28785. return m.clearedtask_stages
  28786. }
  28787. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  28788. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  28789. if m.removedtask_stages == nil {
  28790. m.removedtask_stages = make(map[uint64]struct{})
  28791. }
  28792. for i := range ids {
  28793. delete(m.task_stages, ids[i])
  28794. m.removedtask_stages[ids[i]] = struct{}{}
  28795. }
  28796. }
  28797. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  28798. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  28799. for id := range m.removedtask_stages {
  28800. ids = append(ids, id)
  28801. }
  28802. return
  28803. }
  28804. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  28805. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  28806. for id := range m.task_stages {
  28807. ids = append(ids, id)
  28808. }
  28809. return
  28810. }
  28811. // ResetTaskStages resets all changes to the "task_stages" edge.
  28812. func (m *SopTaskMutation) ResetTaskStages() {
  28813. m.task_stages = nil
  28814. m.clearedtask_stages = false
  28815. m.removedtask_stages = nil
  28816. }
  28817. // Where appends a list predicates to the SopTaskMutation builder.
  28818. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  28819. m.predicates = append(m.predicates, ps...)
  28820. }
  28821. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  28822. // users can use type-assertion to append predicates that do not depend on any generated package.
  28823. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  28824. p := make([]predicate.SopTask, len(ps))
  28825. for i := range ps {
  28826. p[i] = ps[i]
  28827. }
  28828. m.Where(p...)
  28829. }
  28830. // Op returns the operation name.
  28831. func (m *SopTaskMutation) Op() Op {
  28832. return m.op
  28833. }
  28834. // SetOp allows setting the mutation operation.
  28835. func (m *SopTaskMutation) SetOp(op Op) {
  28836. m.op = op
  28837. }
  28838. // Type returns the node type of this mutation (SopTask).
  28839. func (m *SopTaskMutation) Type() string {
  28840. return m.typ
  28841. }
  28842. // Fields returns all fields that were changed during this mutation. Note that in
  28843. // order to get all numeric fields that were incremented/decremented, call
  28844. // AddedFields().
  28845. func (m *SopTaskMutation) Fields() []string {
  28846. fields := make([]string, 0, 12)
  28847. if m.created_at != nil {
  28848. fields = append(fields, soptask.FieldCreatedAt)
  28849. }
  28850. if m.updated_at != nil {
  28851. fields = append(fields, soptask.FieldUpdatedAt)
  28852. }
  28853. if m.status != nil {
  28854. fields = append(fields, soptask.FieldStatus)
  28855. }
  28856. if m.deleted_at != nil {
  28857. fields = append(fields, soptask.FieldDeletedAt)
  28858. }
  28859. if m.name != nil {
  28860. fields = append(fields, soptask.FieldName)
  28861. }
  28862. if m.bot_wxid_list != nil {
  28863. fields = append(fields, soptask.FieldBotWxidList)
  28864. }
  28865. if m._type != nil {
  28866. fields = append(fields, soptask.FieldType)
  28867. }
  28868. if m.plan_start_time != nil {
  28869. fields = append(fields, soptask.FieldPlanStartTime)
  28870. }
  28871. if m.plan_end_time != nil {
  28872. fields = append(fields, soptask.FieldPlanEndTime)
  28873. }
  28874. if m.creator_id != nil {
  28875. fields = append(fields, soptask.FieldCreatorID)
  28876. }
  28877. if m.organization_id != nil {
  28878. fields = append(fields, soptask.FieldOrganizationID)
  28879. }
  28880. if m.token != nil {
  28881. fields = append(fields, soptask.FieldToken)
  28882. }
  28883. return fields
  28884. }
  28885. // Field returns the value of a field with the given name. The second boolean
  28886. // return value indicates that this field was not set, or was not defined in the
  28887. // schema.
  28888. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  28889. switch name {
  28890. case soptask.FieldCreatedAt:
  28891. return m.CreatedAt()
  28892. case soptask.FieldUpdatedAt:
  28893. return m.UpdatedAt()
  28894. case soptask.FieldStatus:
  28895. return m.Status()
  28896. case soptask.FieldDeletedAt:
  28897. return m.DeletedAt()
  28898. case soptask.FieldName:
  28899. return m.Name()
  28900. case soptask.FieldBotWxidList:
  28901. return m.BotWxidList()
  28902. case soptask.FieldType:
  28903. return m.GetType()
  28904. case soptask.FieldPlanStartTime:
  28905. return m.PlanStartTime()
  28906. case soptask.FieldPlanEndTime:
  28907. return m.PlanEndTime()
  28908. case soptask.FieldCreatorID:
  28909. return m.CreatorID()
  28910. case soptask.FieldOrganizationID:
  28911. return m.OrganizationID()
  28912. case soptask.FieldToken:
  28913. return m.Token()
  28914. }
  28915. return nil, false
  28916. }
  28917. // OldField returns the old value of the field from the database. An error is
  28918. // returned if the mutation operation is not UpdateOne, or the query to the
  28919. // database failed.
  28920. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28921. switch name {
  28922. case soptask.FieldCreatedAt:
  28923. return m.OldCreatedAt(ctx)
  28924. case soptask.FieldUpdatedAt:
  28925. return m.OldUpdatedAt(ctx)
  28926. case soptask.FieldStatus:
  28927. return m.OldStatus(ctx)
  28928. case soptask.FieldDeletedAt:
  28929. return m.OldDeletedAt(ctx)
  28930. case soptask.FieldName:
  28931. return m.OldName(ctx)
  28932. case soptask.FieldBotWxidList:
  28933. return m.OldBotWxidList(ctx)
  28934. case soptask.FieldType:
  28935. return m.OldType(ctx)
  28936. case soptask.FieldPlanStartTime:
  28937. return m.OldPlanStartTime(ctx)
  28938. case soptask.FieldPlanEndTime:
  28939. return m.OldPlanEndTime(ctx)
  28940. case soptask.FieldCreatorID:
  28941. return m.OldCreatorID(ctx)
  28942. case soptask.FieldOrganizationID:
  28943. return m.OldOrganizationID(ctx)
  28944. case soptask.FieldToken:
  28945. return m.OldToken(ctx)
  28946. }
  28947. return nil, fmt.Errorf("unknown SopTask field %s", name)
  28948. }
  28949. // SetField sets the value of a field with the given name. It returns an error if
  28950. // the field is not defined in the schema, or if the type mismatched the field
  28951. // type.
  28952. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  28953. switch name {
  28954. case soptask.FieldCreatedAt:
  28955. v, ok := value.(time.Time)
  28956. if !ok {
  28957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28958. }
  28959. m.SetCreatedAt(v)
  28960. return nil
  28961. case soptask.FieldUpdatedAt:
  28962. v, ok := value.(time.Time)
  28963. if !ok {
  28964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28965. }
  28966. m.SetUpdatedAt(v)
  28967. return nil
  28968. case soptask.FieldStatus:
  28969. v, ok := value.(uint8)
  28970. if !ok {
  28971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28972. }
  28973. m.SetStatus(v)
  28974. return nil
  28975. case soptask.FieldDeletedAt:
  28976. v, ok := value.(time.Time)
  28977. if !ok {
  28978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28979. }
  28980. m.SetDeletedAt(v)
  28981. return nil
  28982. case soptask.FieldName:
  28983. v, ok := value.(string)
  28984. if !ok {
  28985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28986. }
  28987. m.SetName(v)
  28988. return nil
  28989. case soptask.FieldBotWxidList:
  28990. v, ok := value.([]string)
  28991. if !ok {
  28992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28993. }
  28994. m.SetBotWxidList(v)
  28995. return nil
  28996. case soptask.FieldType:
  28997. v, ok := value.(int)
  28998. if !ok {
  28999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29000. }
  29001. m.SetType(v)
  29002. return nil
  29003. case soptask.FieldPlanStartTime:
  29004. v, ok := value.(time.Time)
  29005. if !ok {
  29006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29007. }
  29008. m.SetPlanStartTime(v)
  29009. return nil
  29010. case soptask.FieldPlanEndTime:
  29011. v, ok := value.(time.Time)
  29012. if !ok {
  29013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29014. }
  29015. m.SetPlanEndTime(v)
  29016. return nil
  29017. case soptask.FieldCreatorID:
  29018. v, ok := value.(string)
  29019. if !ok {
  29020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29021. }
  29022. m.SetCreatorID(v)
  29023. return nil
  29024. case soptask.FieldOrganizationID:
  29025. v, ok := value.(uint64)
  29026. if !ok {
  29027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29028. }
  29029. m.SetOrganizationID(v)
  29030. return nil
  29031. case soptask.FieldToken:
  29032. v, ok := value.([]string)
  29033. if !ok {
  29034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29035. }
  29036. m.SetToken(v)
  29037. return nil
  29038. }
  29039. return fmt.Errorf("unknown SopTask field %s", name)
  29040. }
  29041. // AddedFields returns all numeric fields that were incremented/decremented during
  29042. // this mutation.
  29043. func (m *SopTaskMutation) AddedFields() []string {
  29044. var fields []string
  29045. if m.addstatus != nil {
  29046. fields = append(fields, soptask.FieldStatus)
  29047. }
  29048. if m.add_type != nil {
  29049. fields = append(fields, soptask.FieldType)
  29050. }
  29051. if m.addorganization_id != nil {
  29052. fields = append(fields, soptask.FieldOrganizationID)
  29053. }
  29054. return fields
  29055. }
  29056. // AddedField returns the numeric value that was incremented/decremented on a field
  29057. // with the given name. The second boolean return value indicates that this field
  29058. // was not set, or was not defined in the schema.
  29059. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  29060. switch name {
  29061. case soptask.FieldStatus:
  29062. return m.AddedStatus()
  29063. case soptask.FieldType:
  29064. return m.AddedType()
  29065. case soptask.FieldOrganizationID:
  29066. return m.AddedOrganizationID()
  29067. }
  29068. return nil, false
  29069. }
  29070. // AddField adds the value to the field with the given name. It returns an error if
  29071. // the field is not defined in the schema, or if the type mismatched the field
  29072. // type.
  29073. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  29074. switch name {
  29075. case soptask.FieldStatus:
  29076. v, ok := value.(int8)
  29077. if !ok {
  29078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29079. }
  29080. m.AddStatus(v)
  29081. return nil
  29082. case soptask.FieldType:
  29083. v, ok := value.(int)
  29084. if !ok {
  29085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29086. }
  29087. m.AddType(v)
  29088. return nil
  29089. case soptask.FieldOrganizationID:
  29090. v, ok := value.(int64)
  29091. if !ok {
  29092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29093. }
  29094. m.AddOrganizationID(v)
  29095. return nil
  29096. }
  29097. return fmt.Errorf("unknown SopTask numeric field %s", name)
  29098. }
  29099. // ClearedFields returns all nullable fields that were cleared during this
  29100. // mutation.
  29101. func (m *SopTaskMutation) ClearedFields() []string {
  29102. var fields []string
  29103. if m.FieldCleared(soptask.FieldStatus) {
  29104. fields = append(fields, soptask.FieldStatus)
  29105. }
  29106. if m.FieldCleared(soptask.FieldDeletedAt) {
  29107. fields = append(fields, soptask.FieldDeletedAt)
  29108. }
  29109. if m.FieldCleared(soptask.FieldBotWxidList) {
  29110. fields = append(fields, soptask.FieldBotWxidList)
  29111. }
  29112. if m.FieldCleared(soptask.FieldPlanStartTime) {
  29113. fields = append(fields, soptask.FieldPlanStartTime)
  29114. }
  29115. if m.FieldCleared(soptask.FieldPlanEndTime) {
  29116. fields = append(fields, soptask.FieldPlanEndTime)
  29117. }
  29118. if m.FieldCleared(soptask.FieldCreatorID) {
  29119. fields = append(fields, soptask.FieldCreatorID)
  29120. }
  29121. if m.FieldCleared(soptask.FieldOrganizationID) {
  29122. fields = append(fields, soptask.FieldOrganizationID)
  29123. }
  29124. if m.FieldCleared(soptask.FieldToken) {
  29125. fields = append(fields, soptask.FieldToken)
  29126. }
  29127. return fields
  29128. }
  29129. // FieldCleared returns a boolean indicating if a field with the given name was
  29130. // cleared in this mutation.
  29131. func (m *SopTaskMutation) FieldCleared(name string) bool {
  29132. _, ok := m.clearedFields[name]
  29133. return ok
  29134. }
  29135. // ClearField clears the value of the field with the given name. It returns an
  29136. // error if the field is not defined in the schema.
  29137. func (m *SopTaskMutation) ClearField(name string) error {
  29138. switch name {
  29139. case soptask.FieldStatus:
  29140. m.ClearStatus()
  29141. return nil
  29142. case soptask.FieldDeletedAt:
  29143. m.ClearDeletedAt()
  29144. return nil
  29145. case soptask.FieldBotWxidList:
  29146. m.ClearBotWxidList()
  29147. return nil
  29148. case soptask.FieldPlanStartTime:
  29149. m.ClearPlanStartTime()
  29150. return nil
  29151. case soptask.FieldPlanEndTime:
  29152. m.ClearPlanEndTime()
  29153. return nil
  29154. case soptask.FieldCreatorID:
  29155. m.ClearCreatorID()
  29156. return nil
  29157. case soptask.FieldOrganizationID:
  29158. m.ClearOrganizationID()
  29159. return nil
  29160. case soptask.FieldToken:
  29161. m.ClearToken()
  29162. return nil
  29163. }
  29164. return fmt.Errorf("unknown SopTask nullable field %s", name)
  29165. }
  29166. // ResetField resets all changes in the mutation for the field with the given name.
  29167. // It returns an error if the field is not defined in the schema.
  29168. func (m *SopTaskMutation) ResetField(name string) error {
  29169. switch name {
  29170. case soptask.FieldCreatedAt:
  29171. m.ResetCreatedAt()
  29172. return nil
  29173. case soptask.FieldUpdatedAt:
  29174. m.ResetUpdatedAt()
  29175. return nil
  29176. case soptask.FieldStatus:
  29177. m.ResetStatus()
  29178. return nil
  29179. case soptask.FieldDeletedAt:
  29180. m.ResetDeletedAt()
  29181. return nil
  29182. case soptask.FieldName:
  29183. m.ResetName()
  29184. return nil
  29185. case soptask.FieldBotWxidList:
  29186. m.ResetBotWxidList()
  29187. return nil
  29188. case soptask.FieldType:
  29189. m.ResetType()
  29190. return nil
  29191. case soptask.FieldPlanStartTime:
  29192. m.ResetPlanStartTime()
  29193. return nil
  29194. case soptask.FieldPlanEndTime:
  29195. m.ResetPlanEndTime()
  29196. return nil
  29197. case soptask.FieldCreatorID:
  29198. m.ResetCreatorID()
  29199. return nil
  29200. case soptask.FieldOrganizationID:
  29201. m.ResetOrganizationID()
  29202. return nil
  29203. case soptask.FieldToken:
  29204. m.ResetToken()
  29205. return nil
  29206. }
  29207. return fmt.Errorf("unknown SopTask field %s", name)
  29208. }
  29209. // AddedEdges returns all edge names that were set/added in this mutation.
  29210. func (m *SopTaskMutation) AddedEdges() []string {
  29211. edges := make([]string, 0, 1)
  29212. if m.task_stages != nil {
  29213. edges = append(edges, soptask.EdgeTaskStages)
  29214. }
  29215. return edges
  29216. }
  29217. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29218. // name in this mutation.
  29219. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  29220. switch name {
  29221. case soptask.EdgeTaskStages:
  29222. ids := make([]ent.Value, 0, len(m.task_stages))
  29223. for id := range m.task_stages {
  29224. ids = append(ids, id)
  29225. }
  29226. return ids
  29227. }
  29228. return nil
  29229. }
  29230. // RemovedEdges returns all edge names that were removed in this mutation.
  29231. func (m *SopTaskMutation) RemovedEdges() []string {
  29232. edges := make([]string, 0, 1)
  29233. if m.removedtask_stages != nil {
  29234. edges = append(edges, soptask.EdgeTaskStages)
  29235. }
  29236. return edges
  29237. }
  29238. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29239. // the given name in this mutation.
  29240. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  29241. switch name {
  29242. case soptask.EdgeTaskStages:
  29243. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  29244. for id := range m.removedtask_stages {
  29245. ids = append(ids, id)
  29246. }
  29247. return ids
  29248. }
  29249. return nil
  29250. }
  29251. // ClearedEdges returns all edge names that were cleared in this mutation.
  29252. func (m *SopTaskMutation) ClearedEdges() []string {
  29253. edges := make([]string, 0, 1)
  29254. if m.clearedtask_stages {
  29255. edges = append(edges, soptask.EdgeTaskStages)
  29256. }
  29257. return edges
  29258. }
  29259. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29260. // was cleared in this mutation.
  29261. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  29262. switch name {
  29263. case soptask.EdgeTaskStages:
  29264. return m.clearedtask_stages
  29265. }
  29266. return false
  29267. }
  29268. // ClearEdge clears the value of the edge with the given name. It returns an error
  29269. // if that edge is not defined in the schema.
  29270. func (m *SopTaskMutation) ClearEdge(name string) error {
  29271. switch name {
  29272. }
  29273. return fmt.Errorf("unknown SopTask unique edge %s", name)
  29274. }
  29275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29276. // It returns an error if the edge is not defined in the schema.
  29277. func (m *SopTaskMutation) ResetEdge(name string) error {
  29278. switch name {
  29279. case soptask.EdgeTaskStages:
  29280. m.ResetTaskStages()
  29281. return nil
  29282. }
  29283. return fmt.Errorf("unknown SopTask edge %s", name)
  29284. }
  29285. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  29286. type TokenMutation struct {
  29287. config
  29288. op Op
  29289. typ string
  29290. id *uint64
  29291. created_at *time.Time
  29292. updated_at *time.Time
  29293. deleted_at *time.Time
  29294. expire_at *time.Time
  29295. token *string
  29296. mac *string
  29297. organization_id *uint64
  29298. addorganization_id *int64
  29299. custom_agent_base *string
  29300. custom_agent_key *string
  29301. openai_base *string
  29302. openai_key *string
  29303. clearedFields map[string]struct{}
  29304. agent *uint64
  29305. clearedagent bool
  29306. done bool
  29307. oldValue func(context.Context) (*Token, error)
  29308. predicates []predicate.Token
  29309. }
  29310. var _ ent.Mutation = (*TokenMutation)(nil)
  29311. // tokenOption allows management of the mutation configuration using functional options.
  29312. type tokenOption func(*TokenMutation)
  29313. // newTokenMutation creates new mutation for the Token entity.
  29314. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  29315. m := &TokenMutation{
  29316. config: c,
  29317. op: op,
  29318. typ: TypeToken,
  29319. clearedFields: make(map[string]struct{}),
  29320. }
  29321. for _, opt := range opts {
  29322. opt(m)
  29323. }
  29324. return m
  29325. }
  29326. // withTokenID sets the ID field of the mutation.
  29327. func withTokenID(id uint64) tokenOption {
  29328. return func(m *TokenMutation) {
  29329. var (
  29330. err error
  29331. once sync.Once
  29332. value *Token
  29333. )
  29334. m.oldValue = func(ctx context.Context) (*Token, error) {
  29335. once.Do(func() {
  29336. if m.done {
  29337. err = errors.New("querying old values post mutation is not allowed")
  29338. } else {
  29339. value, err = m.Client().Token.Get(ctx, id)
  29340. }
  29341. })
  29342. return value, err
  29343. }
  29344. m.id = &id
  29345. }
  29346. }
  29347. // withToken sets the old Token of the mutation.
  29348. func withToken(node *Token) tokenOption {
  29349. return func(m *TokenMutation) {
  29350. m.oldValue = func(context.Context) (*Token, error) {
  29351. return node, nil
  29352. }
  29353. m.id = &node.ID
  29354. }
  29355. }
  29356. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29357. // executed in a transaction (ent.Tx), a transactional client is returned.
  29358. func (m TokenMutation) Client() *Client {
  29359. client := &Client{config: m.config}
  29360. client.init()
  29361. return client
  29362. }
  29363. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29364. // it returns an error otherwise.
  29365. func (m TokenMutation) Tx() (*Tx, error) {
  29366. if _, ok := m.driver.(*txDriver); !ok {
  29367. return nil, errors.New("ent: mutation is not running in a transaction")
  29368. }
  29369. tx := &Tx{config: m.config}
  29370. tx.init()
  29371. return tx, nil
  29372. }
  29373. // SetID sets the value of the id field. Note that this
  29374. // operation is only accepted on creation of Token entities.
  29375. func (m *TokenMutation) SetID(id uint64) {
  29376. m.id = &id
  29377. }
  29378. // ID returns the ID value in the mutation. Note that the ID is only available
  29379. // if it was provided to the builder or after it was returned from the database.
  29380. func (m *TokenMutation) ID() (id uint64, exists bool) {
  29381. if m.id == nil {
  29382. return
  29383. }
  29384. return *m.id, true
  29385. }
  29386. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29387. // That means, if the mutation is applied within a transaction with an isolation level such
  29388. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29389. // or updated by the mutation.
  29390. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  29391. switch {
  29392. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29393. id, exists := m.ID()
  29394. if exists {
  29395. return []uint64{id}, nil
  29396. }
  29397. fallthrough
  29398. case m.op.Is(OpUpdate | OpDelete):
  29399. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  29400. default:
  29401. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29402. }
  29403. }
  29404. // SetCreatedAt sets the "created_at" field.
  29405. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  29406. m.created_at = &t
  29407. }
  29408. // CreatedAt returns the value of the "created_at" field in the mutation.
  29409. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  29410. v := m.created_at
  29411. if v == nil {
  29412. return
  29413. }
  29414. return *v, true
  29415. }
  29416. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  29417. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29419. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29420. if !m.op.Is(OpUpdateOne) {
  29421. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29422. }
  29423. if m.id == nil || m.oldValue == nil {
  29424. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29425. }
  29426. oldValue, err := m.oldValue(ctx)
  29427. if err != nil {
  29428. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29429. }
  29430. return oldValue.CreatedAt, nil
  29431. }
  29432. // ResetCreatedAt resets all changes to the "created_at" field.
  29433. func (m *TokenMutation) ResetCreatedAt() {
  29434. m.created_at = nil
  29435. }
  29436. // SetUpdatedAt sets the "updated_at" field.
  29437. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  29438. m.updated_at = &t
  29439. }
  29440. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29441. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  29442. v := m.updated_at
  29443. if v == nil {
  29444. return
  29445. }
  29446. return *v, true
  29447. }
  29448. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  29449. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29451. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29452. if !m.op.Is(OpUpdateOne) {
  29453. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29454. }
  29455. if m.id == nil || m.oldValue == nil {
  29456. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29457. }
  29458. oldValue, err := m.oldValue(ctx)
  29459. if err != nil {
  29460. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29461. }
  29462. return oldValue.UpdatedAt, nil
  29463. }
  29464. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29465. func (m *TokenMutation) ResetUpdatedAt() {
  29466. m.updated_at = nil
  29467. }
  29468. // SetDeletedAt sets the "deleted_at" field.
  29469. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  29470. m.deleted_at = &t
  29471. }
  29472. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29473. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  29474. v := m.deleted_at
  29475. if v == nil {
  29476. return
  29477. }
  29478. return *v, true
  29479. }
  29480. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  29481. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29483. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29484. if !m.op.Is(OpUpdateOne) {
  29485. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29486. }
  29487. if m.id == nil || m.oldValue == nil {
  29488. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29489. }
  29490. oldValue, err := m.oldValue(ctx)
  29491. if err != nil {
  29492. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29493. }
  29494. return oldValue.DeletedAt, nil
  29495. }
  29496. // ClearDeletedAt clears the value of the "deleted_at" field.
  29497. func (m *TokenMutation) ClearDeletedAt() {
  29498. m.deleted_at = nil
  29499. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  29500. }
  29501. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29502. func (m *TokenMutation) DeletedAtCleared() bool {
  29503. _, ok := m.clearedFields[token.FieldDeletedAt]
  29504. return ok
  29505. }
  29506. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29507. func (m *TokenMutation) ResetDeletedAt() {
  29508. m.deleted_at = nil
  29509. delete(m.clearedFields, token.FieldDeletedAt)
  29510. }
  29511. // SetExpireAt sets the "expire_at" field.
  29512. func (m *TokenMutation) SetExpireAt(t time.Time) {
  29513. m.expire_at = &t
  29514. }
  29515. // ExpireAt returns the value of the "expire_at" field in the mutation.
  29516. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  29517. v := m.expire_at
  29518. if v == nil {
  29519. return
  29520. }
  29521. return *v, true
  29522. }
  29523. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  29524. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29526. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  29527. if !m.op.Is(OpUpdateOne) {
  29528. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  29529. }
  29530. if m.id == nil || m.oldValue == nil {
  29531. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  29532. }
  29533. oldValue, err := m.oldValue(ctx)
  29534. if err != nil {
  29535. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  29536. }
  29537. return oldValue.ExpireAt, nil
  29538. }
  29539. // ClearExpireAt clears the value of the "expire_at" field.
  29540. func (m *TokenMutation) ClearExpireAt() {
  29541. m.expire_at = nil
  29542. m.clearedFields[token.FieldExpireAt] = struct{}{}
  29543. }
  29544. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  29545. func (m *TokenMutation) ExpireAtCleared() bool {
  29546. _, ok := m.clearedFields[token.FieldExpireAt]
  29547. return ok
  29548. }
  29549. // ResetExpireAt resets all changes to the "expire_at" field.
  29550. func (m *TokenMutation) ResetExpireAt() {
  29551. m.expire_at = nil
  29552. delete(m.clearedFields, token.FieldExpireAt)
  29553. }
  29554. // SetToken sets the "token" field.
  29555. func (m *TokenMutation) SetToken(s string) {
  29556. m.token = &s
  29557. }
  29558. // Token returns the value of the "token" field in the mutation.
  29559. func (m *TokenMutation) Token() (r string, exists bool) {
  29560. v := m.token
  29561. if v == nil {
  29562. return
  29563. }
  29564. return *v, true
  29565. }
  29566. // OldToken returns the old "token" field's value of the Token entity.
  29567. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29569. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  29570. if !m.op.Is(OpUpdateOne) {
  29571. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  29572. }
  29573. if m.id == nil || m.oldValue == nil {
  29574. return v, errors.New("OldToken requires an ID field in the mutation")
  29575. }
  29576. oldValue, err := m.oldValue(ctx)
  29577. if err != nil {
  29578. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  29579. }
  29580. return oldValue.Token, nil
  29581. }
  29582. // ClearToken clears the value of the "token" field.
  29583. func (m *TokenMutation) ClearToken() {
  29584. m.token = nil
  29585. m.clearedFields[token.FieldToken] = struct{}{}
  29586. }
  29587. // TokenCleared returns if the "token" field was cleared in this mutation.
  29588. func (m *TokenMutation) TokenCleared() bool {
  29589. _, ok := m.clearedFields[token.FieldToken]
  29590. return ok
  29591. }
  29592. // ResetToken resets all changes to the "token" field.
  29593. func (m *TokenMutation) ResetToken() {
  29594. m.token = nil
  29595. delete(m.clearedFields, token.FieldToken)
  29596. }
  29597. // SetMAC sets the "mac" field.
  29598. func (m *TokenMutation) SetMAC(s string) {
  29599. m.mac = &s
  29600. }
  29601. // MAC returns the value of the "mac" field in the mutation.
  29602. func (m *TokenMutation) MAC() (r string, exists bool) {
  29603. v := m.mac
  29604. if v == nil {
  29605. return
  29606. }
  29607. return *v, true
  29608. }
  29609. // OldMAC returns the old "mac" field's value of the Token entity.
  29610. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29612. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  29613. if !m.op.Is(OpUpdateOne) {
  29614. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  29615. }
  29616. if m.id == nil || m.oldValue == nil {
  29617. return v, errors.New("OldMAC requires an ID field in the mutation")
  29618. }
  29619. oldValue, err := m.oldValue(ctx)
  29620. if err != nil {
  29621. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  29622. }
  29623. return oldValue.MAC, nil
  29624. }
  29625. // ClearMAC clears the value of the "mac" field.
  29626. func (m *TokenMutation) ClearMAC() {
  29627. m.mac = nil
  29628. m.clearedFields[token.FieldMAC] = struct{}{}
  29629. }
  29630. // MACCleared returns if the "mac" field was cleared in this mutation.
  29631. func (m *TokenMutation) MACCleared() bool {
  29632. _, ok := m.clearedFields[token.FieldMAC]
  29633. return ok
  29634. }
  29635. // ResetMAC resets all changes to the "mac" field.
  29636. func (m *TokenMutation) ResetMAC() {
  29637. m.mac = nil
  29638. delete(m.clearedFields, token.FieldMAC)
  29639. }
  29640. // SetOrganizationID sets the "organization_id" field.
  29641. func (m *TokenMutation) SetOrganizationID(u uint64) {
  29642. m.organization_id = &u
  29643. m.addorganization_id = nil
  29644. }
  29645. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29646. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  29647. v := m.organization_id
  29648. if v == nil {
  29649. return
  29650. }
  29651. return *v, true
  29652. }
  29653. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  29654. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29656. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29657. if !m.op.Is(OpUpdateOne) {
  29658. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29659. }
  29660. if m.id == nil || m.oldValue == nil {
  29661. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29662. }
  29663. oldValue, err := m.oldValue(ctx)
  29664. if err != nil {
  29665. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29666. }
  29667. return oldValue.OrganizationID, nil
  29668. }
  29669. // AddOrganizationID adds u to the "organization_id" field.
  29670. func (m *TokenMutation) AddOrganizationID(u int64) {
  29671. if m.addorganization_id != nil {
  29672. *m.addorganization_id += u
  29673. } else {
  29674. m.addorganization_id = &u
  29675. }
  29676. }
  29677. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29678. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  29679. v := m.addorganization_id
  29680. if v == nil {
  29681. return
  29682. }
  29683. return *v, true
  29684. }
  29685. // ResetOrganizationID resets all changes to the "organization_id" field.
  29686. func (m *TokenMutation) ResetOrganizationID() {
  29687. m.organization_id = nil
  29688. m.addorganization_id = nil
  29689. }
  29690. // SetAgentID sets the "agent_id" field.
  29691. func (m *TokenMutation) SetAgentID(u uint64) {
  29692. m.agent = &u
  29693. }
  29694. // AgentID returns the value of the "agent_id" field in the mutation.
  29695. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  29696. v := m.agent
  29697. if v == nil {
  29698. return
  29699. }
  29700. return *v, true
  29701. }
  29702. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  29703. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29705. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  29706. if !m.op.Is(OpUpdateOne) {
  29707. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  29708. }
  29709. if m.id == nil || m.oldValue == nil {
  29710. return v, errors.New("OldAgentID requires an ID field in the mutation")
  29711. }
  29712. oldValue, err := m.oldValue(ctx)
  29713. if err != nil {
  29714. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  29715. }
  29716. return oldValue.AgentID, nil
  29717. }
  29718. // ResetAgentID resets all changes to the "agent_id" field.
  29719. func (m *TokenMutation) ResetAgentID() {
  29720. m.agent = nil
  29721. }
  29722. // SetCustomAgentBase sets the "custom_agent_base" field.
  29723. func (m *TokenMutation) SetCustomAgentBase(s string) {
  29724. m.custom_agent_base = &s
  29725. }
  29726. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  29727. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  29728. v := m.custom_agent_base
  29729. if v == nil {
  29730. return
  29731. }
  29732. return *v, true
  29733. }
  29734. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  29735. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29737. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  29738. if !m.op.Is(OpUpdateOne) {
  29739. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  29740. }
  29741. if m.id == nil || m.oldValue == nil {
  29742. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  29743. }
  29744. oldValue, err := m.oldValue(ctx)
  29745. if err != nil {
  29746. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  29747. }
  29748. return oldValue.CustomAgentBase, nil
  29749. }
  29750. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  29751. func (m *TokenMutation) ClearCustomAgentBase() {
  29752. m.custom_agent_base = nil
  29753. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  29754. }
  29755. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  29756. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  29757. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  29758. return ok
  29759. }
  29760. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  29761. func (m *TokenMutation) ResetCustomAgentBase() {
  29762. m.custom_agent_base = nil
  29763. delete(m.clearedFields, token.FieldCustomAgentBase)
  29764. }
  29765. // SetCustomAgentKey sets the "custom_agent_key" field.
  29766. func (m *TokenMutation) SetCustomAgentKey(s string) {
  29767. m.custom_agent_key = &s
  29768. }
  29769. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  29770. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  29771. v := m.custom_agent_key
  29772. if v == nil {
  29773. return
  29774. }
  29775. return *v, true
  29776. }
  29777. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  29778. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29780. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  29781. if !m.op.Is(OpUpdateOne) {
  29782. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  29783. }
  29784. if m.id == nil || m.oldValue == nil {
  29785. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  29786. }
  29787. oldValue, err := m.oldValue(ctx)
  29788. if err != nil {
  29789. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  29790. }
  29791. return oldValue.CustomAgentKey, nil
  29792. }
  29793. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  29794. func (m *TokenMutation) ClearCustomAgentKey() {
  29795. m.custom_agent_key = nil
  29796. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  29797. }
  29798. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  29799. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  29800. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  29801. return ok
  29802. }
  29803. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  29804. func (m *TokenMutation) ResetCustomAgentKey() {
  29805. m.custom_agent_key = nil
  29806. delete(m.clearedFields, token.FieldCustomAgentKey)
  29807. }
  29808. // SetOpenaiBase sets the "openai_base" field.
  29809. func (m *TokenMutation) SetOpenaiBase(s string) {
  29810. m.openai_base = &s
  29811. }
  29812. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  29813. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  29814. v := m.openai_base
  29815. if v == nil {
  29816. return
  29817. }
  29818. return *v, true
  29819. }
  29820. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  29821. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29823. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  29824. if !m.op.Is(OpUpdateOne) {
  29825. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  29826. }
  29827. if m.id == nil || m.oldValue == nil {
  29828. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  29829. }
  29830. oldValue, err := m.oldValue(ctx)
  29831. if err != nil {
  29832. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  29833. }
  29834. return oldValue.OpenaiBase, nil
  29835. }
  29836. // ClearOpenaiBase clears the value of the "openai_base" field.
  29837. func (m *TokenMutation) ClearOpenaiBase() {
  29838. m.openai_base = nil
  29839. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  29840. }
  29841. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  29842. func (m *TokenMutation) OpenaiBaseCleared() bool {
  29843. _, ok := m.clearedFields[token.FieldOpenaiBase]
  29844. return ok
  29845. }
  29846. // ResetOpenaiBase resets all changes to the "openai_base" field.
  29847. func (m *TokenMutation) ResetOpenaiBase() {
  29848. m.openai_base = nil
  29849. delete(m.clearedFields, token.FieldOpenaiBase)
  29850. }
  29851. // SetOpenaiKey sets the "openai_key" field.
  29852. func (m *TokenMutation) SetOpenaiKey(s string) {
  29853. m.openai_key = &s
  29854. }
  29855. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  29856. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  29857. v := m.openai_key
  29858. if v == nil {
  29859. return
  29860. }
  29861. return *v, true
  29862. }
  29863. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  29864. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29866. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  29867. if !m.op.Is(OpUpdateOne) {
  29868. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  29869. }
  29870. if m.id == nil || m.oldValue == nil {
  29871. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  29872. }
  29873. oldValue, err := m.oldValue(ctx)
  29874. if err != nil {
  29875. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  29876. }
  29877. return oldValue.OpenaiKey, nil
  29878. }
  29879. // ClearOpenaiKey clears the value of the "openai_key" field.
  29880. func (m *TokenMutation) ClearOpenaiKey() {
  29881. m.openai_key = nil
  29882. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  29883. }
  29884. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  29885. func (m *TokenMutation) OpenaiKeyCleared() bool {
  29886. _, ok := m.clearedFields[token.FieldOpenaiKey]
  29887. return ok
  29888. }
  29889. // ResetOpenaiKey resets all changes to the "openai_key" field.
  29890. func (m *TokenMutation) ResetOpenaiKey() {
  29891. m.openai_key = nil
  29892. delete(m.clearedFields, token.FieldOpenaiKey)
  29893. }
  29894. // ClearAgent clears the "agent" edge to the Agent entity.
  29895. func (m *TokenMutation) ClearAgent() {
  29896. m.clearedagent = true
  29897. m.clearedFields[token.FieldAgentID] = struct{}{}
  29898. }
  29899. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  29900. func (m *TokenMutation) AgentCleared() bool {
  29901. return m.clearedagent
  29902. }
  29903. // AgentIDs returns the "agent" edge IDs in the mutation.
  29904. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29905. // AgentID instead. It exists only for internal usage by the builders.
  29906. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  29907. if id := m.agent; id != nil {
  29908. ids = append(ids, *id)
  29909. }
  29910. return
  29911. }
  29912. // ResetAgent resets all changes to the "agent" edge.
  29913. func (m *TokenMutation) ResetAgent() {
  29914. m.agent = nil
  29915. m.clearedagent = false
  29916. }
  29917. // Where appends a list predicates to the TokenMutation builder.
  29918. func (m *TokenMutation) Where(ps ...predicate.Token) {
  29919. m.predicates = append(m.predicates, ps...)
  29920. }
  29921. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  29922. // users can use type-assertion to append predicates that do not depend on any generated package.
  29923. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  29924. p := make([]predicate.Token, len(ps))
  29925. for i := range ps {
  29926. p[i] = ps[i]
  29927. }
  29928. m.Where(p...)
  29929. }
  29930. // Op returns the operation name.
  29931. func (m *TokenMutation) Op() Op {
  29932. return m.op
  29933. }
  29934. // SetOp allows setting the mutation operation.
  29935. func (m *TokenMutation) SetOp(op Op) {
  29936. m.op = op
  29937. }
  29938. // Type returns the node type of this mutation (Token).
  29939. func (m *TokenMutation) Type() string {
  29940. return m.typ
  29941. }
  29942. // Fields returns all fields that were changed during this mutation. Note that in
  29943. // order to get all numeric fields that were incremented/decremented, call
  29944. // AddedFields().
  29945. func (m *TokenMutation) Fields() []string {
  29946. fields := make([]string, 0, 12)
  29947. if m.created_at != nil {
  29948. fields = append(fields, token.FieldCreatedAt)
  29949. }
  29950. if m.updated_at != nil {
  29951. fields = append(fields, token.FieldUpdatedAt)
  29952. }
  29953. if m.deleted_at != nil {
  29954. fields = append(fields, token.FieldDeletedAt)
  29955. }
  29956. if m.expire_at != nil {
  29957. fields = append(fields, token.FieldExpireAt)
  29958. }
  29959. if m.token != nil {
  29960. fields = append(fields, token.FieldToken)
  29961. }
  29962. if m.mac != nil {
  29963. fields = append(fields, token.FieldMAC)
  29964. }
  29965. if m.organization_id != nil {
  29966. fields = append(fields, token.FieldOrganizationID)
  29967. }
  29968. if m.agent != nil {
  29969. fields = append(fields, token.FieldAgentID)
  29970. }
  29971. if m.custom_agent_base != nil {
  29972. fields = append(fields, token.FieldCustomAgentBase)
  29973. }
  29974. if m.custom_agent_key != nil {
  29975. fields = append(fields, token.FieldCustomAgentKey)
  29976. }
  29977. if m.openai_base != nil {
  29978. fields = append(fields, token.FieldOpenaiBase)
  29979. }
  29980. if m.openai_key != nil {
  29981. fields = append(fields, token.FieldOpenaiKey)
  29982. }
  29983. return fields
  29984. }
  29985. // Field returns the value of a field with the given name. The second boolean
  29986. // return value indicates that this field was not set, or was not defined in the
  29987. // schema.
  29988. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  29989. switch name {
  29990. case token.FieldCreatedAt:
  29991. return m.CreatedAt()
  29992. case token.FieldUpdatedAt:
  29993. return m.UpdatedAt()
  29994. case token.FieldDeletedAt:
  29995. return m.DeletedAt()
  29996. case token.FieldExpireAt:
  29997. return m.ExpireAt()
  29998. case token.FieldToken:
  29999. return m.Token()
  30000. case token.FieldMAC:
  30001. return m.MAC()
  30002. case token.FieldOrganizationID:
  30003. return m.OrganizationID()
  30004. case token.FieldAgentID:
  30005. return m.AgentID()
  30006. case token.FieldCustomAgentBase:
  30007. return m.CustomAgentBase()
  30008. case token.FieldCustomAgentKey:
  30009. return m.CustomAgentKey()
  30010. case token.FieldOpenaiBase:
  30011. return m.OpenaiBase()
  30012. case token.FieldOpenaiKey:
  30013. return m.OpenaiKey()
  30014. }
  30015. return nil, false
  30016. }
  30017. // OldField returns the old value of the field from the database. An error is
  30018. // returned if the mutation operation is not UpdateOne, or the query to the
  30019. // database failed.
  30020. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30021. switch name {
  30022. case token.FieldCreatedAt:
  30023. return m.OldCreatedAt(ctx)
  30024. case token.FieldUpdatedAt:
  30025. return m.OldUpdatedAt(ctx)
  30026. case token.FieldDeletedAt:
  30027. return m.OldDeletedAt(ctx)
  30028. case token.FieldExpireAt:
  30029. return m.OldExpireAt(ctx)
  30030. case token.FieldToken:
  30031. return m.OldToken(ctx)
  30032. case token.FieldMAC:
  30033. return m.OldMAC(ctx)
  30034. case token.FieldOrganizationID:
  30035. return m.OldOrganizationID(ctx)
  30036. case token.FieldAgentID:
  30037. return m.OldAgentID(ctx)
  30038. case token.FieldCustomAgentBase:
  30039. return m.OldCustomAgentBase(ctx)
  30040. case token.FieldCustomAgentKey:
  30041. return m.OldCustomAgentKey(ctx)
  30042. case token.FieldOpenaiBase:
  30043. return m.OldOpenaiBase(ctx)
  30044. case token.FieldOpenaiKey:
  30045. return m.OldOpenaiKey(ctx)
  30046. }
  30047. return nil, fmt.Errorf("unknown Token field %s", name)
  30048. }
  30049. // SetField sets the value of a field with the given name. It returns an error if
  30050. // the field is not defined in the schema, or if the type mismatched the field
  30051. // type.
  30052. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  30053. switch name {
  30054. case token.FieldCreatedAt:
  30055. v, ok := value.(time.Time)
  30056. if !ok {
  30057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30058. }
  30059. m.SetCreatedAt(v)
  30060. return nil
  30061. case token.FieldUpdatedAt:
  30062. v, ok := value.(time.Time)
  30063. if !ok {
  30064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30065. }
  30066. m.SetUpdatedAt(v)
  30067. return nil
  30068. case token.FieldDeletedAt:
  30069. v, ok := value.(time.Time)
  30070. if !ok {
  30071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30072. }
  30073. m.SetDeletedAt(v)
  30074. return nil
  30075. case token.FieldExpireAt:
  30076. v, ok := value.(time.Time)
  30077. if !ok {
  30078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30079. }
  30080. m.SetExpireAt(v)
  30081. return nil
  30082. case token.FieldToken:
  30083. v, ok := value.(string)
  30084. if !ok {
  30085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30086. }
  30087. m.SetToken(v)
  30088. return nil
  30089. case token.FieldMAC:
  30090. v, ok := value.(string)
  30091. if !ok {
  30092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30093. }
  30094. m.SetMAC(v)
  30095. return nil
  30096. case token.FieldOrganizationID:
  30097. v, ok := value.(uint64)
  30098. if !ok {
  30099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30100. }
  30101. m.SetOrganizationID(v)
  30102. return nil
  30103. case token.FieldAgentID:
  30104. v, ok := value.(uint64)
  30105. if !ok {
  30106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30107. }
  30108. m.SetAgentID(v)
  30109. return nil
  30110. case token.FieldCustomAgentBase:
  30111. v, ok := value.(string)
  30112. if !ok {
  30113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30114. }
  30115. m.SetCustomAgentBase(v)
  30116. return nil
  30117. case token.FieldCustomAgentKey:
  30118. v, ok := value.(string)
  30119. if !ok {
  30120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30121. }
  30122. m.SetCustomAgentKey(v)
  30123. return nil
  30124. case token.FieldOpenaiBase:
  30125. v, ok := value.(string)
  30126. if !ok {
  30127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30128. }
  30129. m.SetOpenaiBase(v)
  30130. return nil
  30131. case token.FieldOpenaiKey:
  30132. v, ok := value.(string)
  30133. if !ok {
  30134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30135. }
  30136. m.SetOpenaiKey(v)
  30137. return nil
  30138. }
  30139. return fmt.Errorf("unknown Token field %s", name)
  30140. }
  30141. // AddedFields returns all numeric fields that were incremented/decremented during
  30142. // this mutation.
  30143. func (m *TokenMutation) AddedFields() []string {
  30144. var fields []string
  30145. if m.addorganization_id != nil {
  30146. fields = append(fields, token.FieldOrganizationID)
  30147. }
  30148. return fields
  30149. }
  30150. // AddedField returns the numeric value that was incremented/decremented on a field
  30151. // with the given name. The second boolean return value indicates that this field
  30152. // was not set, or was not defined in the schema.
  30153. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  30154. switch name {
  30155. case token.FieldOrganizationID:
  30156. return m.AddedOrganizationID()
  30157. }
  30158. return nil, false
  30159. }
  30160. // AddField adds the value to the field with the given name. It returns an error if
  30161. // the field is not defined in the schema, or if the type mismatched the field
  30162. // type.
  30163. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  30164. switch name {
  30165. case token.FieldOrganizationID:
  30166. v, ok := value.(int64)
  30167. if !ok {
  30168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30169. }
  30170. m.AddOrganizationID(v)
  30171. return nil
  30172. }
  30173. return fmt.Errorf("unknown Token numeric field %s", name)
  30174. }
  30175. // ClearedFields returns all nullable fields that were cleared during this
  30176. // mutation.
  30177. func (m *TokenMutation) ClearedFields() []string {
  30178. var fields []string
  30179. if m.FieldCleared(token.FieldDeletedAt) {
  30180. fields = append(fields, token.FieldDeletedAt)
  30181. }
  30182. if m.FieldCleared(token.FieldExpireAt) {
  30183. fields = append(fields, token.FieldExpireAt)
  30184. }
  30185. if m.FieldCleared(token.FieldToken) {
  30186. fields = append(fields, token.FieldToken)
  30187. }
  30188. if m.FieldCleared(token.FieldMAC) {
  30189. fields = append(fields, token.FieldMAC)
  30190. }
  30191. if m.FieldCleared(token.FieldCustomAgentBase) {
  30192. fields = append(fields, token.FieldCustomAgentBase)
  30193. }
  30194. if m.FieldCleared(token.FieldCustomAgentKey) {
  30195. fields = append(fields, token.FieldCustomAgentKey)
  30196. }
  30197. if m.FieldCleared(token.FieldOpenaiBase) {
  30198. fields = append(fields, token.FieldOpenaiBase)
  30199. }
  30200. if m.FieldCleared(token.FieldOpenaiKey) {
  30201. fields = append(fields, token.FieldOpenaiKey)
  30202. }
  30203. return fields
  30204. }
  30205. // FieldCleared returns a boolean indicating if a field with the given name was
  30206. // cleared in this mutation.
  30207. func (m *TokenMutation) FieldCleared(name string) bool {
  30208. _, ok := m.clearedFields[name]
  30209. return ok
  30210. }
  30211. // ClearField clears the value of the field with the given name. It returns an
  30212. // error if the field is not defined in the schema.
  30213. func (m *TokenMutation) ClearField(name string) error {
  30214. switch name {
  30215. case token.FieldDeletedAt:
  30216. m.ClearDeletedAt()
  30217. return nil
  30218. case token.FieldExpireAt:
  30219. m.ClearExpireAt()
  30220. return nil
  30221. case token.FieldToken:
  30222. m.ClearToken()
  30223. return nil
  30224. case token.FieldMAC:
  30225. m.ClearMAC()
  30226. return nil
  30227. case token.FieldCustomAgentBase:
  30228. m.ClearCustomAgentBase()
  30229. return nil
  30230. case token.FieldCustomAgentKey:
  30231. m.ClearCustomAgentKey()
  30232. return nil
  30233. case token.FieldOpenaiBase:
  30234. m.ClearOpenaiBase()
  30235. return nil
  30236. case token.FieldOpenaiKey:
  30237. m.ClearOpenaiKey()
  30238. return nil
  30239. }
  30240. return fmt.Errorf("unknown Token nullable field %s", name)
  30241. }
  30242. // ResetField resets all changes in the mutation for the field with the given name.
  30243. // It returns an error if the field is not defined in the schema.
  30244. func (m *TokenMutation) ResetField(name string) error {
  30245. switch name {
  30246. case token.FieldCreatedAt:
  30247. m.ResetCreatedAt()
  30248. return nil
  30249. case token.FieldUpdatedAt:
  30250. m.ResetUpdatedAt()
  30251. return nil
  30252. case token.FieldDeletedAt:
  30253. m.ResetDeletedAt()
  30254. return nil
  30255. case token.FieldExpireAt:
  30256. m.ResetExpireAt()
  30257. return nil
  30258. case token.FieldToken:
  30259. m.ResetToken()
  30260. return nil
  30261. case token.FieldMAC:
  30262. m.ResetMAC()
  30263. return nil
  30264. case token.FieldOrganizationID:
  30265. m.ResetOrganizationID()
  30266. return nil
  30267. case token.FieldAgentID:
  30268. m.ResetAgentID()
  30269. return nil
  30270. case token.FieldCustomAgentBase:
  30271. m.ResetCustomAgentBase()
  30272. return nil
  30273. case token.FieldCustomAgentKey:
  30274. m.ResetCustomAgentKey()
  30275. return nil
  30276. case token.FieldOpenaiBase:
  30277. m.ResetOpenaiBase()
  30278. return nil
  30279. case token.FieldOpenaiKey:
  30280. m.ResetOpenaiKey()
  30281. return nil
  30282. }
  30283. return fmt.Errorf("unknown Token field %s", name)
  30284. }
  30285. // AddedEdges returns all edge names that were set/added in this mutation.
  30286. func (m *TokenMutation) AddedEdges() []string {
  30287. edges := make([]string, 0, 1)
  30288. if m.agent != nil {
  30289. edges = append(edges, token.EdgeAgent)
  30290. }
  30291. return edges
  30292. }
  30293. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30294. // name in this mutation.
  30295. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  30296. switch name {
  30297. case token.EdgeAgent:
  30298. if id := m.agent; id != nil {
  30299. return []ent.Value{*id}
  30300. }
  30301. }
  30302. return nil
  30303. }
  30304. // RemovedEdges returns all edge names that were removed in this mutation.
  30305. func (m *TokenMutation) RemovedEdges() []string {
  30306. edges := make([]string, 0, 1)
  30307. return edges
  30308. }
  30309. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30310. // the given name in this mutation.
  30311. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  30312. return nil
  30313. }
  30314. // ClearedEdges returns all edge names that were cleared in this mutation.
  30315. func (m *TokenMutation) ClearedEdges() []string {
  30316. edges := make([]string, 0, 1)
  30317. if m.clearedagent {
  30318. edges = append(edges, token.EdgeAgent)
  30319. }
  30320. return edges
  30321. }
  30322. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30323. // was cleared in this mutation.
  30324. func (m *TokenMutation) EdgeCleared(name string) bool {
  30325. switch name {
  30326. case token.EdgeAgent:
  30327. return m.clearedagent
  30328. }
  30329. return false
  30330. }
  30331. // ClearEdge clears the value of the edge with the given name. It returns an error
  30332. // if that edge is not defined in the schema.
  30333. func (m *TokenMutation) ClearEdge(name string) error {
  30334. switch name {
  30335. case token.EdgeAgent:
  30336. m.ClearAgent()
  30337. return nil
  30338. }
  30339. return fmt.Errorf("unknown Token unique edge %s", name)
  30340. }
  30341. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30342. // It returns an error if the edge is not defined in the schema.
  30343. func (m *TokenMutation) ResetEdge(name string) error {
  30344. switch name {
  30345. case token.EdgeAgent:
  30346. m.ResetAgent()
  30347. return nil
  30348. }
  30349. return fmt.Errorf("unknown Token edge %s", name)
  30350. }
  30351. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  30352. type TutorialMutation struct {
  30353. config
  30354. op Op
  30355. typ string
  30356. id *uint64
  30357. created_at *time.Time
  30358. updated_at *time.Time
  30359. deleted_at *time.Time
  30360. index *int
  30361. addindex *int
  30362. title *string
  30363. content *string
  30364. organization_id *uint64
  30365. addorganization_id *int64
  30366. clearedFields map[string]struct{}
  30367. employee *uint64
  30368. clearedemployee bool
  30369. done bool
  30370. oldValue func(context.Context) (*Tutorial, error)
  30371. predicates []predicate.Tutorial
  30372. }
  30373. var _ ent.Mutation = (*TutorialMutation)(nil)
  30374. // tutorialOption allows management of the mutation configuration using functional options.
  30375. type tutorialOption func(*TutorialMutation)
  30376. // newTutorialMutation creates new mutation for the Tutorial entity.
  30377. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  30378. m := &TutorialMutation{
  30379. config: c,
  30380. op: op,
  30381. typ: TypeTutorial,
  30382. clearedFields: make(map[string]struct{}),
  30383. }
  30384. for _, opt := range opts {
  30385. opt(m)
  30386. }
  30387. return m
  30388. }
  30389. // withTutorialID sets the ID field of the mutation.
  30390. func withTutorialID(id uint64) tutorialOption {
  30391. return func(m *TutorialMutation) {
  30392. var (
  30393. err error
  30394. once sync.Once
  30395. value *Tutorial
  30396. )
  30397. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  30398. once.Do(func() {
  30399. if m.done {
  30400. err = errors.New("querying old values post mutation is not allowed")
  30401. } else {
  30402. value, err = m.Client().Tutorial.Get(ctx, id)
  30403. }
  30404. })
  30405. return value, err
  30406. }
  30407. m.id = &id
  30408. }
  30409. }
  30410. // withTutorial sets the old Tutorial of the mutation.
  30411. func withTutorial(node *Tutorial) tutorialOption {
  30412. return func(m *TutorialMutation) {
  30413. m.oldValue = func(context.Context) (*Tutorial, error) {
  30414. return node, nil
  30415. }
  30416. m.id = &node.ID
  30417. }
  30418. }
  30419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30420. // executed in a transaction (ent.Tx), a transactional client is returned.
  30421. func (m TutorialMutation) Client() *Client {
  30422. client := &Client{config: m.config}
  30423. client.init()
  30424. return client
  30425. }
  30426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30427. // it returns an error otherwise.
  30428. func (m TutorialMutation) Tx() (*Tx, error) {
  30429. if _, ok := m.driver.(*txDriver); !ok {
  30430. return nil, errors.New("ent: mutation is not running in a transaction")
  30431. }
  30432. tx := &Tx{config: m.config}
  30433. tx.init()
  30434. return tx, nil
  30435. }
  30436. // SetID sets the value of the id field. Note that this
  30437. // operation is only accepted on creation of Tutorial entities.
  30438. func (m *TutorialMutation) SetID(id uint64) {
  30439. m.id = &id
  30440. }
  30441. // ID returns the ID value in the mutation. Note that the ID is only available
  30442. // if it was provided to the builder or after it was returned from the database.
  30443. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  30444. if m.id == nil {
  30445. return
  30446. }
  30447. return *m.id, true
  30448. }
  30449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30450. // That means, if the mutation is applied within a transaction with an isolation level such
  30451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30452. // or updated by the mutation.
  30453. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  30454. switch {
  30455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30456. id, exists := m.ID()
  30457. if exists {
  30458. return []uint64{id}, nil
  30459. }
  30460. fallthrough
  30461. case m.op.Is(OpUpdate | OpDelete):
  30462. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  30463. default:
  30464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30465. }
  30466. }
  30467. // SetCreatedAt sets the "created_at" field.
  30468. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  30469. m.created_at = &t
  30470. }
  30471. // CreatedAt returns the value of the "created_at" field in the mutation.
  30472. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  30473. v := m.created_at
  30474. if v == nil {
  30475. return
  30476. }
  30477. return *v, true
  30478. }
  30479. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  30480. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30482. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30483. if !m.op.Is(OpUpdateOne) {
  30484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30485. }
  30486. if m.id == nil || m.oldValue == nil {
  30487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30488. }
  30489. oldValue, err := m.oldValue(ctx)
  30490. if err != nil {
  30491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30492. }
  30493. return oldValue.CreatedAt, nil
  30494. }
  30495. // ResetCreatedAt resets all changes to the "created_at" field.
  30496. func (m *TutorialMutation) ResetCreatedAt() {
  30497. m.created_at = nil
  30498. }
  30499. // SetUpdatedAt sets the "updated_at" field.
  30500. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  30501. m.updated_at = &t
  30502. }
  30503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30504. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  30505. v := m.updated_at
  30506. if v == nil {
  30507. return
  30508. }
  30509. return *v, true
  30510. }
  30511. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  30512. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30514. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30515. if !m.op.Is(OpUpdateOne) {
  30516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30517. }
  30518. if m.id == nil || m.oldValue == nil {
  30519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30520. }
  30521. oldValue, err := m.oldValue(ctx)
  30522. if err != nil {
  30523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30524. }
  30525. return oldValue.UpdatedAt, nil
  30526. }
  30527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30528. func (m *TutorialMutation) ResetUpdatedAt() {
  30529. m.updated_at = nil
  30530. }
  30531. // SetDeletedAt sets the "deleted_at" field.
  30532. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  30533. m.deleted_at = &t
  30534. }
  30535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30536. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  30537. v := m.deleted_at
  30538. if v == nil {
  30539. return
  30540. }
  30541. return *v, true
  30542. }
  30543. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  30544. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30546. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30547. if !m.op.Is(OpUpdateOne) {
  30548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30549. }
  30550. if m.id == nil || m.oldValue == nil {
  30551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30552. }
  30553. oldValue, err := m.oldValue(ctx)
  30554. if err != nil {
  30555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30556. }
  30557. return oldValue.DeletedAt, nil
  30558. }
  30559. // ClearDeletedAt clears the value of the "deleted_at" field.
  30560. func (m *TutorialMutation) ClearDeletedAt() {
  30561. m.deleted_at = nil
  30562. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  30563. }
  30564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30565. func (m *TutorialMutation) DeletedAtCleared() bool {
  30566. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  30567. return ok
  30568. }
  30569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30570. func (m *TutorialMutation) ResetDeletedAt() {
  30571. m.deleted_at = nil
  30572. delete(m.clearedFields, tutorial.FieldDeletedAt)
  30573. }
  30574. // SetEmployeeID sets the "employee_id" field.
  30575. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  30576. m.employee = &u
  30577. }
  30578. // EmployeeID returns the value of the "employee_id" field in the mutation.
  30579. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  30580. v := m.employee
  30581. if v == nil {
  30582. return
  30583. }
  30584. return *v, true
  30585. }
  30586. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  30587. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30589. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  30590. if !m.op.Is(OpUpdateOne) {
  30591. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  30592. }
  30593. if m.id == nil || m.oldValue == nil {
  30594. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  30595. }
  30596. oldValue, err := m.oldValue(ctx)
  30597. if err != nil {
  30598. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  30599. }
  30600. return oldValue.EmployeeID, nil
  30601. }
  30602. // ResetEmployeeID resets all changes to the "employee_id" field.
  30603. func (m *TutorialMutation) ResetEmployeeID() {
  30604. m.employee = nil
  30605. }
  30606. // SetIndex sets the "index" field.
  30607. func (m *TutorialMutation) SetIndex(i int) {
  30608. m.index = &i
  30609. m.addindex = nil
  30610. }
  30611. // Index returns the value of the "index" field in the mutation.
  30612. func (m *TutorialMutation) Index() (r int, exists bool) {
  30613. v := m.index
  30614. if v == nil {
  30615. return
  30616. }
  30617. return *v, true
  30618. }
  30619. // OldIndex returns the old "index" field's value of the Tutorial entity.
  30620. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30622. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  30623. if !m.op.Is(OpUpdateOne) {
  30624. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  30625. }
  30626. if m.id == nil || m.oldValue == nil {
  30627. return v, errors.New("OldIndex requires an ID field in the mutation")
  30628. }
  30629. oldValue, err := m.oldValue(ctx)
  30630. if err != nil {
  30631. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  30632. }
  30633. return oldValue.Index, nil
  30634. }
  30635. // AddIndex adds i to the "index" field.
  30636. func (m *TutorialMutation) AddIndex(i int) {
  30637. if m.addindex != nil {
  30638. *m.addindex += i
  30639. } else {
  30640. m.addindex = &i
  30641. }
  30642. }
  30643. // AddedIndex returns the value that was added to the "index" field in this mutation.
  30644. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  30645. v := m.addindex
  30646. if v == nil {
  30647. return
  30648. }
  30649. return *v, true
  30650. }
  30651. // ResetIndex resets all changes to the "index" field.
  30652. func (m *TutorialMutation) ResetIndex() {
  30653. m.index = nil
  30654. m.addindex = nil
  30655. }
  30656. // SetTitle sets the "title" field.
  30657. func (m *TutorialMutation) SetTitle(s string) {
  30658. m.title = &s
  30659. }
  30660. // Title returns the value of the "title" field in the mutation.
  30661. func (m *TutorialMutation) Title() (r string, exists bool) {
  30662. v := m.title
  30663. if v == nil {
  30664. return
  30665. }
  30666. return *v, true
  30667. }
  30668. // OldTitle returns the old "title" field's value of the Tutorial entity.
  30669. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30671. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  30672. if !m.op.Is(OpUpdateOne) {
  30673. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  30674. }
  30675. if m.id == nil || m.oldValue == nil {
  30676. return v, errors.New("OldTitle requires an ID field in the mutation")
  30677. }
  30678. oldValue, err := m.oldValue(ctx)
  30679. if err != nil {
  30680. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  30681. }
  30682. return oldValue.Title, nil
  30683. }
  30684. // ResetTitle resets all changes to the "title" field.
  30685. func (m *TutorialMutation) ResetTitle() {
  30686. m.title = nil
  30687. }
  30688. // SetContent sets the "content" field.
  30689. func (m *TutorialMutation) SetContent(s string) {
  30690. m.content = &s
  30691. }
  30692. // Content returns the value of the "content" field in the mutation.
  30693. func (m *TutorialMutation) Content() (r string, exists bool) {
  30694. v := m.content
  30695. if v == nil {
  30696. return
  30697. }
  30698. return *v, true
  30699. }
  30700. // OldContent returns the old "content" field's value of the Tutorial entity.
  30701. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30703. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  30704. if !m.op.Is(OpUpdateOne) {
  30705. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  30706. }
  30707. if m.id == nil || m.oldValue == nil {
  30708. return v, errors.New("OldContent requires an ID field in the mutation")
  30709. }
  30710. oldValue, err := m.oldValue(ctx)
  30711. if err != nil {
  30712. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  30713. }
  30714. return oldValue.Content, nil
  30715. }
  30716. // ResetContent resets all changes to the "content" field.
  30717. func (m *TutorialMutation) ResetContent() {
  30718. m.content = nil
  30719. }
  30720. // SetOrganizationID sets the "organization_id" field.
  30721. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  30722. m.organization_id = &u
  30723. m.addorganization_id = nil
  30724. }
  30725. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30726. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  30727. v := m.organization_id
  30728. if v == nil {
  30729. return
  30730. }
  30731. return *v, true
  30732. }
  30733. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  30734. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30736. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30737. if !m.op.Is(OpUpdateOne) {
  30738. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30739. }
  30740. if m.id == nil || m.oldValue == nil {
  30741. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30742. }
  30743. oldValue, err := m.oldValue(ctx)
  30744. if err != nil {
  30745. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30746. }
  30747. return oldValue.OrganizationID, nil
  30748. }
  30749. // AddOrganizationID adds u to the "organization_id" field.
  30750. func (m *TutorialMutation) AddOrganizationID(u int64) {
  30751. if m.addorganization_id != nil {
  30752. *m.addorganization_id += u
  30753. } else {
  30754. m.addorganization_id = &u
  30755. }
  30756. }
  30757. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30758. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  30759. v := m.addorganization_id
  30760. if v == nil {
  30761. return
  30762. }
  30763. return *v, true
  30764. }
  30765. // ResetOrganizationID resets all changes to the "organization_id" field.
  30766. func (m *TutorialMutation) ResetOrganizationID() {
  30767. m.organization_id = nil
  30768. m.addorganization_id = nil
  30769. }
  30770. // ClearEmployee clears the "employee" edge to the Employee entity.
  30771. func (m *TutorialMutation) ClearEmployee() {
  30772. m.clearedemployee = true
  30773. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  30774. }
  30775. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30776. func (m *TutorialMutation) EmployeeCleared() bool {
  30777. return m.clearedemployee
  30778. }
  30779. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30780. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30781. // EmployeeID instead. It exists only for internal usage by the builders.
  30782. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  30783. if id := m.employee; id != nil {
  30784. ids = append(ids, *id)
  30785. }
  30786. return
  30787. }
  30788. // ResetEmployee resets all changes to the "employee" edge.
  30789. func (m *TutorialMutation) ResetEmployee() {
  30790. m.employee = nil
  30791. m.clearedemployee = false
  30792. }
  30793. // Where appends a list predicates to the TutorialMutation builder.
  30794. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  30795. m.predicates = append(m.predicates, ps...)
  30796. }
  30797. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  30798. // users can use type-assertion to append predicates that do not depend on any generated package.
  30799. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  30800. p := make([]predicate.Tutorial, len(ps))
  30801. for i := range ps {
  30802. p[i] = ps[i]
  30803. }
  30804. m.Where(p...)
  30805. }
  30806. // Op returns the operation name.
  30807. func (m *TutorialMutation) Op() Op {
  30808. return m.op
  30809. }
  30810. // SetOp allows setting the mutation operation.
  30811. func (m *TutorialMutation) SetOp(op Op) {
  30812. m.op = op
  30813. }
  30814. // Type returns the node type of this mutation (Tutorial).
  30815. func (m *TutorialMutation) Type() string {
  30816. return m.typ
  30817. }
  30818. // Fields returns all fields that were changed during this mutation. Note that in
  30819. // order to get all numeric fields that were incremented/decremented, call
  30820. // AddedFields().
  30821. func (m *TutorialMutation) Fields() []string {
  30822. fields := make([]string, 0, 8)
  30823. if m.created_at != nil {
  30824. fields = append(fields, tutorial.FieldCreatedAt)
  30825. }
  30826. if m.updated_at != nil {
  30827. fields = append(fields, tutorial.FieldUpdatedAt)
  30828. }
  30829. if m.deleted_at != nil {
  30830. fields = append(fields, tutorial.FieldDeletedAt)
  30831. }
  30832. if m.employee != nil {
  30833. fields = append(fields, tutorial.FieldEmployeeID)
  30834. }
  30835. if m.index != nil {
  30836. fields = append(fields, tutorial.FieldIndex)
  30837. }
  30838. if m.title != nil {
  30839. fields = append(fields, tutorial.FieldTitle)
  30840. }
  30841. if m.content != nil {
  30842. fields = append(fields, tutorial.FieldContent)
  30843. }
  30844. if m.organization_id != nil {
  30845. fields = append(fields, tutorial.FieldOrganizationID)
  30846. }
  30847. return fields
  30848. }
  30849. // Field returns the value of a field with the given name. The second boolean
  30850. // return value indicates that this field was not set, or was not defined in the
  30851. // schema.
  30852. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  30853. switch name {
  30854. case tutorial.FieldCreatedAt:
  30855. return m.CreatedAt()
  30856. case tutorial.FieldUpdatedAt:
  30857. return m.UpdatedAt()
  30858. case tutorial.FieldDeletedAt:
  30859. return m.DeletedAt()
  30860. case tutorial.FieldEmployeeID:
  30861. return m.EmployeeID()
  30862. case tutorial.FieldIndex:
  30863. return m.Index()
  30864. case tutorial.FieldTitle:
  30865. return m.Title()
  30866. case tutorial.FieldContent:
  30867. return m.Content()
  30868. case tutorial.FieldOrganizationID:
  30869. return m.OrganizationID()
  30870. }
  30871. return nil, false
  30872. }
  30873. // OldField returns the old value of the field from the database. An error is
  30874. // returned if the mutation operation is not UpdateOne, or the query to the
  30875. // database failed.
  30876. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30877. switch name {
  30878. case tutorial.FieldCreatedAt:
  30879. return m.OldCreatedAt(ctx)
  30880. case tutorial.FieldUpdatedAt:
  30881. return m.OldUpdatedAt(ctx)
  30882. case tutorial.FieldDeletedAt:
  30883. return m.OldDeletedAt(ctx)
  30884. case tutorial.FieldEmployeeID:
  30885. return m.OldEmployeeID(ctx)
  30886. case tutorial.FieldIndex:
  30887. return m.OldIndex(ctx)
  30888. case tutorial.FieldTitle:
  30889. return m.OldTitle(ctx)
  30890. case tutorial.FieldContent:
  30891. return m.OldContent(ctx)
  30892. case tutorial.FieldOrganizationID:
  30893. return m.OldOrganizationID(ctx)
  30894. }
  30895. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  30896. }
  30897. // SetField sets the value of a field with the given name. It returns an error if
  30898. // the field is not defined in the schema, or if the type mismatched the field
  30899. // type.
  30900. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  30901. switch name {
  30902. case tutorial.FieldCreatedAt:
  30903. v, ok := value.(time.Time)
  30904. if !ok {
  30905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30906. }
  30907. m.SetCreatedAt(v)
  30908. return nil
  30909. case tutorial.FieldUpdatedAt:
  30910. v, ok := value.(time.Time)
  30911. if !ok {
  30912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30913. }
  30914. m.SetUpdatedAt(v)
  30915. return nil
  30916. case tutorial.FieldDeletedAt:
  30917. v, ok := value.(time.Time)
  30918. if !ok {
  30919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30920. }
  30921. m.SetDeletedAt(v)
  30922. return nil
  30923. case tutorial.FieldEmployeeID:
  30924. v, ok := value.(uint64)
  30925. if !ok {
  30926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30927. }
  30928. m.SetEmployeeID(v)
  30929. return nil
  30930. case tutorial.FieldIndex:
  30931. v, ok := value.(int)
  30932. if !ok {
  30933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30934. }
  30935. m.SetIndex(v)
  30936. return nil
  30937. case tutorial.FieldTitle:
  30938. v, ok := value.(string)
  30939. if !ok {
  30940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30941. }
  30942. m.SetTitle(v)
  30943. return nil
  30944. case tutorial.FieldContent:
  30945. v, ok := value.(string)
  30946. if !ok {
  30947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30948. }
  30949. m.SetContent(v)
  30950. return nil
  30951. case tutorial.FieldOrganizationID:
  30952. v, ok := value.(uint64)
  30953. if !ok {
  30954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30955. }
  30956. m.SetOrganizationID(v)
  30957. return nil
  30958. }
  30959. return fmt.Errorf("unknown Tutorial field %s", name)
  30960. }
  30961. // AddedFields returns all numeric fields that were incremented/decremented during
  30962. // this mutation.
  30963. func (m *TutorialMutation) AddedFields() []string {
  30964. var fields []string
  30965. if m.addindex != nil {
  30966. fields = append(fields, tutorial.FieldIndex)
  30967. }
  30968. if m.addorganization_id != nil {
  30969. fields = append(fields, tutorial.FieldOrganizationID)
  30970. }
  30971. return fields
  30972. }
  30973. // AddedField returns the numeric value that was incremented/decremented on a field
  30974. // with the given name. The second boolean return value indicates that this field
  30975. // was not set, or was not defined in the schema.
  30976. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  30977. switch name {
  30978. case tutorial.FieldIndex:
  30979. return m.AddedIndex()
  30980. case tutorial.FieldOrganizationID:
  30981. return m.AddedOrganizationID()
  30982. }
  30983. return nil, false
  30984. }
  30985. // AddField adds the value to the field with the given name. It returns an error if
  30986. // the field is not defined in the schema, or if the type mismatched the field
  30987. // type.
  30988. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  30989. switch name {
  30990. case tutorial.FieldIndex:
  30991. v, ok := value.(int)
  30992. if !ok {
  30993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30994. }
  30995. m.AddIndex(v)
  30996. return nil
  30997. case tutorial.FieldOrganizationID:
  30998. v, ok := value.(int64)
  30999. if !ok {
  31000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31001. }
  31002. m.AddOrganizationID(v)
  31003. return nil
  31004. }
  31005. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  31006. }
  31007. // ClearedFields returns all nullable fields that were cleared during this
  31008. // mutation.
  31009. func (m *TutorialMutation) ClearedFields() []string {
  31010. var fields []string
  31011. if m.FieldCleared(tutorial.FieldDeletedAt) {
  31012. fields = append(fields, tutorial.FieldDeletedAt)
  31013. }
  31014. return fields
  31015. }
  31016. // FieldCleared returns a boolean indicating if a field with the given name was
  31017. // cleared in this mutation.
  31018. func (m *TutorialMutation) FieldCleared(name string) bool {
  31019. _, ok := m.clearedFields[name]
  31020. return ok
  31021. }
  31022. // ClearField clears the value of the field with the given name. It returns an
  31023. // error if the field is not defined in the schema.
  31024. func (m *TutorialMutation) ClearField(name string) error {
  31025. switch name {
  31026. case tutorial.FieldDeletedAt:
  31027. m.ClearDeletedAt()
  31028. return nil
  31029. }
  31030. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  31031. }
  31032. // ResetField resets all changes in the mutation for the field with the given name.
  31033. // It returns an error if the field is not defined in the schema.
  31034. func (m *TutorialMutation) ResetField(name string) error {
  31035. switch name {
  31036. case tutorial.FieldCreatedAt:
  31037. m.ResetCreatedAt()
  31038. return nil
  31039. case tutorial.FieldUpdatedAt:
  31040. m.ResetUpdatedAt()
  31041. return nil
  31042. case tutorial.FieldDeletedAt:
  31043. m.ResetDeletedAt()
  31044. return nil
  31045. case tutorial.FieldEmployeeID:
  31046. m.ResetEmployeeID()
  31047. return nil
  31048. case tutorial.FieldIndex:
  31049. m.ResetIndex()
  31050. return nil
  31051. case tutorial.FieldTitle:
  31052. m.ResetTitle()
  31053. return nil
  31054. case tutorial.FieldContent:
  31055. m.ResetContent()
  31056. return nil
  31057. case tutorial.FieldOrganizationID:
  31058. m.ResetOrganizationID()
  31059. return nil
  31060. }
  31061. return fmt.Errorf("unknown Tutorial field %s", name)
  31062. }
  31063. // AddedEdges returns all edge names that were set/added in this mutation.
  31064. func (m *TutorialMutation) AddedEdges() []string {
  31065. edges := make([]string, 0, 1)
  31066. if m.employee != nil {
  31067. edges = append(edges, tutorial.EdgeEmployee)
  31068. }
  31069. return edges
  31070. }
  31071. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31072. // name in this mutation.
  31073. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  31074. switch name {
  31075. case tutorial.EdgeEmployee:
  31076. if id := m.employee; id != nil {
  31077. return []ent.Value{*id}
  31078. }
  31079. }
  31080. return nil
  31081. }
  31082. // RemovedEdges returns all edge names that were removed in this mutation.
  31083. func (m *TutorialMutation) RemovedEdges() []string {
  31084. edges := make([]string, 0, 1)
  31085. return edges
  31086. }
  31087. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31088. // the given name in this mutation.
  31089. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  31090. return nil
  31091. }
  31092. // ClearedEdges returns all edge names that were cleared in this mutation.
  31093. func (m *TutorialMutation) ClearedEdges() []string {
  31094. edges := make([]string, 0, 1)
  31095. if m.clearedemployee {
  31096. edges = append(edges, tutorial.EdgeEmployee)
  31097. }
  31098. return edges
  31099. }
  31100. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31101. // was cleared in this mutation.
  31102. func (m *TutorialMutation) EdgeCleared(name string) bool {
  31103. switch name {
  31104. case tutorial.EdgeEmployee:
  31105. return m.clearedemployee
  31106. }
  31107. return false
  31108. }
  31109. // ClearEdge clears the value of the edge with the given name. It returns an error
  31110. // if that edge is not defined in the schema.
  31111. func (m *TutorialMutation) ClearEdge(name string) error {
  31112. switch name {
  31113. case tutorial.EdgeEmployee:
  31114. m.ClearEmployee()
  31115. return nil
  31116. }
  31117. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  31118. }
  31119. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31120. // It returns an error if the edge is not defined in the schema.
  31121. func (m *TutorialMutation) ResetEdge(name string) error {
  31122. switch name {
  31123. case tutorial.EdgeEmployee:
  31124. m.ResetEmployee()
  31125. return nil
  31126. }
  31127. return fmt.Errorf("unknown Tutorial edge %s", name)
  31128. }
  31129. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  31130. type UsageDetailMutation struct {
  31131. config
  31132. op Op
  31133. typ string
  31134. id *uint64
  31135. created_at *time.Time
  31136. updated_at *time.Time
  31137. status *uint8
  31138. addstatus *int8
  31139. _type *int
  31140. add_type *int
  31141. bot_id *string
  31142. receiver_id *string
  31143. app *int
  31144. addapp *int
  31145. session_id *uint64
  31146. addsession_id *int64
  31147. request *string
  31148. response *string
  31149. original_data *custom_types.OriginalData
  31150. total_tokens *uint64
  31151. addtotal_tokens *int64
  31152. prompt_tokens *uint64
  31153. addprompt_tokens *int64
  31154. completion_tokens *uint64
  31155. addcompletion_tokens *int64
  31156. organization_id *uint64
  31157. addorganization_id *int64
  31158. clearedFields map[string]struct{}
  31159. done bool
  31160. oldValue func(context.Context) (*UsageDetail, error)
  31161. predicates []predicate.UsageDetail
  31162. }
  31163. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  31164. // usagedetailOption allows management of the mutation configuration using functional options.
  31165. type usagedetailOption func(*UsageDetailMutation)
  31166. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  31167. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  31168. m := &UsageDetailMutation{
  31169. config: c,
  31170. op: op,
  31171. typ: TypeUsageDetail,
  31172. clearedFields: make(map[string]struct{}),
  31173. }
  31174. for _, opt := range opts {
  31175. opt(m)
  31176. }
  31177. return m
  31178. }
  31179. // withUsageDetailID sets the ID field of the mutation.
  31180. func withUsageDetailID(id uint64) usagedetailOption {
  31181. return func(m *UsageDetailMutation) {
  31182. var (
  31183. err error
  31184. once sync.Once
  31185. value *UsageDetail
  31186. )
  31187. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  31188. once.Do(func() {
  31189. if m.done {
  31190. err = errors.New("querying old values post mutation is not allowed")
  31191. } else {
  31192. value, err = m.Client().UsageDetail.Get(ctx, id)
  31193. }
  31194. })
  31195. return value, err
  31196. }
  31197. m.id = &id
  31198. }
  31199. }
  31200. // withUsageDetail sets the old UsageDetail of the mutation.
  31201. func withUsageDetail(node *UsageDetail) usagedetailOption {
  31202. return func(m *UsageDetailMutation) {
  31203. m.oldValue = func(context.Context) (*UsageDetail, error) {
  31204. return node, nil
  31205. }
  31206. m.id = &node.ID
  31207. }
  31208. }
  31209. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31210. // executed in a transaction (ent.Tx), a transactional client is returned.
  31211. func (m UsageDetailMutation) Client() *Client {
  31212. client := &Client{config: m.config}
  31213. client.init()
  31214. return client
  31215. }
  31216. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31217. // it returns an error otherwise.
  31218. func (m UsageDetailMutation) Tx() (*Tx, error) {
  31219. if _, ok := m.driver.(*txDriver); !ok {
  31220. return nil, errors.New("ent: mutation is not running in a transaction")
  31221. }
  31222. tx := &Tx{config: m.config}
  31223. tx.init()
  31224. return tx, nil
  31225. }
  31226. // SetID sets the value of the id field. Note that this
  31227. // operation is only accepted on creation of UsageDetail entities.
  31228. func (m *UsageDetailMutation) SetID(id uint64) {
  31229. m.id = &id
  31230. }
  31231. // ID returns the ID value in the mutation. Note that the ID is only available
  31232. // if it was provided to the builder or after it was returned from the database.
  31233. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  31234. if m.id == nil {
  31235. return
  31236. }
  31237. return *m.id, true
  31238. }
  31239. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31240. // That means, if the mutation is applied within a transaction with an isolation level such
  31241. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31242. // or updated by the mutation.
  31243. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  31244. switch {
  31245. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31246. id, exists := m.ID()
  31247. if exists {
  31248. return []uint64{id}, nil
  31249. }
  31250. fallthrough
  31251. case m.op.Is(OpUpdate | OpDelete):
  31252. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  31253. default:
  31254. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31255. }
  31256. }
  31257. // SetCreatedAt sets the "created_at" field.
  31258. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  31259. m.created_at = &t
  31260. }
  31261. // CreatedAt returns the value of the "created_at" field in the mutation.
  31262. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  31263. v := m.created_at
  31264. if v == nil {
  31265. return
  31266. }
  31267. return *v, true
  31268. }
  31269. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  31270. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31272. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31273. if !m.op.Is(OpUpdateOne) {
  31274. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31275. }
  31276. if m.id == nil || m.oldValue == nil {
  31277. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31278. }
  31279. oldValue, err := m.oldValue(ctx)
  31280. if err != nil {
  31281. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31282. }
  31283. return oldValue.CreatedAt, nil
  31284. }
  31285. // ResetCreatedAt resets all changes to the "created_at" field.
  31286. func (m *UsageDetailMutation) ResetCreatedAt() {
  31287. m.created_at = nil
  31288. }
  31289. // SetUpdatedAt sets the "updated_at" field.
  31290. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  31291. m.updated_at = &t
  31292. }
  31293. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31294. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  31295. v := m.updated_at
  31296. if v == nil {
  31297. return
  31298. }
  31299. return *v, true
  31300. }
  31301. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  31302. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31304. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31305. if !m.op.Is(OpUpdateOne) {
  31306. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31307. }
  31308. if m.id == nil || m.oldValue == nil {
  31309. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31310. }
  31311. oldValue, err := m.oldValue(ctx)
  31312. if err != nil {
  31313. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31314. }
  31315. return oldValue.UpdatedAt, nil
  31316. }
  31317. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31318. func (m *UsageDetailMutation) ResetUpdatedAt() {
  31319. m.updated_at = nil
  31320. }
  31321. // SetStatus sets the "status" field.
  31322. func (m *UsageDetailMutation) SetStatus(u uint8) {
  31323. m.status = &u
  31324. m.addstatus = nil
  31325. }
  31326. // Status returns the value of the "status" field in the mutation.
  31327. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  31328. v := m.status
  31329. if v == nil {
  31330. return
  31331. }
  31332. return *v, true
  31333. }
  31334. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  31335. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31337. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31338. if !m.op.Is(OpUpdateOne) {
  31339. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31340. }
  31341. if m.id == nil || m.oldValue == nil {
  31342. return v, errors.New("OldStatus requires an ID field in the mutation")
  31343. }
  31344. oldValue, err := m.oldValue(ctx)
  31345. if err != nil {
  31346. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31347. }
  31348. return oldValue.Status, nil
  31349. }
  31350. // AddStatus adds u to the "status" field.
  31351. func (m *UsageDetailMutation) AddStatus(u int8) {
  31352. if m.addstatus != nil {
  31353. *m.addstatus += u
  31354. } else {
  31355. m.addstatus = &u
  31356. }
  31357. }
  31358. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31359. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  31360. v := m.addstatus
  31361. if v == nil {
  31362. return
  31363. }
  31364. return *v, true
  31365. }
  31366. // ClearStatus clears the value of the "status" field.
  31367. func (m *UsageDetailMutation) ClearStatus() {
  31368. m.status = nil
  31369. m.addstatus = nil
  31370. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  31371. }
  31372. // StatusCleared returns if the "status" field was cleared in this mutation.
  31373. func (m *UsageDetailMutation) StatusCleared() bool {
  31374. _, ok := m.clearedFields[usagedetail.FieldStatus]
  31375. return ok
  31376. }
  31377. // ResetStatus resets all changes to the "status" field.
  31378. func (m *UsageDetailMutation) ResetStatus() {
  31379. m.status = nil
  31380. m.addstatus = nil
  31381. delete(m.clearedFields, usagedetail.FieldStatus)
  31382. }
  31383. // SetType sets the "type" field.
  31384. func (m *UsageDetailMutation) SetType(i int) {
  31385. m._type = &i
  31386. m.add_type = nil
  31387. }
  31388. // GetType returns the value of the "type" field in the mutation.
  31389. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  31390. v := m._type
  31391. if v == nil {
  31392. return
  31393. }
  31394. return *v, true
  31395. }
  31396. // OldType returns the old "type" field's value of the UsageDetail entity.
  31397. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31399. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  31400. if !m.op.Is(OpUpdateOne) {
  31401. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31402. }
  31403. if m.id == nil || m.oldValue == nil {
  31404. return v, errors.New("OldType requires an ID field in the mutation")
  31405. }
  31406. oldValue, err := m.oldValue(ctx)
  31407. if err != nil {
  31408. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31409. }
  31410. return oldValue.Type, nil
  31411. }
  31412. // AddType adds i to the "type" field.
  31413. func (m *UsageDetailMutation) AddType(i int) {
  31414. if m.add_type != nil {
  31415. *m.add_type += i
  31416. } else {
  31417. m.add_type = &i
  31418. }
  31419. }
  31420. // AddedType returns the value that was added to the "type" field in this mutation.
  31421. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  31422. v := m.add_type
  31423. if v == nil {
  31424. return
  31425. }
  31426. return *v, true
  31427. }
  31428. // ClearType clears the value of the "type" field.
  31429. func (m *UsageDetailMutation) ClearType() {
  31430. m._type = nil
  31431. m.add_type = nil
  31432. m.clearedFields[usagedetail.FieldType] = struct{}{}
  31433. }
  31434. // TypeCleared returns if the "type" field was cleared in this mutation.
  31435. func (m *UsageDetailMutation) TypeCleared() bool {
  31436. _, ok := m.clearedFields[usagedetail.FieldType]
  31437. return ok
  31438. }
  31439. // ResetType resets all changes to the "type" field.
  31440. func (m *UsageDetailMutation) ResetType() {
  31441. m._type = nil
  31442. m.add_type = nil
  31443. delete(m.clearedFields, usagedetail.FieldType)
  31444. }
  31445. // SetBotID sets the "bot_id" field.
  31446. func (m *UsageDetailMutation) SetBotID(s string) {
  31447. m.bot_id = &s
  31448. }
  31449. // BotID returns the value of the "bot_id" field in the mutation.
  31450. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  31451. v := m.bot_id
  31452. if v == nil {
  31453. return
  31454. }
  31455. return *v, true
  31456. }
  31457. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  31458. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31460. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  31461. if !m.op.Is(OpUpdateOne) {
  31462. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31463. }
  31464. if m.id == nil || m.oldValue == nil {
  31465. return v, errors.New("OldBotID requires an ID field in the mutation")
  31466. }
  31467. oldValue, err := m.oldValue(ctx)
  31468. if err != nil {
  31469. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31470. }
  31471. return oldValue.BotID, nil
  31472. }
  31473. // ResetBotID resets all changes to the "bot_id" field.
  31474. func (m *UsageDetailMutation) ResetBotID() {
  31475. m.bot_id = nil
  31476. }
  31477. // SetReceiverID sets the "receiver_id" field.
  31478. func (m *UsageDetailMutation) SetReceiverID(s string) {
  31479. m.receiver_id = &s
  31480. }
  31481. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  31482. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  31483. v := m.receiver_id
  31484. if v == nil {
  31485. return
  31486. }
  31487. return *v, true
  31488. }
  31489. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  31490. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31492. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  31493. if !m.op.Is(OpUpdateOne) {
  31494. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  31495. }
  31496. if m.id == nil || m.oldValue == nil {
  31497. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  31498. }
  31499. oldValue, err := m.oldValue(ctx)
  31500. if err != nil {
  31501. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  31502. }
  31503. return oldValue.ReceiverID, nil
  31504. }
  31505. // ResetReceiverID resets all changes to the "receiver_id" field.
  31506. func (m *UsageDetailMutation) ResetReceiverID() {
  31507. m.receiver_id = nil
  31508. }
  31509. // SetApp sets the "app" field.
  31510. func (m *UsageDetailMutation) SetApp(i int) {
  31511. m.app = &i
  31512. m.addapp = nil
  31513. }
  31514. // App returns the value of the "app" field in the mutation.
  31515. func (m *UsageDetailMutation) App() (r int, exists bool) {
  31516. v := m.app
  31517. if v == nil {
  31518. return
  31519. }
  31520. return *v, true
  31521. }
  31522. // OldApp returns the old "app" field's value of the UsageDetail entity.
  31523. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31525. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  31526. if !m.op.Is(OpUpdateOne) {
  31527. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  31528. }
  31529. if m.id == nil || m.oldValue == nil {
  31530. return v, errors.New("OldApp requires an ID field in the mutation")
  31531. }
  31532. oldValue, err := m.oldValue(ctx)
  31533. if err != nil {
  31534. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  31535. }
  31536. return oldValue.App, nil
  31537. }
  31538. // AddApp adds i to the "app" field.
  31539. func (m *UsageDetailMutation) AddApp(i int) {
  31540. if m.addapp != nil {
  31541. *m.addapp += i
  31542. } else {
  31543. m.addapp = &i
  31544. }
  31545. }
  31546. // AddedApp returns the value that was added to the "app" field in this mutation.
  31547. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  31548. v := m.addapp
  31549. if v == nil {
  31550. return
  31551. }
  31552. return *v, true
  31553. }
  31554. // ClearApp clears the value of the "app" field.
  31555. func (m *UsageDetailMutation) ClearApp() {
  31556. m.app = nil
  31557. m.addapp = nil
  31558. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  31559. }
  31560. // AppCleared returns if the "app" field was cleared in this mutation.
  31561. func (m *UsageDetailMutation) AppCleared() bool {
  31562. _, ok := m.clearedFields[usagedetail.FieldApp]
  31563. return ok
  31564. }
  31565. // ResetApp resets all changes to the "app" field.
  31566. func (m *UsageDetailMutation) ResetApp() {
  31567. m.app = nil
  31568. m.addapp = nil
  31569. delete(m.clearedFields, usagedetail.FieldApp)
  31570. }
  31571. // SetSessionID sets the "session_id" field.
  31572. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  31573. m.session_id = &u
  31574. m.addsession_id = nil
  31575. }
  31576. // SessionID returns the value of the "session_id" field in the mutation.
  31577. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  31578. v := m.session_id
  31579. if v == nil {
  31580. return
  31581. }
  31582. return *v, true
  31583. }
  31584. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  31585. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31587. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  31588. if !m.op.Is(OpUpdateOne) {
  31589. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  31590. }
  31591. if m.id == nil || m.oldValue == nil {
  31592. return v, errors.New("OldSessionID requires an ID field in the mutation")
  31593. }
  31594. oldValue, err := m.oldValue(ctx)
  31595. if err != nil {
  31596. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  31597. }
  31598. return oldValue.SessionID, nil
  31599. }
  31600. // AddSessionID adds u to the "session_id" field.
  31601. func (m *UsageDetailMutation) AddSessionID(u int64) {
  31602. if m.addsession_id != nil {
  31603. *m.addsession_id += u
  31604. } else {
  31605. m.addsession_id = &u
  31606. }
  31607. }
  31608. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  31609. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  31610. v := m.addsession_id
  31611. if v == nil {
  31612. return
  31613. }
  31614. return *v, true
  31615. }
  31616. // ClearSessionID clears the value of the "session_id" field.
  31617. func (m *UsageDetailMutation) ClearSessionID() {
  31618. m.session_id = nil
  31619. m.addsession_id = nil
  31620. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  31621. }
  31622. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  31623. func (m *UsageDetailMutation) SessionIDCleared() bool {
  31624. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  31625. return ok
  31626. }
  31627. // ResetSessionID resets all changes to the "session_id" field.
  31628. func (m *UsageDetailMutation) ResetSessionID() {
  31629. m.session_id = nil
  31630. m.addsession_id = nil
  31631. delete(m.clearedFields, usagedetail.FieldSessionID)
  31632. }
  31633. // SetRequest sets the "request" field.
  31634. func (m *UsageDetailMutation) SetRequest(s string) {
  31635. m.request = &s
  31636. }
  31637. // Request returns the value of the "request" field in the mutation.
  31638. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  31639. v := m.request
  31640. if v == nil {
  31641. return
  31642. }
  31643. return *v, true
  31644. }
  31645. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  31646. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31648. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  31649. if !m.op.Is(OpUpdateOne) {
  31650. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  31651. }
  31652. if m.id == nil || m.oldValue == nil {
  31653. return v, errors.New("OldRequest requires an ID field in the mutation")
  31654. }
  31655. oldValue, err := m.oldValue(ctx)
  31656. if err != nil {
  31657. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  31658. }
  31659. return oldValue.Request, nil
  31660. }
  31661. // ResetRequest resets all changes to the "request" field.
  31662. func (m *UsageDetailMutation) ResetRequest() {
  31663. m.request = nil
  31664. }
  31665. // SetResponse sets the "response" field.
  31666. func (m *UsageDetailMutation) SetResponse(s string) {
  31667. m.response = &s
  31668. }
  31669. // Response returns the value of the "response" field in the mutation.
  31670. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  31671. v := m.response
  31672. if v == nil {
  31673. return
  31674. }
  31675. return *v, true
  31676. }
  31677. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  31678. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31680. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  31681. if !m.op.Is(OpUpdateOne) {
  31682. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  31683. }
  31684. if m.id == nil || m.oldValue == nil {
  31685. return v, errors.New("OldResponse requires an ID field in the mutation")
  31686. }
  31687. oldValue, err := m.oldValue(ctx)
  31688. if err != nil {
  31689. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  31690. }
  31691. return oldValue.Response, nil
  31692. }
  31693. // ResetResponse resets all changes to the "response" field.
  31694. func (m *UsageDetailMutation) ResetResponse() {
  31695. m.response = nil
  31696. }
  31697. // SetOriginalData sets the "original_data" field.
  31698. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  31699. m.original_data = &ctd
  31700. }
  31701. // OriginalData returns the value of the "original_data" field in the mutation.
  31702. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  31703. v := m.original_data
  31704. if v == nil {
  31705. return
  31706. }
  31707. return *v, true
  31708. }
  31709. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  31710. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31712. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  31713. if !m.op.Is(OpUpdateOne) {
  31714. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  31715. }
  31716. if m.id == nil || m.oldValue == nil {
  31717. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  31718. }
  31719. oldValue, err := m.oldValue(ctx)
  31720. if err != nil {
  31721. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  31722. }
  31723. return oldValue.OriginalData, nil
  31724. }
  31725. // ResetOriginalData resets all changes to the "original_data" field.
  31726. func (m *UsageDetailMutation) ResetOriginalData() {
  31727. m.original_data = nil
  31728. }
  31729. // SetTotalTokens sets the "total_tokens" field.
  31730. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  31731. m.total_tokens = &u
  31732. m.addtotal_tokens = nil
  31733. }
  31734. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  31735. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  31736. v := m.total_tokens
  31737. if v == nil {
  31738. return
  31739. }
  31740. return *v, true
  31741. }
  31742. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  31743. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31745. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  31746. if !m.op.Is(OpUpdateOne) {
  31747. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  31748. }
  31749. if m.id == nil || m.oldValue == nil {
  31750. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  31751. }
  31752. oldValue, err := m.oldValue(ctx)
  31753. if err != nil {
  31754. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  31755. }
  31756. return oldValue.TotalTokens, nil
  31757. }
  31758. // AddTotalTokens adds u to the "total_tokens" field.
  31759. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  31760. if m.addtotal_tokens != nil {
  31761. *m.addtotal_tokens += u
  31762. } else {
  31763. m.addtotal_tokens = &u
  31764. }
  31765. }
  31766. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  31767. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  31768. v := m.addtotal_tokens
  31769. if v == nil {
  31770. return
  31771. }
  31772. return *v, true
  31773. }
  31774. // ClearTotalTokens clears the value of the "total_tokens" field.
  31775. func (m *UsageDetailMutation) ClearTotalTokens() {
  31776. m.total_tokens = nil
  31777. m.addtotal_tokens = nil
  31778. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  31779. }
  31780. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  31781. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  31782. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  31783. return ok
  31784. }
  31785. // ResetTotalTokens resets all changes to the "total_tokens" field.
  31786. func (m *UsageDetailMutation) ResetTotalTokens() {
  31787. m.total_tokens = nil
  31788. m.addtotal_tokens = nil
  31789. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  31790. }
  31791. // SetPromptTokens sets the "prompt_tokens" field.
  31792. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  31793. m.prompt_tokens = &u
  31794. m.addprompt_tokens = nil
  31795. }
  31796. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  31797. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  31798. v := m.prompt_tokens
  31799. if v == nil {
  31800. return
  31801. }
  31802. return *v, true
  31803. }
  31804. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  31805. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31807. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  31808. if !m.op.Is(OpUpdateOne) {
  31809. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  31810. }
  31811. if m.id == nil || m.oldValue == nil {
  31812. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  31813. }
  31814. oldValue, err := m.oldValue(ctx)
  31815. if err != nil {
  31816. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  31817. }
  31818. return oldValue.PromptTokens, nil
  31819. }
  31820. // AddPromptTokens adds u to the "prompt_tokens" field.
  31821. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  31822. if m.addprompt_tokens != nil {
  31823. *m.addprompt_tokens += u
  31824. } else {
  31825. m.addprompt_tokens = &u
  31826. }
  31827. }
  31828. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  31829. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  31830. v := m.addprompt_tokens
  31831. if v == nil {
  31832. return
  31833. }
  31834. return *v, true
  31835. }
  31836. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  31837. func (m *UsageDetailMutation) ClearPromptTokens() {
  31838. m.prompt_tokens = nil
  31839. m.addprompt_tokens = nil
  31840. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  31841. }
  31842. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  31843. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  31844. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  31845. return ok
  31846. }
  31847. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  31848. func (m *UsageDetailMutation) ResetPromptTokens() {
  31849. m.prompt_tokens = nil
  31850. m.addprompt_tokens = nil
  31851. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  31852. }
  31853. // SetCompletionTokens sets the "completion_tokens" field.
  31854. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  31855. m.completion_tokens = &u
  31856. m.addcompletion_tokens = nil
  31857. }
  31858. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  31859. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  31860. v := m.completion_tokens
  31861. if v == nil {
  31862. return
  31863. }
  31864. return *v, true
  31865. }
  31866. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  31867. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31869. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  31870. if !m.op.Is(OpUpdateOne) {
  31871. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  31872. }
  31873. if m.id == nil || m.oldValue == nil {
  31874. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  31875. }
  31876. oldValue, err := m.oldValue(ctx)
  31877. if err != nil {
  31878. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  31879. }
  31880. return oldValue.CompletionTokens, nil
  31881. }
  31882. // AddCompletionTokens adds u to the "completion_tokens" field.
  31883. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  31884. if m.addcompletion_tokens != nil {
  31885. *m.addcompletion_tokens += u
  31886. } else {
  31887. m.addcompletion_tokens = &u
  31888. }
  31889. }
  31890. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  31891. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  31892. v := m.addcompletion_tokens
  31893. if v == nil {
  31894. return
  31895. }
  31896. return *v, true
  31897. }
  31898. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  31899. func (m *UsageDetailMutation) ClearCompletionTokens() {
  31900. m.completion_tokens = nil
  31901. m.addcompletion_tokens = nil
  31902. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  31903. }
  31904. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  31905. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  31906. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  31907. return ok
  31908. }
  31909. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  31910. func (m *UsageDetailMutation) ResetCompletionTokens() {
  31911. m.completion_tokens = nil
  31912. m.addcompletion_tokens = nil
  31913. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  31914. }
  31915. // SetOrganizationID sets the "organization_id" field.
  31916. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  31917. m.organization_id = &u
  31918. m.addorganization_id = nil
  31919. }
  31920. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31921. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  31922. v := m.organization_id
  31923. if v == nil {
  31924. return
  31925. }
  31926. return *v, true
  31927. }
  31928. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  31929. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31931. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31932. if !m.op.Is(OpUpdateOne) {
  31933. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31934. }
  31935. if m.id == nil || m.oldValue == nil {
  31936. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31937. }
  31938. oldValue, err := m.oldValue(ctx)
  31939. if err != nil {
  31940. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31941. }
  31942. return oldValue.OrganizationID, nil
  31943. }
  31944. // AddOrganizationID adds u to the "organization_id" field.
  31945. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  31946. if m.addorganization_id != nil {
  31947. *m.addorganization_id += u
  31948. } else {
  31949. m.addorganization_id = &u
  31950. }
  31951. }
  31952. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31953. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  31954. v := m.addorganization_id
  31955. if v == nil {
  31956. return
  31957. }
  31958. return *v, true
  31959. }
  31960. // ClearOrganizationID clears the value of the "organization_id" field.
  31961. func (m *UsageDetailMutation) ClearOrganizationID() {
  31962. m.organization_id = nil
  31963. m.addorganization_id = nil
  31964. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  31965. }
  31966. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31967. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  31968. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  31969. return ok
  31970. }
  31971. // ResetOrganizationID resets all changes to the "organization_id" field.
  31972. func (m *UsageDetailMutation) ResetOrganizationID() {
  31973. m.organization_id = nil
  31974. m.addorganization_id = nil
  31975. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  31976. }
  31977. // Where appends a list predicates to the UsageDetailMutation builder.
  31978. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  31979. m.predicates = append(m.predicates, ps...)
  31980. }
  31981. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  31982. // users can use type-assertion to append predicates that do not depend on any generated package.
  31983. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  31984. p := make([]predicate.UsageDetail, len(ps))
  31985. for i := range ps {
  31986. p[i] = ps[i]
  31987. }
  31988. m.Where(p...)
  31989. }
  31990. // Op returns the operation name.
  31991. func (m *UsageDetailMutation) Op() Op {
  31992. return m.op
  31993. }
  31994. // SetOp allows setting the mutation operation.
  31995. func (m *UsageDetailMutation) SetOp(op Op) {
  31996. m.op = op
  31997. }
  31998. // Type returns the node type of this mutation (UsageDetail).
  31999. func (m *UsageDetailMutation) Type() string {
  32000. return m.typ
  32001. }
  32002. // Fields returns all fields that were changed during this mutation. Note that in
  32003. // order to get all numeric fields that were incremented/decremented, call
  32004. // AddedFields().
  32005. func (m *UsageDetailMutation) Fields() []string {
  32006. fields := make([]string, 0, 15)
  32007. if m.created_at != nil {
  32008. fields = append(fields, usagedetail.FieldCreatedAt)
  32009. }
  32010. if m.updated_at != nil {
  32011. fields = append(fields, usagedetail.FieldUpdatedAt)
  32012. }
  32013. if m.status != nil {
  32014. fields = append(fields, usagedetail.FieldStatus)
  32015. }
  32016. if m._type != nil {
  32017. fields = append(fields, usagedetail.FieldType)
  32018. }
  32019. if m.bot_id != nil {
  32020. fields = append(fields, usagedetail.FieldBotID)
  32021. }
  32022. if m.receiver_id != nil {
  32023. fields = append(fields, usagedetail.FieldReceiverID)
  32024. }
  32025. if m.app != nil {
  32026. fields = append(fields, usagedetail.FieldApp)
  32027. }
  32028. if m.session_id != nil {
  32029. fields = append(fields, usagedetail.FieldSessionID)
  32030. }
  32031. if m.request != nil {
  32032. fields = append(fields, usagedetail.FieldRequest)
  32033. }
  32034. if m.response != nil {
  32035. fields = append(fields, usagedetail.FieldResponse)
  32036. }
  32037. if m.original_data != nil {
  32038. fields = append(fields, usagedetail.FieldOriginalData)
  32039. }
  32040. if m.total_tokens != nil {
  32041. fields = append(fields, usagedetail.FieldTotalTokens)
  32042. }
  32043. if m.prompt_tokens != nil {
  32044. fields = append(fields, usagedetail.FieldPromptTokens)
  32045. }
  32046. if m.completion_tokens != nil {
  32047. fields = append(fields, usagedetail.FieldCompletionTokens)
  32048. }
  32049. if m.organization_id != nil {
  32050. fields = append(fields, usagedetail.FieldOrganizationID)
  32051. }
  32052. return fields
  32053. }
  32054. // Field returns the value of a field with the given name. The second boolean
  32055. // return value indicates that this field was not set, or was not defined in the
  32056. // schema.
  32057. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  32058. switch name {
  32059. case usagedetail.FieldCreatedAt:
  32060. return m.CreatedAt()
  32061. case usagedetail.FieldUpdatedAt:
  32062. return m.UpdatedAt()
  32063. case usagedetail.FieldStatus:
  32064. return m.Status()
  32065. case usagedetail.FieldType:
  32066. return m.GetType()
  32067. case usagedetail.FieldBotID:
  32068. return m.BotID()
  32069. case usagedetail.FieldReceiverID:
  32070. return m.ReceiverID()
  32071. case usagedetail.FieldApp:
  32072. return m.App()
  32073. case usagedetail.FieldSessionID:
  32074. return m.SessionID()
  32075. case usagedetail.FieldRequest:
  32076. return m.Request()
  32077. case usagedetail.FieldResponse:
  32078. return m.Response()
  32079. case usagedetail.FieldOriginalData:
  32080. return m.OriginalData()
  32081. case usagedetail.FieldTotalTokens:
  32082. return m.TotalTokens()
  32083. case usagedetail.FieldPromptTokens:
  32084. return m.PromptTokens()
  32085. case usagedetail.FieldCompletionTokens:
  32086. return m.CompletionTokens()
  32087. case usagedetail.FieldOrganizationID:
  32088. return m.OrganizationID()
  32089. }
  32090. return nil, false
  32091. }
  32092. // OldField returns the old value of the field from the database. An error is
  32093. // returned if the mutation operation is not UpdateOne, or the query to the
  32094. // database failed.
  32095. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32096. switch name {
  32097. case usagedetail.FieldCreatedAt:
  32098. return m.OldCreatedAt(ctx)
  32099. case usagedetail.FieldUpdatedAt:
  32100. return m.OldUpdatedAt(ctx)
  32101. case usagedetail.FieldStatus:
  32102. return m.OldStatus(ctx)
  32103. case usagedetail.FieldType:
  32104. return m.OldType(ctx)
  32105. case usagedetail.FieldBotID:
  32106. return m.OldBotID(ctx)
  32107. case usagedetail.FieldReceiverID:
  32108. return m.OldReceiverID(ctx)
  32109. case usagedetail.FieldApp:
  32110. return m.OldApp(ctx)
  32111. case usagedetail.FieldSessionID:
  32112. return m.OldSessionID(ctx)
  32113. case usagedetail.FieldRequest:
  32114. return m.OldRequest(ctx)
  32115. case usagedetail.FieldResponse:
  32116. return m.OldResponse(ctx)
  32117. case usagedetail.FieldOriginalData:
  32118. return m.OldOriginalData(ctx)
  32119. case usagedetail.FieldTotalTokens:
  32120. return m.OldTotalTokens(ctx)
  32121. case usagedetail.FieldPromptTokens:
  32122. return m.OldPromptTokens(ctx)
  32123. case usagedetail.FieldCompletionTokens:
  32124. return m.OldCompletionTokens(ctx)
  32125. case usagedetail.FieldOrganizationID:
  32126. return m.OldOrganizationID(ctx)
  32127. }
  32128. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  32129. }
  32130. // SetField sets the value of a field with the given name. It returns an error if
  32131. // the field is not defined in the schema, or if the type mismatched the field
  32132. // type.
  32133. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  32134. switch name {
  32135. case usagedetail.FieldCreatedAt:
  32136. v, ok := value.(time.Time)
  32137. if !ok {
  32138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32139. }
  32140. m.SetCreatedAt(v)
  32141. return nil
  32142. case usagedetail.FieldUpdatedAt:
  32143. v, ok := value.(time.Time)
  32144. if !ok {
  32145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32146. }
  32147. m.SetUpdatedAt(v)
  32148. return nil
  32149. case usagedetail.FieldStatus:
  32150. v, ok := value.(uint8)
  32151. if !ok {
  32152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32153. }
  32154. m.SetStatus(v)
  32155. return nil
  32156. case usagedetail.FieldType:
  32157. v, ok := value.(int)
  32158. if !ok {
  32159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32160. }
  32161. m.SetType(v)
  32162. return nil
  32163. case usagedetail.FieldBotID:
  32164. v, ok := value.(string)
  32165. if !ok {
  32166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32167. }
  32168. m.SetBotID(v)
  32169. return nil
  32170. case usagedetail.FieldReceiverID:
  32171. v, ok := value.(string)
  32172. if !ok {
  32173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32174. }
  32175. m.SetReceiverID(v)
  32176. return nil
  32177. case usagedetail.FieldApp:
  32178. v, ok := value.(int)
  32179. if !ok {
  32180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32181. }
  32182. m.SetApp(v)
  32183. return nil
  32184. case usagedetail.FieldSessionID:
  32185. v, ok := value.(uint64)
  32186. if !ok {
  32187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32188. }
  32189. m.SetSessionID(v)
  32190. return nil
  32191. case usagedetail.FieldRequest:
  32192. v, ok := value.(string)
  32193. if !ok {
  32194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32195. }
  32196. m.SetRequest(v)
  32197. return nil
  32198. case usagedetail.FieldResponse:
  32199. v, ok := value.(string)
  32200. if !ok {
  32201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32202. }
  32203. m.SetResponse(v)
  32204. return nil
  32205. case usagedetail.FieldOriginalData:
  32206. v, ok := value.(custom_types.OriginalData)
  32207. if !ok {
  32208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32209. }
  32210. m.SetOriginalData(v)
  32211. return nil
  32212. case usagedetail.FieldTotalTokens:
  32213. v, ok := value.(uint64)
  32214. if !ok {
  32215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32216. }
  32217. m.SetTotalTokens(v)
  32218. return nil
  32219. case usagedetail.FieldPromptTokens:
  32220. v, ok := value.(uint64)
  32221. if !ok {
  32222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32223. }
  32224. m.SetPromptTokens(v)
  32225. return nil
  32226. case usagedetail.FieldCompletionTokens:
  32227. v, ok := value.(uint64)
  32228. if !ok {
  32229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32230. }
  32231. m.SetCompletionTokens(v)
  32232. return nil
  32233. case usagedetail.FieldOrganizationID:
  32234. v, ok := value.(uint64)
  32235. if !ok {
  32236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32237. }
  32238. m.SetOrganizationID(v)
  32239. return nil
  32240. }
  32241. return fmt.Errorf("unknown UsageDetail field %s", name)
  32242. }
  32243. // AddedFields returns all numeric fields that were incremented/decremented during
  32244. // this mutation.
  32245. func (m *UsageDetailMutation) AddedFields() []string {
  32246. var fields []string
  32247. if m.addstatus != nil {
  32248. fields = append(fields, usagedetail.FieldStatus)
  32249. }
  32250. if m.add_type != nil {
  32251. fields = append(fields, usagedetail.FieldType)
  32252. }
  32253. if m.addapp != nil {
  32254. fields = append(fields, usagedetail.FieldApp)
  32255. }
  32256. if m.addsession_id != nil {
  32257. fields = append(fields, usagedetail.FieldSessionID)
  32258. }
  32259. if m.addtotal_tokens != nil {
  32260. fields = append(fields, usagedetail.FieldTotalTokens)
  32261. }
  32262. if m.addprompt_tokens != nil {
  32263. fields = append(fields, usagedetail.FieldPromptTokens)
  32264. }
  32265. if m.addcompletion_tokens != nil {
  32266. fields = append(fields, usagedetail.FieldCompletionTokens)
  32267. }
  32268. if m.addorganization_id != nil {
  32269. fields = append(fields, usagedetail.FieldOrganizationID)
  32270. }
  32271. return fields
  32272. }
  32273. // AddedField returns the numeric value that was incremented/decremented on a field
  32274. // with the given name. The second boolean return value indicates that this field
  32275. // was not set, or was not defined in the schema.
  32276. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  32277. switch name {
  32278. case usagedetail.FieldStatus:
  32279. return m.AddedStatus()
  32280. case usagedetail.FieldType:
  32281. return m.AddedType()
  32282. case usagedetail.FieldApp:
  32283. return m.AddedApp()
  32284. case usagedetail.FieldSessionID:
  32285. return m.AddedSessionID()
  32286. case usagedetail.FieldTotalTokens:
  32287. return m.AddedTotalTokens()
  32288. case usagedetail.FieldPromptTokens:
  32289. return m.AddedPromptTokens()
  32290. case usagedetail.FieldCompletionTokens:
  32291. return m.AddedCompletionTokens()
  32292. case usagedetail.FieldOrganizationID:
  32293. return m.AddedOrganizationID()
  32294. }
  32295. return nil, false
  32296. }
  32297. // AddField adds the value to the field with the given name. It returns an error if
  32298. // the field is not defined in the schema, or if the type mismatched the field
  32299. // type.
  32300. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  32301. switch name {
  32302. case usagedetail.FieldStatus:
  32303. v, ok := value.(int8)
  32304. if !ok {
  32305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32306. }
  32307. m.AddStatus(v)
  32308. return nil
  32309. case usagedetail.FieldType:
  32310. v, ok := value.(int)
  32311. if !ok {
  32312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32313. }
  32314. m.AddType(v)
  32315. return nil
  32316. case usagedetail.FieldApp:
  32317. v, ok := value.(int)
  32318. if !ok {
  32319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32320. }
  32321. m.AddApp(v)
  32322. return nil
  32323. case usagedetail.FieldSessionID:
  32324. v, ok := value.(int64)
  32325. if !ok {
  32326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32327. }
  32328. m.AddSessionID(v)
  32329. return nil
  32330. case usagedetail.FieldTotalTokens:
  32331. v, ok := value.(int64)
  32332. if !ok {
  32333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32334. }
  32335. m.AddTotalTokens(v)
  32336. return nil
  32337. case usagedetail.FieldPromptTokens:
  32338. v, ok := value.(int64)
  32339. if !ok {
  32340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32341. }
  32342. m.AddPromptTokens(v)
  32343. return nil
  32344. case usagedetail.FieldCompletionTokens:
  32345. v, ok := value.(int64)
  32346. if !ok {
  32347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32348. }
  32349. m.AddCompletionTokens(v)
  32350. return nil
  32351. case usagedetail.FieldOrganizationID:
  32352. v, ok := value.(int64)
  32353. if !ok {
  32354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32355. }
  32356. m.AddOrganizationID(v)
  32357. return nil
  32358. }
  32359. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  32360. }
  32361. // ClearedFields returns all nullable fields that were cleared during this
  32362. // mutation.
  32363. func (m *UsageDetailMutation) ClearedFields() []string {
  32364. var fields []string
  32365. if m.FieldCleared(usagedetail.FieldStatus) {
  32366. fields = append(fields, usagedetail.FieldStatus)
  32367. }
  32368. if m.FieldCleared(usagedetail.FieldType) {
  32369. fields = append(fields, usagedetail.FieldType)
  32370. }
  32371. if m.FieldCleared(usagedetail.FieldApp) {
  32372. fields = append(fields, usagedetail.FieldApp)
  32373. }
  32374. if m.FieldCleared(usagedetail.FieldSessionID) {
  32375. fields = append(fields, usagedetail.FieldSessionID)
  32376. }
  32377. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  32378. fields = append(fields, usagedetail.FieldTotalTokens)
  32379. }
  32380. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  32381. fields = append(fields, usagedetail.FieldPromptTokens)
  32382. }
  32383. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  32384. fields = append(fields, usagedetail.FieldCompletionTokens)
  32385. }
  32386. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  32387. fields = append(fields, usagedetail.FieldOrganizationID)
  32388. }
  32389. return fields
  32390. }
  32391. // FieldCleared returns a boolean indicating if a field with the given name was
  32392. // cleared in this mutation.
  32393. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  32394. _, ok := m.clearedFields[name]
  32395. return ok
  32396. }
  32397. // ClearField clears the value of the field with the given name. It returns an
  32398. // error if the field is not defined in the schema.
  32399. func (m *UsageDetailMutation) ClearField(name string) error {
  32400. switch name {
  32401. case usagedetail.FieldStatus:
  32402. m.ClearStatus()
  32403. return nil
  32404. case usagedetail.FieldType:
  32405. m.ClearType()
  32406. return nil
  32407. case usagedetail.FieldApp:
  32408. m.ClearApp()
  32409. return nil
  32410. case usagedetail.FieldSessionID:
  32411. m.ClearSessionID()
  32412. return nil
  32413. case usagedetail.FieldTotalTokens:
  32414. m.ClearTotalTokens()
  32415. return nil
  32416. case usagedetail.FieldPromptTokens:
  32417. m.ClearPromptTokens()
  32418. return nil
  32419. case usagedetail.FieldCompletionTokens:
  32420. m.ClearCompletionTokens()
  32421. return nil
  32422. case usagedetail.FieldOrganizationID:
  32423. m.ClearOrganizationID()
  32424. return nil
  32425. }
  32426. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  32427. }
  32428. // ResetField resets all changes in the mutation for the field with the given name.
  32429. // It returns an error if the field is not defined in the schema.
  32430. func (m *UsageDetailMutation) ResetField(name string) error {
  32431. switch name {
  32432. case usagedetail.FieldCreatedAt:
  32433. m.ResetCreatedAt()
  32434. return nil
  32435. case usagedetail.FieldUpdatedAt:
  32436. m.ResetUpdatedAt()
  32437. return nil
  32438. case usagedetail.FieldStatus:
  32439. m.ResetStatus()
  32440. return nil
  32441. case usagedetail.FieldType:
  32442. m.ResetType()
  32443. return nil
  32444. case usagedetail.FieldBotID:
  32445. m.ResetBotID()
  32446. return nil
  32447. case usagedetail.FieldReceiverID:
  32448. m.ResetReceiverID()
  32449. return nil
  32450. case usagedetail.FieldApp:
  32451. m.ResetApp()
  32452. return nil
  32453. case usagedetail.FieldSessionID:
  32454. m.ResetSessionID()
  32455. return nil
  32456. case usagedetail.FieldRequest:
  32457. m.ResetRequest()
  32458. return nil
  32459. case usagedetail.FieldResponse:
  32460. m.ResetResponse()
  32461. return nil
  32462. case usagedetail.FieldOriginalData:
  32463. m.ResetOriginalData()
  32464. return nil
  32465. case usagedetail.FieldTotalTokens:
  32466. m.ResetTotalTokens()
  32467. return nil
  32468. case usagedetail.FieldPromptTokens:
  32469. m.ResetPromptTokens()
  32470. return nil
  32471. case usagedetail.FieldCompletionTokens:
  32472. m.ResetCompletionTokens()
  32473. return nil
  32474. case usagedetail.FieldOrganizationID:
  32475. m.ResetOrganizationID()
  32476. return nil
  32477. }
  32478. return fmt.Errorf("unknown UsageDetail field %s", name)
  32479. }
  32480. // AddedEdges returns all edge names that were set/added in this mutation.
  32481. func (m *UsageDetailMutation) AddedEdges() []string {
  32482. edges := make([]string, 0, 0)
  32483. return edges
  32484. }
  32485. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32486. // name in this mutation.
  32487. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  32488. return nil
  32489. }
  32490. // RemovedEdges returns all edge names that were removed in this mutation.
  32491. func (m *UsageDetailMutation) RemovedEdges() []string {
  32492. edges := make([]string, 0, 0)
  32493. return edges
  32494. }
  32495. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32496. // the given name in this mutation.
  32497. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  32498. return nil
  32499. }
  32500. // ClearedEdges returns all edge names that were cleared in this mutation.
  32501. func (m *UsageDetailMutation) ClearedEdges() []string {
  32502. edges := make([]string, 0, 0)
  32503. return edges
  32504. }
  32505. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32506. // was cleared in this mutation.
  32507. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  32508. return false
  32509. }
  32510. // ClearEdge clears the value of the edge with the given name. It returns an error
  32511. // if that edge is not defined in the schema.
  32512. func (m *UsageDetailMutation) ClearEdge(name string) error {
  32513. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  32514. }
  32515. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32516. // It returns an error if the edge is not defined in the schema.
  32517. func (m *UsageDetailMutation) ResetEdge(name string) error {
  32518. return fmt.Errorf("unknown UsageDetail edge %s", name)
  32519. }
  32520. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  32521. type UsageStatisticDayMutation struct {
  32522. config
  32523. op Op
  32524. typ string
  32525. id *uint64
  32526. created_at *time.Time
  32527. updated_at *time.Time
  32528. status *uint8
  32529. addstatus *int8
  32530. deleted_at *time.Time
  32531. addtime *uint64
  32532. addaddtime *int64
  32533. _type *int
  32534. add_type *int
  32535. bot_id *string
  32536. organization_id *uint64
  32537. addorganization_id *int64
  32538. ai_response *uint64
  32539. addai_response *int64
  32540. sop_run *uint64
  32541. addsop_run *int64
  32542. total_friend *uint64
  32543. addtotal_friend *int64
  32544. total_group *uint64
  32545. addtotal_group *int64
  32546. account_balance *uint64
  32547. addaccount_balance *int64
  32548. consume_token *uint64
  32549. addconsume_token *int64
  32550. active_user *uint64
  32551. addactive_user *int64
  32552. new_user *int64
  32553. addnew_user *int64
  32554. label_dist *[]custom_types.LabelDist
  32555. appendlabel_dist []custom_types.LabelDist
  32556. clearedFields map[string]struct{}
  32557. done bool
  32558. oldValue func(context.Context) (*UsageStatisticDay, error)
  32559. predicates []predicate.UsageStatisticDay
  32560. }
  32561. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  32562. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  32563. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  32564. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  32565. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  32566. m := &UsageStatisticDayMutation{
  32567. config: c,
  32568. op: op,
  32569. typ: TypeUsageStatisticDay,
  32570. clearedFields: make(map[string]struct{}),
  32571. }
  32572. for _, opt := range opts {
  32573. opt(m)
  32574. }
  32575. return m
  32576. }
  32577. // withUsageStatisticDayID sets the ID field of the mutation.
  32578. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  32579. return func(m *UsageStatisticDayMutation) {
  32580. var (
  32581. err error
  32582. once sync.Once
  32583. value *UsageStatisticDay
  32584. )
  32585. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  32586. once.Do(func() {
  32587. if m.done {
  32588. err = errors.New("querying old values post mutation is not allowed")
  32589. } else {
  32590. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  32591. }
  32592. })
  32593. return value, err
  32594. }
  32595. m.id = &id
  32596. }
  32597. }
  32598. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  32599. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  32600. return func(m *UsageStatisticDayMutation) {
  32601. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  32602. return node, nil
  32603. }
  32604. m.id = &node.ID
  32605. }
  32606. }
  32607. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32608. // executed in a transaction (ent.Tx), a transactional client is returned.
  32609. func (m UsageStatisticDayMutation) Client() *Client {
  32610. client := &Client{config: m.config}
  32611. client.init()
  32612. return client
  32613. }
  32614. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32615. // it returns an error otherwise.
  32616. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  32617. if _, ok := m.driver.(*txDriver); !ok {
  32618. return nil, errors.New("ent: mutation is not running in a transaction")
  32619. }
  32620. tx := &Tx{config: m.config}
  32621. tx.init()
  32622. return tx, nil
  32623. }
  32624. // SetID sets the value of the id field. Note that this
  32625. // operation is only accepted on creation of UsageStatisticDay entities.
  32626. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  32627. m.id = &id
  32628. }
  32629. // ID returns the ID value in the mutation. Note that the ID is only available
  32630. // if it was provided to the builder or after it was returned from the database.
  32631. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  32632. if m.id == nil {
  32633. return
  32634. }
  32635. return *m.id, true
  32636. }
  32637. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32638. // That means, if the mutation is applied within a transaction with an isolation level such
  32639. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32640. // or updated by the mutation.
  32641. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  32642. switch {
  32643. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32644. id, exists := m.ID()
  32645. if exists {
  32646. return []uint64{id}, nil
  32647. }
  32648. fallthrough
  32649. case m.op.Is(OpUpdate | OpDelete):
  32650. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  32651. default:
  32652. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32653. }
  32654. }
  32655. // SetCreatedAt sets the "created_at" field.
  32656. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  32657. m.created_at = &t
  32658. }
  32659. // CreatedAt returns the value of the "created_at" field in the mutation.
  32660. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  32661. v := m.created_at
  32662. if v == nil {
  32663. return
  32664. }
  32665. return *v, true
  32666. }
  32667. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  32668. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32670. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32671. if !m.op.Is(OpUpdateOne) {
  32672. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32673. }
  32674. if m.id == nil || m.oldValue == nil {
  32675. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32676. }
  32677. oldValue, err := m.oldValue(ctx)
  32678. if err != nil {
  32679. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32680. }
  32681. return oldValue.CreatedAt, nil
  32682. }
  32683. // ResetCreatedAt resets all changes to the "created_at" field.
  32684. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  32685. m.created_at = nil
  32686. }
  32687. // SetUpdatedAt sets the "updated_at" field.
  32688. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  32689. m.updated_at = &t
  32690. }
  32691. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32692. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  32693. v := m.updated_at
  32694. if v == nil {
  32695. return
  32696. }
  32697. return *v, true
  32698. }
  32699. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  32700. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32702. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32703. if !m.op.Is(OpUpdateOne) {
  32704. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32705. }
  32706. if m.id == nil || m.oldValue == nil {
  32707. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32708. }
  32709. oldValue, err := m.oldValue(ctx)
  32710. if err != nil {
  32711. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32712. }
  32713. return oldValue.UpdatedAt, nil
  32714. }
  32715. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32716. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  32717. m.updated_at = nil
  32718. }
  32719. // SetStatus sets the "status" field.
  32720. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  32721. m.status = &u
  32722. m.addstatus = nil
  32723. }
  32724. // Status returns the value of the "status" field in the mutation.
  32725. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  32726. v := m.status
  32727. if v == nil {
  32728. return
  32729. }
  32730. return *v, true
  32731. }
  32732. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  32733. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32735. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32736. if !m.op.Is(OpUpdateOne) {
  32737. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32738. }
  32739. if m.id == nil || m.oldValue == nil {
  32740. return v, errors.New("OldStatus requires an ID field in the mutation")
  32741. }
  32742. oldValue, err := m.oldValue(ctx)
  32743. if err != nil {
  32744. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32745. }
  32746. return oldValue.Status, nil
  32747. }
  32748. // AddStatus adds u to the "status" field.
  32749. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  32750. if m.addstatus != nil {
  32751. *m.addstatus += u
  32752. } else {
  32753. m.addstatus = &u
  32754. }
  32755. }
  32756. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32757. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  32758. v := m.addstatus
  32759. if v == nil {
  32760. return
  32761. }
  32762. return *v, true
  32763. }
  32764. // ClearStatus clears the value of the "status" field.
  32765. func (m *UsageStatisticDayMutation) ClearStatus() {
  32766. m.status = nil
  32767. m.addstatus = nil
  32768. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  32769. }
  32770. // StatusCleared returns if the "status" field was cleared in this mutation.
  32771. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  32772. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  32773. return ok
  32774. }
  32775. // ResetStatus resets all changes to the "status" field.
  32776. func (m *UsageStatisticDayMutation) ResetStatus() {
  32777. m.status = nil
  32778. m.addstatus = nil
  32779. delete(m.clearedFields, usagestatisticday.FieldStatus)
  32780. }
  32781. // SetDeletedAt sets the "deleted_at" field.
  32782. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  32783. m.deleted_at = &t
  32784. }
  32785. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32786. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  32787. v := m.deleted_at
  32788. if v == nil {
  32789. return
  32790. }
  32791. return *v, true
  32792. }
  32793. // OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32797. if !m.op.Is(OpUpdateOne) {
  32798. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32799. }
  32800. if m.id == nil || m.oldValue == nil {
  32801. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  32806. }
  32807. return oldValue.DeletedAt, nil
  32808. }
  32809. // ClearDeletedAt clears the value of the "deleted_at" field.
  32810. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  32811. m.deleted_at = nil
  32812. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  32813. }
  32814. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32815. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  32816. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  32817. return ok
  32818. }
  32819. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32820. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  32821. m.deleted_at = nil
  32822. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  32823. }
  32824. // SetAddtime sets the "addtime" field.
  32825. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  32826. m.addtime = &u
  32827. m.addaddtime = nil
  32828. }
  32829. // Addtime returns the value of the "addtime" field in the mutation.
  32830. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  32831. v := m.addtime
  32832. if v == nil {
  32833. return
  32834. }
  32835. return *v, true
  32836. }
  32837. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  32838. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32840. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32841. if !m.op.Is(OpUpdateOne) {
  32842. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32843. }
  32844. if m.id == nil || m.oldValue == nil {
  32845. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32846. }
  32847. oldValue, err := m.oldValue(ctx)
  32848. if err != nil {
  32849. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32850. }
  32851. return oldValue.Addtime, nil
  32852. }
  32853. // AddAddtime adds u to the "addtime" field.
  32854. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  32855. if m.addaddtime != nil {
  32856. *m.addaddtime += u
  32857. } else {
  32858. m.addaddtime = &u
  32859. }
  32860. }
  32861. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32862. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  32863. v := m.addaddtime
  32864. if v == nil {
  32865. return
  32866. }
  32867. return *v, true
  32868. }
  32869. // ResetAddtime resets all changes to the "addtime" field.
  32870. func (m *UsageStatisticDayMutation) ResetAddtime() {
  32871. m.addtime = nil
  32872. m.addaddtime = nil
  32873. }
  32874. // SetType sets the "type" field.
  32875. func (m *UsageStatisticDayMutation) SetType(i int) {
  32876. m._type = &i
  32877. m.add_type = nil
  32878. }
  32879. // GetType returns the value of the "type" field in the mutation.
  32880. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  32881. v := m._type
  32882. if v == nil {
  32883. return
  32884. }
  32885. return *v, true
  32886. }
  32887. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  32888. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32890. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  32891. if !m.op.Is(OpUpdateOne) {
  32892. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32893. }
  32894. if m.id == nil || m.oldValue == nil {
  32895. return v, errors.New("OldType requires an ID field in the mutation")
  32896. }
  32897. oldValue, err := m.oldValue(ctx)
  32898. if err != nil {
  32899. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32900. }
  32901. return oldValue.Type, nil
  32902. }
  32903. // AddType adds i to the "type" field.
  32904. func (m *UsageStatisticDayMutation) AddType(i int) {
  32905. if m.add_type != nil {
  32906. *m.add_type += i
  32907. } else {
  32908. m.add_type = &i
  32909. }
  32910. }
  32911. // AddedType returns the value that was added to the "type" field in this mutation.
  32912. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  32913. v := m.add_type
  32914. if v == nil {
  32915. return
  32916. }
  32917. return *v, true
  32918. }
  32919. // ResetType resets all changes to the "type" field.
  32920. func (m *UsageStatisticDayMutation) ResetType() {
  32921. m._type = nil
  32922. m.add_type = nil
  32923. }
  32924. // SetBotID sets the "bot_id" field.
  32925. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  32926. m.bot_id = &s
  32927. }
  32928. // BotID returns the value of the "bot_id" field in the mutation.
  32929. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  32930. v := m.bot_id
  32931. if v == nil {
  32932. return
  32933. }
  32934. return *v, true
  32935. }
  32936. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  32937. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32939. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  32940. if !m.op.Is(OpUpdateOne) {
  32941. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32942. }
  32943. if m.id == nil || m.oldValue == nil {
  32944. return v, errors.New("OldBotID requires an ID field in the mutation")
  32945. }
  32946. oldValue, err := m.oldValue(ctx)
  32947. if err != nil {
  32948. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32949. }
  32950. return oldValue.BotID, nil
  32951. }
  32952. // ClearBotID clears the value of the "bot_id" field.
  32953. func (m *UsageStatisticDayMutation) ClearBotID() {
  32954. m.bot_id = nil
  32955. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  32956. }
  32957. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32958. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  32959. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  32960. return ok
  32961. }
  32962. // ResetBotID resets all changes to the "bot_id" field.
  32963. func (m *UsageStatisticDayMutation) ResetBotID() {
  32964. m.bot_id = nil
  32965. delete(m.clearedFields, usagestatisticday.FieldBotID)
  32966. }
  32967. // SetOrganizationID sets the "organization_id" field.
  32968. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  32969. m.organization_id = &u
  32970. m.addorganization_id = nil
  32971. }
  32972. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32973. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  32974. v := m.organization_id
  32975. if v == nil {
  32976. return
  32977. }
  32978. return *v, true
  32979. }
  32980. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  32981. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32983. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32984. if !m.op.Is(OpUpdateOne) {
  32985. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32986. }
  32987. if m.id == nil || m.oldValue == nil {
  32988. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32989. }
  32990. oldValue, err := m.oldValue(ctx)
  32991. if err != nil {
  32992. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32993. }
  32994. return oldValue.OrganizationID, nil
  32995. }
  32996. // AddOrganizationID adds u to the "organization_id" field.
  32997. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  32998. if m.addorganization_id != nil {
  32999. *m.addorganization_id += u
  33000. } else {
  33001. m.addorganization_id = &u
  33002. }
  33003. }
  33004. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33005. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  33006. v := m.addorganization_id
  33007. if v == nil {
  33008. return
  33009. }
  33010. return *v, true
  33011. }
  33012. // ClearOrganizationID clears the value of the "organization_id" field.
  33013. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  33014. m.organization_id = nil
  33015. m.addorganization_id = nil
  33016. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  33017. }
  33018. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33019. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  33020. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  33021. return ok
  33022. }
  33023. // ResetOrganizationID resets all changes to the "organization_id" field.
  33024. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  33025. m.organization_id = nil
  33026. m.addorganization_id = nil
  33027. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  33028. }
  33029. // SetAiResponse sets the "ai_response" field.
  33030. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  33031. m.ai_response = &u
  33032. m.addai_response = nil
  33033. }
  33034. // AiResponse returns the value of the "ai_response" field in the mutation.
  33035. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  33036. v := m.ai_response
  33037. if v == nil {
  33038. return
  33039. }
  33040. return *v, true
  33041. }
  33042. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  33043. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33045. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33046. if !m.op.Is(OpUpdateOne) {
  33047. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33048. }
  33049. if m.id == nil || m.oldValue == nil {
  33050. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33051. }
  33052. oldValue, err := m.oldValue(ctx)
  33053. if err != nil {
  33054. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33055. }
  33056. return oldValue.AiResponse, nil
  33057. }
  33058. // AddAiResponse adds u to the "ai_response" field.
  33059. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  33060. if m.addai_response != nil {
  33061. *m.addai_response += u
  33062. } else {
  33063. m.addai_response = &u
  33064. }
  33065. }
  33066. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33067. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  33068. v := m.addai_response
  33069. if v == nil {
  33070. return
  33071. }
  33072. return *v, true
  33073. }
  33074. // ResetAiResponse resets all changes to the "ai_response" field.
  33075. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  33076. m.ai_response = nil
  33077. m.addai_response = nil
  33078. }
  33079. // SetSopRun sets the "sop_run" field.
  33080. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  33081. m.sop_run = &u
  33082. m.addsop_run = nil
  33083. }
  33084. // SopRun returns the value of the "sop_run" field in the mutation.
  33085. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  33086. v := m.sop_run
  33087. if v == nil {
  33088. return
  33089. }
  33090. return *v, true
  33091. }
  33092. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  33093. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33095. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33096. if !m.op.Is(OpUpdateOne) {
  33097. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33098. }
  33099. if m.id == nil || m.oldValue == nil {
  33100. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33101. }
  33102. oldValue, err := m.oldValue(ctx)
  33103. if err != nil {
  33104. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33105. }
  33106. return oldValue.SopRun, nil
  33107. }
  33108. // AddSopRun adds u to the "sop_run" field.
  33109. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  33110. if m.addsop_run != nil {
  33111. *m.addsop_run += u
  33112. } else {
  33113. m.addsop_run = &u
  33114. }
  33115. }
  33116. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33117. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  33118. v := m.addsop_run
  33119. if v == nil {
  33120. return
  33121. }
  33122. return *v, true
  33123. }
  33124. // ResetSopRun resets all changes to the "sop_run" field.
  33125. func (m *UsageStatisticDayMutation) ResetSopRun() {
  33126. m.sop_run = nil
  33127. m.addsop_run = nil
  33128. }
  33129. // SetTotalFriend sets the "total_friend" field.
  33130. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  33131. m.total_friend = &u
  33132. m.addtotal_friend = nil
  33133. }
  33134. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33135. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  33136. v := m.total_friend
  33137. if v == nil {
  33138. return
  33139. }
  33140. return *v, true
  33141. }
  33142. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  33143. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33145. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33146. if !m.op.Is(OpUpdateOne) {
  33147. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33148. }
  33149. if m.id == nil || m.oldValue == nil {
  33150. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33151. }
  33152. oldValue, err := m.oldValue(ctx)
  33153. if err != nil {
  33154. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33155. }
  33156. return oldValue.TotalFriend, nil
  33157. }
  33158. // AddTotalFriend adds u to the "total_friend" field.
  33159. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  33160. if m.addtotal_friend != nil {
  33161. *m.addtotal_friend += u
  33162. } else {
  33163. m.addtotal_friend = &u
  33164. }
  33165. }
  33166. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  33167. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  33168. v := m.addtotal_friend
  33169. if v == nil {
  33170. return
  33171. }
  33172. return *v, true
  33173. }
  33174. // ResetTotalFriend resets all changes to the "total_friend" field.
  33175. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  33176. m.total_friend = nil
  33177. m.addtotal_friend = nil
  33178. }
  33179. // SetTotalGroup sets the "total_group" field.
  33180. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  33181. m.total_group = &u
  33182. m.addtotal_group = nil
  33183. }
  33184. // TotalGroup returns the value of the "total_group" field in the mutation.
  33185. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  33186. v := m.total_group
  33187. if v == nil {
  33188. return
  33189. }
  33190. return *v, true
  33191. }
  33192. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  33193. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33195. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  33196. if !m.op.Is(OpUpdateOne) {
  33197. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33198. }
  33199. if m.id == nil || m.oldValue == nil {
  33200. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  33201. }
  33202. oldValue, err := m.oldValue(ctx)
  33203. if err != nil {
  33204. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  33205. }
  33206. return oldValue.TotalGroup, nil
  33207. }
  33208. // AddTotalGroup adds u to the "total_group" field.
  33209. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  33210. if m.addtotal_group != nil {
  33211. *m.addtotal_group += u
  33212. } else {
  33213. m.addtotal_group = &u
  33214. }
  33215. }
  33216. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33217. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  33218. v := m.addtotal_group
  33219. if v == nil {
  33220. return
  33221. }
  33222. return *v, true
  33223. }
  33224. // ResetTotalGroup resets all changes to the "total_group" field.
  33225. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  33226. m.total_group = nil
  33227. m.addtotal_group = nil
  33228. }
  33229. // SetAccountBalance sets the "account_balance" field.
  33230. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  33231. m.account_balance = &u
  33232. m.addaccount_balance = nil
  33233. }
  33234. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33235. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  33236. v := m.account_balance
  33237. if v == nil {
  33238. return
  33239. }
  33240. return *v, true
  33241. }
  33242. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  33243. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33245. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33246. if !m.op.Is(OpUpdateOne) {
  33247. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33248. }
  33249. if m.id == nil || m.oldValue == nil {
  33250. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33251. }
  33252. oldValue, err := m.oldValue(ctx)
  33253. if err != nil {
  33254. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33255. }
  33256. return oldValue.AccountBalance, nil
  33257. }
  33258. // AddAccountBalance adds u to the "account_balance" field.
  33259. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  33260. if m.addaccount_balance != nil {
  33261. *m.addaccount_balance += u
  33262. } else {
  33263. m.addaccount_balance = &u
  33264. }
  33265. }
  33266. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33267. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  33268. v := m.addaccount_balance
  33269. if v == nil {
  33270. return
  33271. }
  33272. return *v, true
  33273. }
  33274. // ResetAccountBalance resets all changes to the "account_balance" field.
  33275. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  33276. m.account_balance = nil
  33277. m.addaccount_balance = nil
  33278. }
  33279. // SetConsumeToken sets the "consume_token" field.
  33280. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  33281. m.consume_token = &u
  33282. m.addconsume_token = nil
  33283. }
  33284. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33285. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  33286. v := m.consume_token
  33287. if v == nil {
  33288. return
  33289. }
  33290. return *v, true
  33291. }
  33292. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  33293. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33295. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33296. if !m.op.Is(OpUpdateOne) {
  33297. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33298. }
  33299. if m.id == nil || m.oldValue == nil {
  33300. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33301. }
  33302. oldValue, err := m.oldValue(ctx)
  33303. if err != nil {
  33304. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33305. }
  33306. return oldValue.ConsumeToken, nil
  33307. }
  33308. // AddConsumeToken adds u to the "consume_token" field.
  33309. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  33310. if m.addconsume_token != nil {
  33311. *m.addconsume_token += u
  33312. } else {
  33313. m.addconsume_token = &u
  33314. }
  33315. }
  33316. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33317. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  33318. v := m.addconsume_token
  33319. if v == nil {
  33320. return
  33321. }
  33322. return *v, true
  33323. }
  33324. // ResetConsumeToken resets all changes to the "consume_token" field.
  33325. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  33326. m.consume_token = nil
  33327. m.addconsume_token = nil
  33328. }
  33329. // SetActiveUser sets the "active_user" field.
  33330. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  33331. m.active_user = &u
  33332. m.addactive_user = nil
  33333. }
  33334. // ActiveUser returns the value of the "active_user" field in the mutation.
  33335. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  33336. v := m.active_user
  33337. if v == nil {
  33338. return
  33339. }
  33340. return *v, true
  33341. }
  33342. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  33343. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33345. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33346. if !m.op.Is(OpUpdateOne) {
  33347. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33348. }
  33349. if m.id == nil || m.oldValue == nil {
  33350. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33351. }
  33352. oldValue, err := m.oldValue(ctx)
  33353. if err != nil {
  33354. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33355. }
  33356. return oldValue.ActiveUser, nil
  33357. }
  33358. // AddActiveUser adds u to the "active_user" field.
  33359. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  33360. if m.addactive_user != nil {
  33361. *m.addactive_user += u
  33362. } else {
  33363. m.addactive_user = &u
  33364. }
  33365. }
  33366. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33367. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  33368. v := m.addactive_user
  33369. if v == nil {
  33370. return
  33371. }
  33372. return *v, true
  33373. }
  33374. // ResetActiveUser resets all changes to the "active_user" field.
  33375. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  33376. m.active_user = nil
  33377. m.addactive_user = nil
  33378. }
  33379. // SetNewUser sets the "new_user" field.
  33380. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  33381. m.new_user = &i
  33382. m.addnew_user = nil
  33383. }
  33384. // NewUser returns the value of the "new_user" field in the mutation.
  33385. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  33386. v := m.new_user
  33387. if v == nil {
  33388. return
  33389. }
  33390. return *v, true
  33391. }
  33392. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  33393. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33395. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33396. if !m.op.Is(OpUpdateOne) {
  33397. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33398. }
  33399. if m.id == nil || m.oldValue == nil {
  33400. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33401. }
  33402. oldValue, err := m.oldValue(ctx)
  33403. if err != nil {
  33404. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33405. }
  33406. return oldValue.NewUser, nil
  33407. }
  33408. // AddNewUser adds i to the "new_user" field.
  33409. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  33410. if m.addnew_user != nil {
  33411. *m.addnew_user += i
  33412. } else {
  33413. m.addnew_user = &i
  33414. }
  33415. }
  33416. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33417. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  33418. v := m.addnew_user
  33419. if v == nil {
  33420. return
  33421. }
  33422. return *v, true
  33423. }
  33424. // ResetNewUser resets all changes to the "new_user" field.
  33425. func (m *UsageStatisticDayMutation) ResetNewUser() {
  33426. m.new_user = nil
  33427. m.addnew_user = nil
  33428. }
  33429. // SetLabelDist sets the "label_dist" field.
  33430. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33431. m.label_dist = &ctd
  33432. m.appendlabel_dist = nil
  33433. }
  33434. // LabelDist returns the value of the "label_dist" field in the mutation.
  33435. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33436. v := m.label_dist
  33437. if v == nil {
  33438. return
  33439. }
  33440. return *v, true
  33441. }
  33442. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  33443. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33445. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33446. if !m.op.Is(OpUpdateOne) {
  33447. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33448. }
  33449. if m.id == nil || m.oldValue == nil {
  33450. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33451. }
  33452. oldValue, err := m.oldValue(ctx)
  33453. if err != nil {
  33454. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33455. }
  33456. return oldValue.LabelDist, nil
  33457. }
  33458. // AppendLabelDist adds ctd to the "label_dist" field.
  33459. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33460. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33461. }
  33462. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33463. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33464. if len(m.appendlabel_dist) == 0 {
  33465. return nil, false
  33466. }
  33467. return m.appendlabel_dist, true
  33468. }
  33469. // ResetLabelDist resets all changes to the "label_dist" field.
  33470. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  33471. m.label_dist = nil
  33472. m.appendlabel_dist = nil
  33473. }
  33474. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  33475. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  33476. m.predicates = append(m.predicates, ps...)
  33477. }
  33478. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  33479. // users can use type-assertion to append predicates that do not depend on any generated package.
  33480. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  33481. p := make([]predicate.UsageStatisticDay, len(ps))
  33482. for i := range ps {
  33483. p[i] = ps[i]
  33484. }
  33485. m.Where(p...)
  33486. }
  33487. // Op returns the operation name.
  33488. func (m *UsageStatisticDayMutation) Op() Op {
  33489. return m.op
  33490. }
  33491. // SetOp allows setting the mutation operation.
  33492. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  33493. m.op = op
  33494. }
  33495. // Type returns the node type of this mutation (UsageStatisticDay).
  33496. func (m *UsageStatisticDayMutation) Type() string {
  33497. return m.typ
  33498. }
  33499. // Fields returns all fields that were changed during this mutation. Note that in
  33500. // order to get all numeric fields that were incremented/decremented, call
  33501. // AddedFields().
  33502. func (m *UsageStatisticDayMutation) Fields() []string {
  33503. fields := make([]string, 0, 17)
  33504. if m.created_at != nil {
  33505. fields = append(fields, usagestatisticday.FieldCreatedAt)
  33506. }
  33507. if m.updated_at != nil {
  33508. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  33509. }
  33510. if m.status != nil {
  33511. fields = append(fields, usagestatisticday.FieldStatus)
  33512. }
  33513. if m.deleted_at != nil {
  33514. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33515. }
  33516. if m.addtime != nil {
  33517. fields = append(fields, usagestatisticday.FieldAddtime)
  33518. }
  33519. if m._type != nil {
  33520. fields = append(fields, usagestatisticday.FieldType)
  33521. }
  33522. if m.bot_id != nil {
  33523. fields = append(fields, usagestatisticday.FieldBotID)
  33524. }
  33525. if m.organization_id != nil {
  33526. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33527. }
  33528. if m.ai_response != nil {
  33529. fields = append(fields, usagestatisticday.FieldAiResponse)
  33530. }
  33531. if m.sop_run != nil {
  33532. fields = append(fields, usagestatisticday.FieldSopRun)
  33533. }
  33534. if m.total_friend != nil {
  33535. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33536. }
  33537. if m.total_group != nil {
  33538. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33539. }
  33540. if m.account_balance != nil {
  33541. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33542. }
  33543. if m.consume_token != nil {
  33544. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33545. }
  33546. if m.active_user != nil {
  33547. fields = append(fields, usagestatisticday.FieldActiveUser)
  33548. }
  33549. if m.new_user != nil {
  33550. fields = append(fields, usagestatisticday.FieldNewUser)
  33551. }
  33552. if m.label_dist != nil {
  33553. fields = append(fields, usagestatisticday.FieldLabelDist)
  33554. }
  33555. return fields
  33556. }
  33557. // Field returns the value of a field with the given name. The second boolean
  33558. // return value indicates that this field was not set, or was not defined in the
  33559. // schema.
  33560. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  33561. switch name {
  33562. case usagestatisticday.FieldCreatedAt:
  33563. return m.CreatedAt()
  33564. case usagestatisticday.FieldUpdatedAt:
  33565. return m.UpdatedAt()
  33566. case usagestatisticday.FieldStatus:
  33567. return m.Status()
  33568. case usagestatisticday.FieldDeletedAt:
  33569. return m.DeletedAt()
  33570. case usagestatisticday.FieldAddtime:
  33571. return m.Addtime()
  33572. case usagestatisticday.FieldType:
  33573. return m.GetType()
  33574. case usagestatisticday.FieldBotID:
  33575. return m.BotID()
  33576. case usagestatisticday.FieldOrganizationID:
  33577. return m.OrganizationID()
  33578. case usagestatisticday.FieldAiResponse:
  33579. return m.AiResponse()
  33580. case usagestatisticday.FieldSopRun:
  33581. return m.SopRun()
  33582. case usagestatisticday.FieldTotalFriend:
  33583. return m.TotalFriend()
  33584. case usagestatisticday.FieldTotalGroup:
  33585. return m.TotalGroup()
  33586. case usagestatisticday.FieldAccountBalance:
  33587. return m.AccountBalance()
  33588. case usagestatisticday.FieldConsumeToken:
  33589. return m.ConsumeToken()
  33590. case usagestatisticday.FieldActiveUser:
  33591. return m.ActiveUser()
  33592. case usagestatisticday.FieldNewUser:
  33593. return m.NewUser()
  33594. case usagestatisticday.FieldLabelDist:
  33595. return m.LabelDist()
  33596. }
  33597. return nil, false
  33598. }
  33599. // OldField returns the old value of the field from the database. An error is
  33600. // returned if the mutation operation is not UpdateOne, or the query to the
  33601. // database failed.
  33602. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33603. switch name {
  33604. case usagestatisticday.FieldCreatedAt:
  33605. return m.OldCreatedAt(ctx)
  33606. case usagestatisticday.FieldUpdatedAt:
  33607. return m.OldUpdatedAt(ctx)
  33608. case usagestatisticday.FieldStatus:
  33609. return m.OldStatus(ctx)
  33610. case usagestatisticday.FieldDeletedAt:
  33611. return m.OldDeletedAt(ctx)
  33612. case usagestatisticday.FieldAddtime:
  33613. return m.OldAddtime(ctx)
  33614. case usagestatisticday.FieldType:
  33615. return m.OldType(ctx)
  33616. case usagestatisticday.FieldBotID:
  33617. return m.OldBotID(ctx)
  33618. case usagestatisticday.FieldOrganizationID:
  33619. return m.OldOrganizationID(ctx)
  33620. case usagestatisticday.FieldAiResponse:
  33621. return m.OldAiResponse(ctx)
  33622. case usagestatisticday.FieldSopRun:
  33623. return m.OldSopRun(ctx)
  33624. case usagestatisticday.FieldTotalFriend:
  33625. return m.OldTotalFriend(ctx)
  33626. case usagestatisticday.FieldTotalGroup:
  33627. return m.OldTotalGroup(ctx)
  33628. case usagestatisticday.FieldAccountBalance:
  33629. return m.OldAccountBalance(ctx)
  33630. case usagestatisticday.FieldConsumeToken:
  33631. return m.OldConsumeToken(ctx)
  33632. case usagestatisticday.FieldActiveUser:
  33633. return m.OldActiveUser(ctx)
  33634. case usagestatisticday.FieldNewUser:
  33635. return m.OldNewUser(ctx)
  33636. case usagestatisticday.FieldLabelDist:
  33637. return m.OldLabelDist(ctx)
  33638. }
  33639. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33640. }
  33641. // SetField sets the value of a field with the given name. It returns an error if
  33642. // the field is not defined in the schema, or if the type mismatched the field
  33643. // type.
  33644. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  33645. switch name {
  33646. case usagestatisticday.FieldCreatedAt:
  33647. v, ok := value.(time.Time)
  33648. if !ok {
  33649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33650. }
  33651. m.SetCreatedAt(v)
  33652. return nil
  33653. case usagestatisticday.FieldUpdatedAt:
  33654. v, ok := value.(time.Time)
  33655. if !ok {
  33656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33657. }
  33658. m.SetUpdatedAt(v)
  33659. return nil
  33660. case usagestatisticday.FieldStatus:
  33661. v, ok := value.(uint8)
  33662. if !ok {
  33663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33664. }
  33665. m.SetStatus(v)
  33666. return nil
  33667. case usagestatisticday.FieldDeletedAt:
  33668. v, ok := value.(time.Time)
  33669. if !ok {
  33670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33671. }
  33672. m.SetDeletedAt(v)
  33673. return nil
  33674. case usagestatisticday.FieldAddtime:
  33675. v, ok := value.(uint64)
  33676. if !ok {
  33677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33678. }
  33679. m.SetAddtime(v)
  33680. return nil
  33681. case usagestatisticday.FieldType:
  33682. v, ok := value.(int)
  33683. if !ok {
  33684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33685. }
  33686. m.SetType(v)
  33687. return nil
  33688. case usagestatisticday.FieldBotID:
  33689. v, ok := value.(string)
  33690. if !ok {
  33691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33692. }
  33693. m.SetBotID(v)
  33694. return nil
  33695. case usagestatisticday.FieldOrganizationID:
  33696. v, ok := value.(uint64)
  33697. if !ok {
  33698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33699. }
  33700. m.SetOrganizationID(v)
  33701. return nil
  33702. case usagestatisticday.FieldAiResponse:
  33703. v, ok := value.(uint64)
  33704. if !ok {
  33705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33706. }
  33707. m.SetAiResponse(v)
  33708. return nil
  33709. case usagestatisticday.FieldSopRun:
  33710. v, ok := value.(uint64)
  33711. if !ok {
  33712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33713. }
  33714. m.SetSopRun(v)
  33715. return nil
  33716. case usagestatisticday.FieldTotalFriend:
  33717. v, ok := value.(uint64)
  33718. if !ok {
  33719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33720. }
  33721. m.SetTotalFriend(v)
  33722. return nil
  33723. case usagestatisticday.FieldTotalGroup:
  33724. v, ok := value.(uint64)
  33725. if !ok {
  33726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33727. }
  33728. m.SetTotalGroup(v)
  33729. return nil
  33730. case usagestatisticday.FieldAccountBalance:
  33731. v, ok := value.(uint64)
  33732. if !ok {
  33733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33734. }
  33735. m.SetAccountBalance(v)
  33736. return nil
  33737. case usagestatisticday.FieldConsumeToken:
  33738. v, ok := value.(uint64)
  33739. if !ok {
  33740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33741. }
  33742. m.SetConsumeToken(v)
  33743. return nil
  33744. case usagestatisticday.FieldActiveUser:
  33745. v, ok := value.(uint64)
  33746. if !ok {
  33747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33748. }
  33749. m.SetActiveUser(v)
  33750. return nil
  33751. case usagestatisticday.FieldNewUser:
  33752. v, ok := value.(int64)
  33753. if !ok {
  33754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33755. }
  33756. m.SetNewUser(v)
  33757. return nil
  33758. case usagestatisticday.FieldLabelDist:
  33759. v, ok := value.([]custom_types.LabelDist)
  33760. if !ok {
  33761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33762. }
  33763. m.SetLabelDist(v)
  33764. return nil
  33765. }
  33766. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33767. }
  33768. // AddedFields returns all numeric fields that were incremented/decremented during
  33769. // this mutation.
  33770. func (m *UsageStatisticDayMutation) AddedFields() []string {
  33771. var fields []string
  33772. if m.addstatus != nil {
  33773. fields = append(fields, usagestatisticday.FieldStatus)
  33774. }
  33775. if m.addaddtime != nil {
  33776. fields = append(fields, usagestatisticday.FieldAddtime)
  33777. }
  33778. if m.add_type != nil {
  33779. fields = append(fields, usagestatisticday.FieldType)
  33780. }
  33781. if m.addorganization_id != nil {
  33782. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33783. }
  33784. if m.addai_response != nil {
  33785. fields = append(fields, usagestatisticday.FieldAiResponse)
  33786. }
  33787. if m.addsop_run != nil {
  33788. fields = append(fields, usagestatisticday.FieldSopRun)
  33789. }
  33790. if m.addtotal_friend != nil {
  33791. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33792. }
  33793. if m.addtotal_group != nil {
  33794. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33795. }
  33796. if m.addaccount_balance != nil {
  33797. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33798. }
  33799. if m.addconsume_token != nil {
  33800. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33801. }
  33802. if m.addactive_user != nil {
  33803. fields = append(fields, usagestatisticday.FieldActiveUser)
  33804. }
  33805. if m.addnew_user != nil {
  33806. fields = append(fields, usagestatisticday.FieldNewUser)
  33807. }
  33808. return fields
  33809. }
  33810. // AddedField returns the numeric value that was incremented/decremented on a field
  33811. // with the given name. The second boolean return value indicates that this field
  33812. // was not set, or was not defined in the schema.
  33813. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  33814. switch name {
  33815. case usagestatisticday.FieldStatus:
  33816. return m.AddedStatus()
  33817. case usagestatisticday.FieldAddtime:
  33818. return m.AddedAddtime()
  33819. case usagestatisticday.FieldType:
  33820. return m.AddedType()
  33821. case usagestatisticday.FieldOrganizationID:
  33822. return m.AddedOrganizationID()
  33823. case usagestatisticday.FieldAiResponse:
  33824. return m.AddedAiResponse()
  33825. case usagestatisticday.FieldSopRun:
  33826. return m.AddedSopRun()
  33827. case usagestatisticday.FieldTotalFriend:
  33828. return m.AddedTotalFriend()
  33829. case usagestatisticday.FieldTotalGroup:
  33830. return m.AddedTotalGroup()
  33831. case usagestatisticday.FieldAccountBalance:
  33832. return m.AddedAccountBalance()
  33833. case usagestatisticday.FieldConsumeToken:
  33834. return m.AddedConsumeToken()
  33835. case usagestatisticday.FieldActiveUser:
  33836. return m.AddedActiveUser()
  33837. case usagestatisticday.FieldNewUser:
  33838. return m.AddedNewUser()
  33839. }
  33840. return nil, false
  33841. }
  33842. // AddField adds the value to the field with the given name. It returns an error if
  33843. // the field is not defined in the schema, or if the type mismatched the field
  33844. // type.
  33845. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  33846. switch name {
  33847. case usagestatisticday.FieldStatus:
  33848. v, ok := value.(int8)
  33849. if !ok {
  33850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33851. }
  33852. m.AddStatus(v)
  33853. return nil
  33854. case usagestatisticday.FieldAddtime:
  33855. v, ok := value.(int64)
  33856. if !ok {
  33857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33858. }
  33859. m.AddAddtime(v)
  33860. return nil
  33861. case usagestatisticday.FieldType:
  33862. v, ok := value.(int)
  33863. if !ok {
  33864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33865. }
  33866. m.AddType(v)
  33867. return nil
  33868. case usagestatisticday.FieldOrganizationID:
  33869. v, ok := value.(int64)
  33870. if !ok {
  33871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33872. }
  33873. m.AddOrganizationID(v)
  33874. return nil
  33875. case usagestatisticday.FieldAiResponse:
  33876. v, ok := value.(int64)
  33877. if !ok {
  33878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33879. }
  33880. m.AddAiResponse(v)
  33881. return nil
  33882. case usagestatisticday.FieldSopRun:
  33883. v, ok := value.(int64)
  33884. if !ok {
  33885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33886. }
  33887. m.AddSopRun(v)
  33888. return nil
  33889. case usagestatisticday.FieldTotalFriend:
  33890. v, ok := value.(int64)
  33891. if !ok {
  33892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33893. }
  33894. m.AddTotalFriend(v)
  33895. return nil
  33896. case usagestatisticday.FieldTotalGroup:
  33897. v, ok := value.(int64)
  33898. if !ok {
  33899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33900. }
  33901. m.AddTotalGroup(v)
  33902. return nil
  33903. case usagestatisticday.FieldAccountBalance:
  33904. v, ok := value.(int64)
  33905. if !ok {
  33906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33907. }
  33908. m.AddAccountBalance(v)
  33909. return nil
  33910. case usagestatisticday.FieldConsumeToken:
  33911. v, ok := value.(int64)
  33912. if !ok {
  33913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33914. }
  33915. m.AddConsumeToken(v)
  33916. return nil
  33917. case usagestatisticday.FieldActiveUser:
  33918. v, ok := value.(int64)
  33919. if !ok {
  33920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33921. }
  33922. m.AddActiveUser(v)
  33923. return nil
  33924. case usagestatisticday.FieldNewUser:
  33925. v, ok := value.(int64)
  33926. if !ok {
  33927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33928. }
  33929. m.AddNewUser(v)
  33930. return nil
  33931. }
  33932. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  33933. }
  33934. // ClearedFields returns all nullable fields that were cleared during this
  33935. // mutation.
  33936. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  33937. var fields []string
  33938. if m.FieldCleared(usagestatisticday.FieldStatus) {
  33939. fields = append(fields, usagestatisticday.FieldStatus)
  33940. }
  33941. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  33942. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33943. }
  33944. if m.FieldCleared(usagestatisticday.FieldBotID) {
  33945. fields = append(fields, usagestatisticday.FieldBotID)
  33946. }
  33947. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  33948. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33949. }
  33950. return fields
  33951. }
  33952. // FieldCleared returns a boolean indicating if a field with the given name was
  33953. // cleared in this mutation.
  33954. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  33955. _, ok := m.clearedFields[name]
  33956. return ok
  33957. }
  33958. // ClearField clears the value of the field with the given name. It returns an
  33959. // error if the field is not defined in the schema.
  33960. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  33961. switch name {
  33962. case usagestatisticday.FieldStatus:
  33963. m.ClearStatus()
  33964. return nil
  33965. case usagestatisticday.FieldDeletedAt:
  33966. m.ClearDeletedAt()
  33967. return nil
  33968. case usagestatisticday.FieldBotID:
  33969. m.ClearBotID()
  33970. return nil
  33971. case usagestatisticday.FieldOrganizationID:
  33972. m.ClearOrganizationID()
  33973. return nil
  33974. }
  33975. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  33976. }
  33977. // ResetField resets all changes in the mutation for the field with the given name.
  33978. // It returns an error if the field is not defined in the schema.
  33979. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  33980. switch name {
  33981. case usagestatisticday.FieldCreatedAt:
  33982. m.ResetCreatedAt()
  33983. return nil
  33984. case usagestatisticday.FieldUpdatedAt:
  33985. m.ResetUpdatedAt()
  33986. return nil
  33987. case usagestatisticday.FieldStatus:
  33988. m.ResetStatus()
  33989. return nil
  33990. case usagestatisticday.FieldDeletedAt:
  33991. m.ResetDeletedAt()
  33992. return nil
  33993. case usagestatisticday.FieldAddtime:
  33994. m.ResetAddtime()
  33995. return nil
  33996. case usagestatisticday.FieldType:
  33997. m.ResetType()
  33998. return nil
  33999. case usagestatisticday.FieldBotID:
  34000. m.ResetBotID()
  34001. return nil
  34002. case usagestatisticday.FieldOrganizationID:
  34003. m.ResetOrganizationID()
  34004. return nil
  34005. case usagestatisticday.FieldAiResponse:
  34006. m.ResetAiResponse()
  34007. return nil
  34008. case usagestatisticday.FieldSopRun:
  34009. m.ResetSopRun()
  34010. return nil
  34011. case usagestatisticday.FieldTotalFriend:
  34012. m.ResetTotalFriend()
  34013. return nil
  34014. case usagestatisticday.FieldTotalGroup:
  34015. m.ResetTotalGroup()
  34016. return nil
  34017. case usagestatisticday.FieldAccountBalance:
  34018. m.ResetAccountBalance()
  34019. return nil
  34020. case usagestatisticday.FieldConsumeToken:
  34021. m.ResetConsumeToken()
  34022. return nil
  34023. case usagestatisticday.FieldActiveUser:
  34024. m.ResetActiveUser()
  34025. return nil
  34026. case usagestatisticday.FieldNewUser:
  34027. m.ResetNewUser()
  34028. return nil
  34029. case usagestatisticday.FieldLabelDist:
  34030. m.ResetLabelDist()
  34031. return nil
  34032. }
  34033. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  34034. }
  34035. // AddedEdges returns all edge names that were set/added in this mutation.
  34036. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  34037. edges := make([]string, 0, 0)
  34038. return edges
  34039. }
  34040. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34041. // name in this mutation.
  34042. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  34043. return nil
  34044. }
  34045. // RemovedEdges returns all edge names that were removed in this mutation.
  34046. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  34047. edges := make([]string, 0, 0)
  34048. return edges
  34049. }
  34050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34051. // the given name in this mutation.
  34052. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  34053. return nil
  34054. }
  34055. // ClearedEdges returns all edge names that were cleared in this mutation.
  34056. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  34057. edges := make([]string, 0, 0)
  34058. return edges
  34059. }
  34060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34061. // was cleared in this mutation.
  34062. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  34063. return false
  34064. }
  34065. // ClearEdge clears the value of the edge with the given name. It returns an error
  34066. // if that edge is not defined in the schema.
  34067. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  34068. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  34069. }
  34070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34071. // It returns an error if the edge is not defined in the schema.
  34072. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  34073. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  34074. }
  34075. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  34076. type UsageStatisticHourMutation struct {
  34077. config
  34078. op Op
  34079. typ string
  34080. id *uint64
  34081. created_at *time.Time
  34082. updated_at *time.Time
  34083. status *uint8
  34084. addstatus *int8
  34085. deleted_at *time.Time
  34086. addtime *uint64
  34087. addaddtime *int64
  34088. _type *int
  34089. add_type *int
  34090. bot_id *string
  34091. organization_id *uint64
  34092. addorganization_id *int64
  34093. ai_response *uint64
  34094. addai_response *int64
  34095. sop_run *uint64
  34096. addsop_run *int64
  34097. total_friend *uint64
  34098. addtotal_friend *int64
  34099. total_group *uint64
  34100. addtotal_group *int64
  34101. account_balance *uint64
  34102. addaccount_balance *int64
  34103. consume_token *uint64
  34104. addconsume_token *int64
  34105. active_user *uint64
  34106. addactive_user *int64
  34107. new_user *int64
  34108. addnew_user *int64
  34109. label_dist *[]custom_types.LabelDist
  34110. appendlabel_dist []custom_types.LabelDist
  34111. clearedFields map[string]struct{}
  34112. done bool
  34113. oldValue func(context.Context) (*UsageStatisticHour, error)
  34114. predicates []predicate.UsageStatisticHour
  34115. }
  34116. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  34117. // usagestatistichourOption allows management of the mutation configuration using functional options.
  34118. type usagestatistichourOption func(*UsageStatisticHourMutation)
  34119. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  34120. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  34121. m := &UsageStatisticHourMutation{
  34122. config: c,
  34123. op: op,
  34124. typ: TypeUsageStatisticHour,
  34125. clearedFields: make(map[string]struct{}),
  34126. }
  34127. for _, opt := range opts {
  34128. opt(m)
  34129. }
  34130. return m
  34131. }
  34132. // withUsageStatisticHourID sets the ID field of the mutation.
  34133. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  34134. return func(m *UsageStatisticHourMutation) {
  34135. var (
  34136. err error
  34137. once sync.Once
  34138. value *UsageStatisticHour
  34139. )
  34140. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  34141. once.Do(func() {
  34142. if m.done {
  34143. err = errors.New("querying old values post mutation is not allowed")
  34144. } else {
  34145. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  34146. }
  34147. })
  34148. return value, err
  34149. }
  34150. m.id = &id
  34151. }
  34152. }
  34153. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  34154. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  34155. return func(m *UsageStatisticHourMutation) {
  34156. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  34157. return node, nil
  34158. }
  34159. m.id = &node.ID
  34160. }
  34161. }
  34162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34163. // executed in a transaction (ent.Tx), a transactional client is returned.
  34164. func (m UsageStatisticHourMutation) Client() *Client {
  34165. client := &Client{config: m.config}
  34166. client.init()
  34167. return client
  34168. }
  34169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34170. // it returns an error otherwise.
  34171. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  34172. if _, ok := m.driver.(*txDriver); !ok {
  34173. return nil, errors.New("ent: mutation is not running in a transaction")
  34174. }
  34175. tx := &Tx{config: m.config}
  34176. tx.init()
  34177. return tx, nil
  34178. }
  34179. // SetID sets the value of the id field. Note that this
  34180. // operation is only accepted on creation of UsageStatisticHour entities.
  34181. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  34182. m.id = &id
  34183. }
  34184. // ID returns the ID value in the mutation. Note that the ID is only available
  34185. // if it was provided to the builder or after it was returned from the database.
  34186. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  34187. if m.id == nil {
  34188. return
  34189. }
  34190. return *m.id, true
  34191. }
  34192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34193. // That means, if the mutation is applied within a transaction with an isolation level such
  34194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34195. // or updated by the mutation.
  34196. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  34197. switch {
  34198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34199. id, exists := m.ID()
  34200. if exists {
  34201. return []uint64{id}, nil
  34202. }
  34203. fallthrough
  34204. case m.op.Is(OpUpdate | OpDelete):
  34205. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  34206. default:
  34207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34208. }
  34209. }
  34210. // SetCreatedAt sets the "created_at" field.
  34211. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  34212. m.created_at = &t
  34213. }
  34214. // CreatedAt returns the value of the "created_at" field in the mutation.
  34215. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  34216. v := m.created_at
  34217. if v == nil {
  34218. return
  34219. }
  34220. return *v, true
  34221. }
  34222. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  34223. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34225. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34226. if !m.op.Is(OpUpdateOne) {
  34227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34228. }
  34229. if m.id == nil || m.oldValue == nil {
  34230. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34231. }
  34232. oldValue, err := m.oldValue(ctx)
  34233. if err != nil {
  34234. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34235. }
  34236. return oldValue.CreatedAt, nil
  34237. }
  34238. // ResetCreatedAt resets all changes to the "created_at" field.
  34239. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  34240. m.created_at = nil
  34241. }
  34242. // SetUpdatedAt sets the "updated_at" field.
  34243. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  34244. m.updated_at = &t
  34245. }
  34246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34247. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  34248. v := m.updated_at
  34249. if v == nil {
  34250. return
  34251. }
  34252. return *v, true
  34253. }
  34254. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  34255. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34257. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34258. if !m.op.Is(OpUpdateOne) {
  34259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34260. }
  34261. if m.id == nil || m.oldValue == nil {
  34262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34263. }
  34264. oldValue, err := m.oldValue(ctx)
  34265. if err != nil {
  34266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34267. }
  34268. return oldValue.UpdatedAt, nil
  34269. }
  34270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34271. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  34272. m.updated_at = nil
  34273. }
  34274. // SetStatus sets the "status" field.
  34275. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  34276. m.status = &u
  34277. m.addstatus = nil
  34278. }
  34279. // Status returns the value of the "status" field in the mutation.
  34280. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  34281. v := m.status
  34282. if v == nil {
  34283. return
  34284. }
  34285. return *v, true
  34286. }
  34287. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  34288. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34290. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34291. if !m.op.Is(OpUpdateOne) {
  34292. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34293. }
  34294. if m.id == nil || m.oldValue == nil {
  34295. return v, errors.New("OldStatus requires an ID field in the mutation")
  34296. }
  34297. oldValue, err := m.oldValue(ctx)
  34298. if err != nil {
  34299. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34300. }
  34301. return oldValue.Status, nil
  34302. }
  34303. // AddStatus adds u to the "status" field.
  34304. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  34305. if m.addstatus != nil {
  34306. *m.addstatus += u
  34307. } else {
  34308. m.addstatus = &u
  34309. }
  34310. }
  34311. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34312. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  34313. v := m.addstatus
  34314. if v == nil {
  34315. return
  34316. }
  34317. return *v, true
  34318. }
  34319. // ClearStatus clears the value of the "status" field.
  34320. func (m *UsageStatisticHourMutation) ClearStatus() {
  34321. m.status = nil
  34322. m.addstatus = nil
  34323. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  34324. }
  34325. // StatusCleared returns if the "status" field was cleared in this mutation.
  34326. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  34327. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  34328. return ok
  34329. }
  34330. // ResetStatus resets all changes to the "status" field.
  34331. func (m *UsageStatisticHourMutation) ResetStatus() {
  34332. m.status = nil
  34333. m.addstatus = nil
  34334. delete(m.clearedFields, usagestatistichour.FieldStatus)
  34335. }
  34336. // SetDeletedAt sets the "deleted_at" field.
  34337. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  34338. m.deleted_at = &t
  34339. }
  34340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34341. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  34342. v := m.deleted_at
  34343. if v == nil {
  34344. return
  34345. }
  34346. return *v, true
  34347. }
  34348. // OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34352. if !m.op.Is(OpUpdateOne) {
  34353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34354. }
  34355. if m.id == nil || m.oldValue == nil {
  34356. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  34361. }
  34362. return oldValue.DeletedAt, nil
  34363. }
  34364. // ClearDeletedAt clears the value of the "deleted_at" field.
  34365. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  34366. m.deleted_at = nil
  34367. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  34368. }
  34369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34370. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  34371. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  34372. return ok
  34373. }
  34374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34375. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  34376. m.deleted_at = nil
  34377. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  34378. }
  34379. // SetAddtime sets the "addtime" field.
  34380. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  34381. m.addtime = &u
  34382. m.addaddtime = nil
  34383. }
  34384. // Addtime returns the value of the "addtime" field in the mutation.
  34385. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  34386. v := m.addtime
  34387. if v == nil {
  34388. return
  34389. }
  34390. return *v, true
  34391. }
  34392. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  34393. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34395. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34396. if !m.op.Is(OpUpdateOne) {
  34397. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34398. }
  34399. if m.id == nil || m.oldValue == nil {
  34400. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34401. }
  34402. oldValue, err := m.oldValue(ctx)
  34403. if err != nil {
  34404. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34405. }
  34406. return oldValue.Addtime, nil
  34407. }
  34408. // AddAddtime adds u to the "addtime" field.
  34409. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  34410. if m.addaddtime != nil {
  34411. *m.addaddtime += u
  34412. } else {
  34413. m.addaddtime = &u
  34414. }
  34415. }
  34416. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34417. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  34418. v := m.addaddtime
  34419. if v == nil {
  34420. return
  34421. }
  34422. return *v, true
  34423. }
  34424. // ResetAddtime resets all changes to the "addtime" field.
  34425. func (m *UsageStatisticHourMutation) ResetAddtime() {
  34426. m.addtime = nil
  34427. m.addaddtime = nil
  34428. }
  34429. // SetType sets the "type" field.
  34430. func (m *UsageStatisticHourMutation) SetType(i int) {
  34431. m._type = &i
  34432. m.add_type = nil
  34433. }
  34434. // GetType returns the value of the "type" field in the mutation.
  34435. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  34436. v := m._type
  34437. if v == nil {
  34438. return
  34439. }
  34440. return *v, true
  34441. }
  34442. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  34443. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34445. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  34446. if !m.op.Is(OpUpdateOne) {
  34447. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34448. }
  34449. if m.id == nil || m.oldValue == nil {
  34450. return v, errors.New("OldType requires an ID field in the mutation")
  34451. }
  34452. oldValue, err := m.oldValue(ctx)
  34453. if err != nil {
  34454. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34455. }
  34456. return oldValue.Type, nil
  34457. }
  34458. // AddType adds i to the "type" field.
  34459. func (m *UsageStatisticHourMutation) AddType(i int) {
  34460. if m.add_type != nil {
  34461. *m.add_type += i
  34462. } else {
  34463. m.add_type = &i
  34464. }
  34465. }
  34466. // AddedType returns the value that was added to the "type" field in this mutation.
  34467. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  34468. v := m.add_type
  34469. if v == nil {
  34470. return
  34471. }
  34472. return *v, true
  34473. }
  34474. // ResetType resets all changes to the "type" field.
  34475. func (m *UsageStatisticHourMutation) ResetType() {
  34476. m._type = nil
  34477. m.add_type = nil
  34478. }
  34479. // SetBotID sets the "bot_id" field.
  34480. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  34481. m.bot_id = &s
  34482. }
  34483. // BotID returns the value of the "bot_id" field in the mutation.
  34484. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  34485. v := m.bot_id
  34486. if v == nil {
  34487. return
  34488. }
  34489. return *v, true
  34490. }
  34491. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  34492. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34494. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  34495. if !m.op.Is(OpUpdateOne) {
  34496. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34497. }
  34498. if m.id == nil || m.oldValue == nil {
  34499. return v, errors.New("OldBotID requires an ID field in the mutation")
  34500. }
  34501. oldValue, err := m.oldValue(ctx)
  34502. if err != nil {
  34503. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34504. }
  34505. return oldValue.BotID, nil
  34506. }
  34507. // ClearBotID clears the value of the "bot_id" field.
  34508. func (m *UsageStatisticHourMutation) ClearBotID() {
  34509. m.bot_id = nil
  34510. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  34511. }
  34512. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34513. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  34514. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  34515. return ok
  34516. }
  34517. // ResetBotID resets all changes to the "bot_id" field.
  34518. func (m *UsageStatisticHourMutation) ResetBotID() {
  34519. m.bot_id = nil
  34520. delete(m.clearedFields, usagestatistichour.FieldBotID)
  34521. }
  34522. // SetOrganizationID sets the "organization_id" field.
  34523. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  34524. m.organization_id = &u
  34525. m.addorganization_id = nil
  34526. }
  34527. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34528. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  34529. v := m.organization_id
  34530. if v == nil {
  34531. return
  34532. }
  34533. return *v, true
  34534. }
  34535. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  34536. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34538. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34539. if !m.op.Is(OpUpdateOne) {
  34540. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34541. }
  34542. if m.id == nil || m.oldValue == nil {
  34543. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34544. }
  34545. oldValue, err := m.oldValue(ctx)
  34546. if err != nil {
  34547. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34548. }
  34549. return oldValue.OrganizationID, nil
  34550. }
  34551. // AddOrganizationID adds u to the "organization_id" field.
  34552. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  34553. if m.addorganization_id != nil {
  34554. *m.addorganization_id += u
  34555. } else {
  34556. m.addorganization_id = &u
  34557. }
  34558. }
  34559. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34560. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  34561. v := m.addorganization_id
  34562. if v == nil {
  34563. return
  34564. }
  34565. return *v, true
  34566. }
  34567. // ClearOrganizationID clears the value of the "organization_id" field.
  34568. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  34569. m.organization_id = nil
  34570. m.addorganization_id = nil
  34571. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  34572. }
  34573. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34574. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  34575. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  34576. return ok
  34577. }
  34578. // ResetOrganizationID resets all changes to the "organization_id" field.
  34579. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  34580. m.organization_id = nil
  34581. m.addorganization_id = nil
  34582. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  34583. }
  34584. // SetAiResponse sets the "ai_response" field.
  34585. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  34586. m.ai_response = &u
  34587. m.addai_response = nil
  34588. }
  34589. // AiResponse returns the value of the "ai_response" field in the mutation.
  34590. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  34591. v := m.ai_response
  34592. if v == nil {
  34593. return
  34594. }
  34595. return *v, true
  34596. }
  34597. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  34598. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34600. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34601. if !m.op.Is(OpUpdateOne) {
  34602. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34603. }
  34604. if m.id == nil || m.oldValue == nil {
  34605. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34606. }
  34607. oldValue, err := m.oldValue(ctx)
  34608. if err != nil {
  34609. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34610. }
  34611. return oldValue.AiResponse, nil
  34612. }
  34613. // AddAiResponse adds u to the "ai_response" field.
  34614. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  34615. if m.addai_response != nil {
  34616. *m.addai_response += u
  34617. } else {
  34618. m.addai_response = &u
  34619. }
  34620. }
  34621. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34622. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  34623. v := m.addai_response
  34624. if v == nil {
  34625. return
  34626. }
  34627. return *v, true
  34628. }
  34629. // ResetAiResponse resets all changes to the "ai_response" field.
  34630. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  34631. m.ai_response = nil
  34632. m.addai_response = nil
  34633. }
  34634. // SetSopRun sets the "sop_run" field.
  34635. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  34636. m.sop_run = &u
  34637. m.addsop_run = nil
  34638. }
  34639. // SopRun returns the value of the "sop_run" field in the mutation.
  34640. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  34641. v := m.sop_run
  34642. if v == nil {
  34643. return
  34644. }
  34645. return *v, true
  34646. }
  34647. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  34648. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34650. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34651. if !m.op.Is(OpUpdateOne) {
  34652. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34653. }
  34654. if m.id == nil || m.oldValue == nil {
  34655. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34656. }
  34657. oldValue, err := m.oldValue(ctx)
  34658. if err != nil {
  34659. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34660. }
  34661. return oldValue.SopRun, nil
  34662. }
  34663. // AddSopRun adds u to the "sop_run" field.
  34664. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  34665. if m.addsop_run != nil {
  34666. *m.addsop_run += u
  34667. } else {
  34668. m.addsop_run = &u
  34669. }
  34670. }
  34671. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34672. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  34673. v := m.addsop_run
  34674. if v == nil {
  34675. return
  34676. }
  34677. return *v, true
  34678. }
  34679. // ResetSopRun resets all changes to the "sop_run" field.
  34680. func (m *UsageStatisticHourMutation) ResetSopRun() {
  34681. m.sop_run = nil
  34682. m.addsop_run = nil
  34683. }
  34684. // SetTotalFriend sets the "total_friend" field.
  34685. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  34686. m.total_friend = &u
  34687. m.addtotal_friend = nil
  34688. }
  34689. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34690. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  34691. v := m.total_friend
  34692. if v == nil {
  34693. return
  34694. }
  34695. return *v, true
  34696. }
  34697. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  34698. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34700. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34701. if !m.op.Is(OpUpdateOne) {
  34702. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34703. }
  34704. if m.id == nil || m.oldValue == nil {
  34705. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34706. }
  34707. oldValue, err := m.oldValue(ctx)
  34708. if err != nil {
  34709. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34710. }
  34711. return oldValue.TotalFriend, nil
  34712. }
  34713. // AddTotalFriend adds u to the "total_friend" field.
  34714. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  34715. if m.addtotal_friend != nil {
  34716. *m.addtotal_friend += u
  34717. } else {
  34718. m.addtotal_friend = &u
  34719. }
  34720. }
  34721. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34722. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  34723. v := m.addtotal_friend
  34724. if v == nil {
  34725. return
  34726. }
  34727. return *v, true
  34728. }
  34729. // ResetTotalFriend resets all changes to the "total_friend" field.
  34730. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  34731. m.total_friend = nil
  34732. m.addtotal_friend = nil
  34733. }
  34734. // SetTotalGroup sets the "total_group" field.
  34735. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  34736. m.total_group = &u
  34737. m.addtotal_group = nil
  34738. }
  34739. // TotalGroup returns the value of the "total_group" field in the mutation.
  34740. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  34741. v := m.total_group
  34742. if v == nil {
  34743. return
  34744. }
  34745. return *v, true
  34746. }
  34747. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  34748. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34750. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34751. if !m.op.Is(OpUpdateOne) {
  34752. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34753. }
  34754. if m.id == nil || m.oldValue == nil {
  34755. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34756. }
  34757. oldValue, err := m.oldValue(ctx)
  34758. if err != nil {
  34759. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34760. }
  34761. return oldValue.TotalGroup, nil
  34762. }
  34763. // AddTotalGroup adds u to the "total_group" field.
  34764. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  34765. if m.addtotal_group != nil {
  34766. *m.addtotal_group += u
  34767. } else {
  34768. m.addtotal_group = &u
  34769. }
  34770. }
  34771. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34772. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  34773. v := m.addtotal_group
  34774. if v == nil {
  34775. return
  34776. }
  34777. return *v, true
  34778. }
  34779. // ResetTotalGroup resets all changes to the "total_group" field.
  34780. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  34781. m.total_group = nil
  34782. m.addtotal_group = nil
  34783. }
  34784. // SetAccountBalance sets the "account_balance" field.
  34785. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  34786. m.account_balance = &u
  34787. m.addaccount_balance = nil
  34788. }
  34789. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34790. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  34791. v := m.account_balance
  34792. if v == nil {
  34793. return
  34794. }
  34795. return *v, true
  34796. }
  34797. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  34798. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34800. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34801. if !m.op.Is(OpUpdateOne) {
  34802. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34803. }
  34804. if m.id == nil || m.oldValue == nil {
  34805. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34806. }
  34807. oldValue, err := m.oldValue(ctx)
  34808. if err != nil {
  34809. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34810. }
  34811. return oldValue.AccountBalance, nil
  34812. }
  34813. // AddAccountBalance adds u to the "account_balance" field.
  34814. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  34815. if m.addaccount_balance != nil {
  34816. *m.addaccount_balance += u
  34817. } else {
  34818. m.addaccount_balance = &u
  34819. }
  34820. }
  34821. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34822. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  34823. v := m.addaccount_balance
  34824. if v == nil {
  34825. return
  34826. }
  34827. return *v, true
  34828. }
  34829. // ResetAccountBalance resets all changes to the "account_balance" field.
  34830. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  34831. m.account_balance = nil
  34832. m.addaccount_balance = nil
  34833. }
  34834. // SetConsumeToken sets the "consume_token" field.
  34835. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  34836. m.consume_token = &u
  34837. m.addconsume_token = nil
  34838. }
  34839. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34840. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  34841. v := m.consume_token
  34842. if v == nil {
  34843. return
  34844. }
  34845. return *v, true
  34846. }
  34847. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  34848. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34850. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34851. if !m.op.Is(OpUpdateOne) {
  34852. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34853. }
  34854. if m.id == nil || m.oldValue == nil {
  34855. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34856. }
  34857. oldValue, err := m.oldValue(ctx)
  34858. if err != nil {
  34859. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34860. }
  34861. return oldValue.ConsumeToken, nil
  34862. }
  34863. // AddConsumeToken adds u to the "consume_token" field.
  34864. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  34865. if m.addconsume_token != nil {
  34866. *m.addconsume_token += u
  34867. } else {
  34868. m.addconsume_token = &u
  34869. }
  34870. }
  34871. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34872. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  34873. v := m.addconsume_token
  34874. if v == nil {
  34875. return
  34876. }
  34877. return *v, true
  34878. }
  34879. // ResetConsumeToken resets all changes to the "consume_token" field.
  34880. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  34881. m.consume_token = nil
  34882. m.addconsume_token = nil
  34883. }
  34884. // SetActiveUser sets the "active_user" field.
  34885. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  34886. m.active_user = &u
  34887. m.addactive_user = nil
  34888. }
  34889. // ActiveUser returns the value of the "active_user" field in the mutation.
  34890. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  34891. v := m.active_user
  34892. if v == nil {
  34893. return
  34894. }
  34895. return *v, true
  34896. }
  34897. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  34898. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34900. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34901. if !m.op.Is(OpUpdateOne) {
  34902. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34903. }
  34904. if m.id == nil || m.oldValue == nil {
  34905. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34906. }
  34907. oldValue, err := m.oldValue(ctx)
  34908. if err != nil {
  34909. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34910. }
  34911. return oldValue.ActiveUser, nil
  34912. }
  34913. // AddActiveUser adds u to the "active_user" field.
  34914. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  34915. if m.addactive_user != nil {
  34916. *m.addactive_user += u
  34917. } else {
  34918. m.addactive_user = &u
  34919. }
  34920. }
  34921. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34922. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  34923. v := m.addactive_user
  34924. if v == nil {
  34925. return
  34926. }
  34927. return *v, true
  34928. }
  34929. // ResetActiveUser resets all changes to the "active_user" field.
  34930. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  34931. m.active_user = nil
  34932. m.addactive_user = nil
  34933. }
  34934. // SetNewUser sets the "new_user" field.
  34935. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  34936. m.new_user = &i
  34937. m.addnew_user = nil
  34938. }
  34939. // NewUser returns the value of the "new_user" field in the mutation.
  34940. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  34941. v := m.new_user
  34942. if v == nil {
  34943. return
  34944. }
  34945. return *v, true
  34946. }
  34947. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  34948. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34950. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34951. if !m.op.Is(OpUpdateOne) {
  34952. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34953. }
  34954. if m.id == nil || m.oldValue == nil {
  34955. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34956. }
  34957. oldValue, err := m.oldValue(ctx)
  34958. if err != nil {
  34959. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34960. }
  34961. return oldValue.NewUser, nil
  34962. }
  34963. // AddNewUser adds i to the "new_user" field.
  34964. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  34965. if m.addnew_user != nil {
  34966. *m.addnew_user += i
  34967. } else {
  34968. m.addnew_user = &i
  34969. }
  34970. }
  34971. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34972. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  34973. v := m.addnew_user
  34974. if v == nil {
  34975. return
  34976. }
  34977. return *v, true
  34978. }
  34979. // ResetNewUser resets all changes to the "new_user" field.
  34980. func (m *UsageStatisticHourMutation) ResetNewUser() {
  34981. m.new_user = nil
  34982. m.addnew_user = nil
  34983. }
  34984. // SetLabelDist sets the "label_dist" field.
  34985. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34986. m.label_dist = &ctd
  34987. m.appendlabel_dist = nil
  34988. }
  34989. // LabelDist returns the value of the "label_dist" field in the mutation.
  34990. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34991. v := m.label_dist
  34992. if v == nil {
  34993. return
  34994. }
  34995. return *v, true
  34996. }
  34997. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  34998. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35000. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35001. if !m.op.Is(OpUpdateOne) {
  35002. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35003. }
  35004. if m.id == nil || m.oldValue == nil {
  35005. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35006. }
  35007. oldValue, err := m.oldValue(ctx)
  35008. if err != nil {
  35009. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35010. }
  35011. return oldValue.LabelDist, nil
  35012. }
  35013. // AppendLabelDist adds ctd to the "label_dist" field.
  35014. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35015. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35016. }
  35017. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35018. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35019. if len(m.appendlabel_dist) == 0 {
  35020. return nil, false
  35021. }
  35022. return m.appendlabel_dist, true
  35023. }
  35024. // ResetLabelDist resets all changes to the "label_dist" field.
  35025. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  35026. m.label_dist = nil
  35027. m.appendlabel_dist = nil
  35028. }
  35029. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  35030. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  35031. m.predicates = append(m.predicates, ps...)
  35032. }
  35033. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  35034. // users can use type-assertion to append predicates that do not depend on any generated package.
  35035. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  35036. p := make([]predicate.UsageStatisticHour, len(ps))
  35037. for i := range ps {
  35038. p[i] = ps[i]
  35039. }
  35040. m.Where(p...)
  35041. }
  35042. // Op returns the operation name.
  35043. func (m *UsageStatisticHourMutation) Op() Op {
  35044. return m.op
  35045. }
  35046. // SetOp allows setting the mutation operation.
  35047. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  35048. m.op = op
  35049. }
  35050. // Type returns the node type of this mutation (UsageStatisticHour).
  35051. func (m *UsageStatisticHourMutation) Type() string {
  35052. return m.typ
  35053. }
  35054. // Fields returns all fields that were changed during this mutation. Note that in
  35055. // order to get all numeric fields that were incremented/decremented, call
  35056. // AddedFields().
  35057. func (m *UsageStatisticHourMutation) Fields() []string {
  35058. fields := make([]string, 0, 17)
  35059. if m.created_at != nil {
  35060. fields = append(fields, usagestatistichour.FieldCreatedAt)
  35061. }
  35062. if m.updated_at != nil {
  35063. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  35064. }
  35065. if m.status != nil {
  35066. fields = append(fields, usagestatistichour.FieldStatus)
  35067. }
  35068. if m.deleted_at != nil {
  35069. fields = append(fields, usagestatistichour.FieldDeletedAt)
  35070. }
  35071. if m.addtime != nil {
  35072. fields = append(fields, usagestatistichour.FieldAddtime)
  35073. }
  35074. if m._type != nil {
  35075. fields = append(fields, usagestatistichour.FieldType)
  35076. }
  35077. if m.bot_id != nil {
  35078. fields = append(fields, usagestatistichour.FieldBotID)
  35079. }
  35080. if m.organization_id != nil {
  35081. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35082. }
  35083. if m.ai_response != nil {
  35084. fields = append(fields, usagestatistichour.FieldAiResponse)
  35085. }
  35086. if m.sop_run != nil {
  35087. fields = append(fields, usagestatistichour.FieldSopRun)
  35088. }
  35089. if m.total_friend != nil {
  35090. fields = append(fields, usagestatistichour.FieldTotalFriend)
  35091. }
  35092. if m.total_group != nil {
  35093. fields = append(fields, usagestatistichour.FieldTotalGroup)
  35094. }
  35095. if m.account_balance != nil {
  35096. fields = append(fields, usagestatistichour.FieldAccountBalance)
  35097. }
  35098. if m.consume_token != nil {
  35099. fields = append(fields, usagestatistichour.FieldConsumeToken)
  35100. }
  35101. if m.active_user != nil {
  35102. fields = append(fields, usagestatistichour.FieldActiveUser)
  35103. }
  35104. if m.new_user != nil {
  35105. fields = append(fields, usagestatistichour.FieldNewUser)
  35106. }
  35107. if m.label_dist != nil {
  35108. fields = append(fields, usagestatistichour.FieldLabelDist)
  35109. }
  35110. return fields
  35111. }
  35112. // Field returns the value of a field with the given name. The second boolean
  35113. // return value indicates that this field was not set, or was not defined in the
  35114. // schema.
  35115. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  35116. switch name {
  35117. case usagestatistichour.FieldCreatedAt:
  35118. return m.CreatedAt()
  35119. case usagestatistichour.FieldUpdatedAt:
  35120. return m.UpdatedAt()
  35121. case usagestatistichour.FieldStatus:
  35122. return m.Status()
  35123. case usagestatistichour.FieldDeletedAt:
  35124. return m.DeletedAt()
  35125. case usagestatistichour.FieldAddtime:
  35126. return m.Addtime()
  35127. case usagestatistichour.FieldType:
  35128. return m.GetType()
  35129. case usagestatistichour.FieldBotID:
  35130. return m.BotID()
  35131. case usagestatistichour.FieldOrganizationID:
  35132. return m.OrganizationID()
  35133. case usagestatistichour.FieldAiResponse:
  35134. return m.AiResponse()
  35135. case usagestatistichour.FieldSopRun:
  35136. return m.SopRun()
  35137. case usagestatistichour.FieldTotalFriend:
  35138. return m.TotalFriend()
  35139. case usagestatistichour.FieldTotalGroup:
  35140. return m.TotalGroup()
  35141. case usagestatistichour.FieldAccountBalance:
  35142. return m.AccountBalance()
  35143. case usagestatistichour.FieldConsumeToken:
  35144. return m.ConsumeToken()
  35145. case usagestatistichour.FieldActiveUser:
  35146. return m.ActiveUser()
  35147. case usagestatistichour.FieldNewUser:
  35148. return m.NewUser()
  35149. case usagestatistichour.FieldLabelDist:
  35150. return m.LabelDist()
  35151. }
  35152. return nil, false
  35153. }
  35154. // OldField returns the old value of the field from the database. An error is
  35155. // returned if the mutation operation is not UpdateOne, or the query to the
  35156. // database failed.
  35157. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35158. switch name {
  35159. case usagestatistichour.FieldCreatedAt:
  35160. return m.OldCreatedAt(ctx)
  35161. case usagestatistichour.FieldUpdatedAt:
  35162. return m.OldUpdatedAt(ctx)
  35163. case usagestatistichour.FieldStatus:
  35164. return m.OldStatus(ctx)
  35165. case usagestatistichour.FieldDeletedAt:
  35166. return m.OldDeletedAt(ctx)
  35167. case usagestatistichour.FieldAddtime:
  35168. return m.OldAddtime(ctx)
  35169. case usagestatistichour.FieldType:
  35170. return m.OldType(ctx)
  35171. case usagestatistichour.FieldBotID:
  35172. return m.OldBotID(ctx)
  35173. case usagestatistichour.FieldOrganizationID:
  35174. return m.OldOrganizationID(ctx)
  35175. case usagestatistichour.FieldAiResponse:
  35176. return m.OldAiResponse(ctx)
  35177. case usagestatistichour.FieldSopRun:
  35178. return m.OldSopRun(ctx)
  35179. case usagestatistichour.FieldTotalFriend:
  35180. return m.OldTotalFriend(ctx)
  35181. case usagestatistichour.FieldTotalGroup:
  35182. return m.OldTotalGroup(ctx)
  35183. case usagestatistichour.FieldAccountBalance:
  35184. return m.OldAccountBalance(ctx)
  35185. case usagestatistichour.FieldConsumeToken:
  35186. return m.OldConsumeToken(ctx)
  35187. case usagestatistichour.FieldActiveUser:
  35188. return m.OldActiveUser(ctx)
  35189. case usagestatistichour.FieldNewUser:
  35190. return m.OldNewUser(ctx)
  35191. case usagestatistichour.FieldLabelDist:
  35192. return m.OldLabelDist(ctx)
  35193. }
  35194. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35195. }
  35196. // SetField sets the value of a field with the given name. It returns an error if
  35197. // the field is not defined in the schema, or if the type mismatched the field
  35198. // type.
  35199. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  35200. switch name {
  35201. case usagestatistichour.FieldCreatedAt:
  35202. v, ok := value.(time.Time)
  35203. if !ok {
  35204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35205. }
  35206. m.SetCreatedAt(v)
  35207. return nil
  35208. case usagestatistichour.FieldUpdatedAt:
  35209. v, ok := value.(time.Time)
  35210. if !ok {
  35211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35212. }
  35213. m.SetUpdatedAt(v)
  35214. return nil
  35215. case usagestatistichour.FieldStatus:
  35216. v, ok := value.(uint8)
  35217. if !ok {
  35218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35219. }
  35220. m.SetStatus(v)
  35221. return nil
  35222. case usagestatistichour.FieldDeletedAt:
  35223. v, ok := value.(time.Time)
  35224. if !ok {
  35225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35226. }
  35227. m.SetDeletedAt(v)
  35228. return nil
  35229. case usagestatistichour.FieldAddtime:
  35230. v, ok := value.(uint64)
  35231. if !ok {
  35232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35233. }
  35234. m.SetAddtime(v)
  35235. return nil
  35236. case usagestatistichour.FieldType:
  35237. v, ok := value.(int)
  35238. if !ok {
  35239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35240. }
  35241. m.SetType(v)
  35242. return nil
  35243. case usagestatistichour.FieldBotID:
  35244. v, ok := value.(string)
  35245. if !ok {
  35246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35247. }
  35248. m.SetBotID(v)
  35249. return nil
  35250. case usagestatistichour.FieldOrganizationID:
  35251. v, ok := value.(uint64)
  35252. if !ok {
  35253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35254. }
  35255. m.SetOrganizationID(v)
  35256. return nil
  35257. case usagestatistichour.FieldAiResponse:
  35258. v, ok := value.(uint64)
  35259. if !ok {
  35260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35261. }
  35262. m.SetAiResponse(v)
  35263. return nil
  35264. case usagestatistichour.FieldSopRun:
  35265. v, ok := value.(uint64)
  35266. if !ok {
  35267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35268. }
  35269. m.SetSopRun(v)
  35270. return nil
  35271. case usagestatistichour.FieldTotalFriend:
  35272. v, ok := value.(uint64)
  35273. if !ok {
  35274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35275. }
  35276. m.SetTotalFriend(v)
  35277. return nil
  35278. case usagestatistichour.FieldTotalGroup:
  35279. v, ok := value.(uint64)
  35280. if !ok {
  35281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35282. }
  35283. m.SetTotalGroup(v)
  35284. return nil
  35285. case usagestatistichour.FieldAccountBalance:
  35286. v, ok := value.(uint64)
  35287. if !ok {
  35288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35289. }
  35290. m.SetAccountBalance(v)
  35291. return nil
  35292. case usagestatistichour.FieldConsumeToken:
  35293. v, ok := value.(uint64)
  35294. if !ok {
  35295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35296. }
  35297. m.SetConsumeToken(v)
  35298. return nil
  35299. case usagestatistichour.FieldActiveUser:
  35300. v, ok := value.(uint64)
  35301. if !ok {
  35302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35303. }
  35304. m.SetActiveUser(v)
  35305. return nil
  35306. case usagestatistichour.FieldNewUser:
  35307. v, ok := value.(int64)
  35308. if !ok {
  35309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35310. }
  35311. m.SetNewUser(v)
  35312. return nil
  35313. case usagestatistichour.FieldLabelDist:
  35314. v, ok := value.([]custom_types.LabelDist)
  35315. if !ok {
  35316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35317. }
  35318. m.SetLabelDist(v)
  35319. return nil
  35320. }
  35321. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35322. }
  35323. // AddedFields returns all numeric fields that were incremented/decremented during
  35324. // this mutation.
  35325. func (m *UsageStatisticHourMutation) AddedFields() []string {
  35326. var fields []string
  35327. if m.addstatus != nil {
  35328. fields = append(fields, usagestatistichour.FieldStatus)
  35329. }
  35330. if m.addaddtime != nil {
  35331. fields = append(fields, usagestatistichour.FieldAddtime)
  35332. }
  35333. if m.add_type != nil {
  35334. fields = append(fields, usagestatistichour.FieldType)
  35335. }
  35336. if m.addorganization_id != nil {
  35337. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35338. }
  35339. if m.addai_response != nil {
  35340. fields = append(fields, usagestatistichour.FieldAiResponse)
  35341. }
  35342. if m.addsop_run != nil {
  35343. fields = append(fields, usagestatistichour.FieldSopRun)
  35344. }
  35345. if m.addtotal_friend != nil {
  35346. fields = append(fields, usagestatistichour.FieldTotalFriend)
  35347. }
  35348. if m.addtotal_group != nil {
  35349. fields = append(fields, usagestatistichour.FieldTotalGroup)
  35350. }
  35351. if m.addaccount_balance != nil {
  35352. fields = append(fields, usagestatistichour.FieldAccountBalance)
  35353. }
  35354. if m.addconsume_token != nil {
  35355. fields = append(fields, usagestatistichour.FieldConsumeToken)
  35356. }
  35357. if m.addactive_user != nil {
  35358. fields = append(fields, usagestatistichour.FieldActiveUser)
  35359. }
  35360. if m.addnew_user != nil {
  35361. fields = append(fields, usagestatistichour.FieldNewUser)
  35362. }
  35363. return fields
  35364. }
  35365. // AddedField returns the numeric value that was incremented/decremented on a field
  35366. // with the given name. The second boolean return value indicates that this field
  35367. // was not set, or was not defined in the schema.
  35368. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  35369. switch name {
  35370. case usagestatistichour.FieldStatus:
  35371. return m.AddedStatus()
  35372. case usagestatistichour.FieldAddtime:
  35373. return m.AddedAddtime()
  35374. case usagestatistichour.FieldType:
  35375. return m.AddedType()
  35376. case usagestatistichour.FieldOrganizationID:
  35377. return m.AddedOrganizationID()
  35378. case usagestatistichour.FieldAiResponse:
  35379. return m.AddedAiResponse()
  35380. case usagestatistichour.FieldSopRun:
  35381. return m.AddedSopRun()
  35382. case usagestatistichour.FieldTotalFriend:
  35383. return m.AddedTotalFriend()
  35384. case usagestatistichour.FieldTotalGroup:
  35385. return m.AddedTotalGroup()
  35386. case usagestatistichour.FieldAccountBalance:
  35387. return m.AddedAccountBalance()
  35388. case usagestatistichour.FieldConsumeToken:
  35389. return m.AddedConsumeToken()
  35390. case usagestatistichour.FieldActiveUser:
  35391. return m.AddedActiveUser()
  35392. case usagestatistichour.FieldNewUser:
  35393. return m.AddedNewUser()
  35394. }
  35395. return nil, false
  35396. }
  35397. // AddField adds the value to the field with the given name. It returns an error if
  35398. // the field is not defined in the schema, or if the type mismatched the field
  35399. // type.
  35400. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  35401. switch name {
  35402. case usagestatistichour.FieldStatus:
  35403. v, ok := value.(int8)
  35404. if !ok {
  35405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35406. }
  35407. m.AddStatus(v)
  35408. return nil
  35409. case usagestatistichour.FieldAddtime:
  35410. v, ok := value.(int64)
  35411. if !ok {
  35412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35413. }
  35414. m.AddAddtime(v)
  35415. return nil
  35416. case usagestatistichour.FieldType:
  35417. v, ok := value.(int)
  35418. if !ok {
  35419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35420. }
  35421. m.AddType(v)
  35422. return nil
  35423. case usagestatistichour.FieldOrganizationID:
  35424. v, ok := value.(int64)
  35425. if !ok {
  35426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35427. }
  35428. m.AddOrganizationID(v)
  35429. return nil
  35430. case usagestatistichour.FieldAiResponse:
  35431. v, ok := value.(int64)
  35432. if !ok {
  35433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35434. }
  35435. m.AddAiResponse(v)
  35436. return nil
  35437. case usagestatistichour.FieldSopRun:
  35438. v, ok := value.(int64)
  35439. if !ok {
  35440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35441. }
  35442. m.AddSopRun(v)
  35443. return nil
  35444. case usagestatistichour.FieldTotalFriend:
  35445. v, ok := value.(int64)
  35446. if !ok {
  35447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35448. }
  35449. m.AddTotalFriend(v)
  35450. return nil
  35451. case usagestatistichour.FieldTotalGroup:
  35452. v, ok := value.(int64)
  35453. if !ok {
  35454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35455. }
  35456. m.AddTotalGroup(v)
  35457. return nil
  35458. case usagestatistichour.FieldAccountBalance:
  35459. v, ok := value.(int64)
  35460. if !ok {
  35461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35462. }
  35463. m.AddAccountBalance(v)
  35464. return nil
  35465. case usagestatistichour.FieldConsumeToken:
  35466. v, ok := value.(int64)
  35467. if !ok {
  35468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35469. }
  35470. m.AddConsumeToken(v)
  35471. return nil
  35472. case usagestatistichour.FieldActiveUser:
  35473. v, ok := value.(int64)
  35474. if !ok {
  35475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35476. }
  35477. m.AddActiveUser(v)
  35478. return nil
  35479. case usagestatistichour.FieldNewUser:
  35480. v, ok := value.(int64)
  35481. if !ok {
  35482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35483. }
  35484. m.AddNewUser(v)
  35485. return nil
  35486. }
  35487. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  35488. }
  35489. // ClearedFields returns all nullable fields that were cleared during this
  35490. // mutation.
  35491. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  35492. var fields []string
  35493. if m.FieldCleared(usagestatistichour.FieldStatus) {
  35494. fields = append(fields, usagestatistichour.FieldStatus)
  35495. }
  35496. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  35497. fields = append(fields, usagestatistichour.FieldDeletedAt)
  35498. }
  35499. if m.FieldCleared(usagestatistichour.FieldBotID) {
  35500. fields = append(fields, usagestatistichour.FieldBotID)
  35501. }
  35502. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  35503. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35504. }
  35505. return fields
  35506. }
  35507. // FieldCleared returns a boolean indicating if a field with the given name was
  35508. // cleared in this mutation.
  35509. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  35510. _, ok := m.clearedFields[name]
  35511. return ok
  35512. }
  35513. // ClearField clears the value of the field with the given name. It returns an
  35514. // error if the field is not defined in the schema.
  35515. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  35516. switch name {
  35517. case usagestatistichour.FieldStatus:
  35518. m.ClearStatus()
  35519. return nil
  35520. case usagestatistichour.FieldDeletedAt:
  35521. m.ClearDeletedAt()
  35522. return nil
  35523. case usagestatistichour.FieldBotID:
  35524. m.ClearBotID()
  35525. return nil
  35526. case usagestatistichour.FieldOrganizationID:
  35527. m.ClearOrganizationID()
  35528. return nil
  35529. }
  35530. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  35531. }
  35532. // ResetField resets all changes in the mutation for the field with the given name.
  35533. // It returns an error if the field is not defined in the schema.
  35534. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  35535. switch name {
  35536. case usagestatistichour.FieldCreatedAt:
  35537. m.ResetCreatedAt()
  35538. return nil
  35539. case usagestatistichour.FieldUpdatedAt:
  35540. m.ResetUpdatedAt()
  35541. return nil
  35542. case usagestatistichour.FieldStatus:
  35543. m.ResetStatus()
  35544. return nil
  35545. case usagestatistichour.FieldDeletedAt:
  35546. m.ResetDeletedAt()
  35547. return nil
  35548. case usagestatistichour.FieldAddtime:
  35549. m.ResetAddtime()
  35550. return nil
  35551. case usagestatistichour.FieldType:
  35552. m.ResetType()
  35553. return nil
  35554. case usagestatistichour.FieldBotID:
  35555. m.ResetBotID()
  35556. return nil
  35557. case usagestatistichour.FieldOrganizationID:
  35558. m.ResetOrganizationID()
  35559. return nil
  35560. case usagestatistichour.FieldAiResponse:
  35561. m.ResetAiResponse()
  35562. return nil
  35563. case usagestatistichour.FieldSopRun:
  35564. m.ResetSopRun()
  35565. return nil
  35566. case usagestatistichour.FieldTotalFriend:
  35567. m.ResetTotalFriend()
  35568. return nil
  35569. case usagestatistichour.FieldTotalGroup:
  35570. m.ResetTotalGroup()
  35571. return nil
  35572. case usagestatistichour.FieldAccountBalance:
  35573. m.ResetAccountBalance()
  35574. return nil
  35575. case usagestatistichour.FieldConsumeToken:
  35576. m.ResetConsumeToken()
  35577. return nil
  35578. case usagestatistichour.FieldActiveUser:
  35579. m.ResetActiveUser()
  35580. return nil
  35581. case usagestatistichour.FieldNewUser:
  35582. m.ResetNewUser()
  35583. return nil
  35584. case usagestatistichour.FieldLabelDist:
  35585. m.ResetLabelDist()
  35586. return nil
  35587. }
  35588. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35589. }
  35590. // AddedEdges returns all edge names that were set/added in this mutation.
  35591. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  35592. edges := make([]string, 0, 0)
  35593. return edges
  35594. }
  35595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35596. // name in this mutation.
  35597. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  35598. return nil
  35599. }
  35600. // RemovedEdges returns all edge names that were removed in this mutation.
  35601. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  35602. edges := make([]string, 0, 0)
  35603. return edges
  35604. }
  35605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35606. // the given name in this mutation.
  35607. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  35608. return nil
  35609. }
  35610. // ClearedEdges returns all edge names that were cleared in this mutation.
  35611. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  35612. edges := make([]string, 0, 0)
  35613. return edges
  35614. }
  35615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35616. // was cleared in this mutation.
  35617. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  35618. return false
  35619. }
  35620. // ClearEdge clears the value of the edge with the given name. It returns an error
  35621. // if that edge is not defined in the schema.
  35622. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  35623. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  35624. }
  35625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35626. // It returns an error if the edge is not defined in the schema.
  35627. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  35628. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  35629. }
  35630. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  35631. type UsageStatisticMonthMutation struct {
  35632. config
  35633. op Op
  35634. typ string
  35635. id *uint64
  35636. created_at *time.Time
  35637. updated_at *time.Time
  35638. status *uint8
  35639. addstatus *int8
  35640. deleted_at *time.Time
  35641. addtime *uint64
  35642. addaddtime *int64
  35643. _type *int
  35644. add_type *int
  35645. bot_id *string
  35646. organization_id *uint64
  35647. addorganization_id *int64
  35648. ai_response *uint64
  35649. addai_response *int64
  35650. sop_run *uint64
  35651. addsop_run *int64
  35652. total_friend *uint64
  35653. addtotal_friend *int64
  35654. total_group *uint64
  35655. addtotal_group *int64
  35656. account_balance *uint64
  35657. addaccount_balance *int64
  35658. consume_token *uint64
  35659. addconsume_token *int64
  35660. active_user *uint64
  35661. addactive_user *int64
  35662. new_user *int64
  35663. addnew_user *int64
  35664. label_dist *[]custom_types.LabelDist
  35665. appendlabel_dist []custom_types.LabelDist
  35666. clearedFields map[string]struct{}
  35667. done bool
  35668. oldValue func(context.Context) (*UsageStatisticMonth, error)
  35669. predicates []predicate.UsageStatisticMonth
  35670. }
  35671. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  35672. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  35673. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  35674. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  35675. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  35676. m := &UsageStatisticMonthMutation{
  35677. config: c,
  35678. op: op,
  35679. typ: TypeUsageStatisticMonth,
  35680. clearedFields: make(map[string]struct{}),
  35681. }
  35682. for _, opt := range opts {
  35683. opt(m)
  35684. }
  35685. return m
  35686. }
  35687. // withUsageStatisticMonthID sets the ID field of the mutation.
  35688. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  35689. return func(m *UsageStatisticMonthMutation) {
  35690. var (
  35691. err error
  35692. once sync.Once
  35693. value *UsageStatisticMonth
  35694. )
  35695. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  35696. once.Do(func() {
  35697. if m.done {
  35698. err = errors.New("querying old values post mutation is not allowed")
  35699. } else {
  35700. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  35701. }
  35702. })
  35703. return value, err
  35704. }
  35705. m.id = &id
  35706. }
  35707. }
  35708. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  35709. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  35710. return func(m *UsageStatisticMonthMutation) {
  35711. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  35712. return node, nil
  35713. }
  35714. m.id = &node.ID
  35715. }
  35716. }
  35717. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35718. // executed in a transaction (ent.Tx), a transactional client is returned.
  35719. func (m UsageStatisticMonthMutation) Client() *Client {
  35720. client := &Client{config: m.config}
  35721. client.init()
  35722. return client
  35723. }
  35724. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35725. // it returns an error otherwise.
  35726. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  35727. if _, ok := m.driver.(*txDriver); !ok {
  35728. return nil, errors.New("ent: mutation is not running in a transaction")
  35729. }
  35730. tx := &Tx{config: m.config}
  35731. tx.init()
  35732. return tx, nil
  35733. }
  35734. // SetID sets the value of the id field. Note that this
  35735. // operation is only accepted on creation of UsageStatisticMonth entities.
  35736. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  35737. m.id = &id
  35738. }
  35739. // ID returns the ID value in the mutation. Note that the ID is only available
  35740. // if it was provided to the builder or after it was returned from the database.
  35741. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  35742. if m.id == nil {
  35743. return
  35744. }
  35745. return *m.id, true
  35746. }
  35747. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35748. // That means, if the mutation is applied within a transaction with an isolation level such
  35749. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35750. // or updated by the mutation.
  35751. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  35752. switch {
  35753. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35754. id, exists := m.ID()
  35755. if exists {
  35756. return []uint64{id}, nil
  35757. }
  35758. fallthrough
  35759. case m.op.Is(OpUpdate | OpDelete):
  35760. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  35761. default:
  35762. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35763. }
  35764. }
  35765. // SetCreatedAt sets the "created_at" field.
  35766. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  35767. m.created_at = &t
  35768. }
  35769. // CreatedAt returns the value of the "created_at" field in the mutation.
  35770. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  35771. v := m.created_at
  35772. if v == nil {
  35773. return
  35774. }
  35775. return *v, true
  35776. }
  35777. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  35778. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35780. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35781. if !m.op.Is(OpUpdateOne) {
  35782. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35783. }
  35784. if m.id == nil || m.oldValue == nil {
  35785. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35786. }
  35787. oldValue, err := m.oldValue(ctx)
  35788. if err != nil {
  35789. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35790. }
  35791. return oldValue.CreatedAt, nil
  35792. }
  35793. // ResetCreatedAt resets all changes to the "created_at" field.
  35794. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  35795. m.created_at = nil
  35796. }
  35797. // SetUpdatedAt sets the "updated_at" field.
  35798. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  35799. m.updated_at = &t
  35800. }
  35801. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35802. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  35803. v := m.updated_at
  35804. if v == nil {
  35805. return
  35806. }
  35807. return *v, true
  35808. }
  35809. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  35810. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35812. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35813. if !m.op.Is(OpUpdateOne) {
  35814. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35815. }
  35816. if m.id == nil || m.oldValue == nil {
  35817. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35818. }
  35819. oldValue, err := m.oldValue(ctx)
  35820. if err != nil {
  35821. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35822. }
  35823. return oldValue.UpdatedAt, nil
  35824. }
  35825. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35826. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  35827. m.updated_at = nil
  35828. }
  35829. // SetStatus sets the "status" field.
  35830. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  35831. m.status = &u
  35832. m.addstatus = nil
  35833. }
  35834. // Status returns the value of the "status" field in the mutation.
  35835. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  35836. v := m.status
  35837. if v == nil {
  35838. return
  35839. }
  35840. return *v, true
  35841. }
  35842. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  35843. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35845. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35846. if !m.op.Is(OpUpdateOne) {
  35847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35848. }
  35849. if m.id == nil || m.oldValue == nil {
  35850. return v, errors.New("OldStatus requires an ID field in the mutation")
  35851. }
  35852. oldValue, err := m.oldValue(ctx)
  35853. if err != nil {
  35854. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35855. }
  35856. return oldValue.Status, nil
  35857. }
  35858. // AddStatus adds u to the "status" field.
  35859. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  35860. if m.addstatus != nil {
  35861. *m.addstatus += u
  35862. } else {
  35863. m.addstatus = &u
  35864. }
  35865. }
  35866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35867. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  35868. v := m.addstatus
  35869. if v == nil {
  35870. return
  35871. }
  35872. return *v, true
  35873. }
  35874. // ClearStatus clears the value of the "status" field.
  35875. func (m *UsageStatisticMonthMutation) ClearStatus() {
  35876. m.status = nil
  35877. m.addstatus = nil
  35878. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  35879. }
  35880. // StatusCleared returns if the "status" field was cleared in this mutation.
  35881. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  35882. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  35883. return ok
  35884. }
  35885. // ResetStatus resets all changes to the "status" field.
  35886. func (m *UsageStatisticMonthMutation) ResetStatus() {
  35887. m.status = nil
  35888. m.addstatus = nil
  35889. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  35890. }
  35891. // SetDeletedAt sets the "deleted_at" field.
  35892. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  35893. m.deleted_at = &t
  35894. }
  35895. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35896. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  35897. v := m.deleted_at
  35898. if v == nil {
  35899. return
  35900. }
  35901. return *v, true
  35902. }
  35903. // OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35907. if !m.op.Is(OpUpdateOne) {
  35908. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35909. }
  35910. if m.id == nil || m.oldValue == nil {
  35911. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  35916. }
  35917. return oldValue.DeletedAt, nil
  35918. }
  35919. // ClearDeletedAt clears the value of the "deleted_at" field.
  35920. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  35921. m.deleted_at = nil
  35922. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  35923. }
  35924. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35925. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  35926. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  35927. return ok
  35928. }
  35929. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35930. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  35931. m.deleted_at = nil
  35932. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  35933. }
  35934. // SetAddtime sets the "addtime" field.
  35935. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  35936. m.addtime = &u
  35937. m.addaddtime = nil
  35938. }
  35939. // Addtime returns the value of the "addtime" field in the mutation.
  35940. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  35941. v := m.addtime
  35942. if v == nil {
  35943. return
  35944. }
  35945. return *v, true
  35946. }
  35947. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  35948. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35950. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35951. if !m.op.Is(OpUpdateOne) {
  35952. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35953. }
  35954. if m.id == nil || m.oldValue == nil {
  35955. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35956. }
  35957. oldValue, err := m.oldValue(ctx)
  35958. if err != nil {
  35959. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35960. }
  35961. return oldValue.Addtime, nil
  35962. }
  35963. // AddAddtime adds u to the "addtime" field.
  35964. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  35965. if m.addaddtime != nil {
  35966. *m.addaddtime += u
  35967. } else {
  35968. m.addaddtime = &u
  35969. }
  35970. }
  35971. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35972. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  35973. v := m.addaddtime
  35974. if v == nil {
  35975. return
  35976. }
  35977. return *v, true
  35978. }
  35979. // ResetAddtime resets all changes to the "addtime" field.
  35980. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  35981. m.addtime = nil
  35982. m.addaddtime = nil
  35983. }
  35984. // SetType sets the "type" field.
  35985. func (m *UsageStatisticMonthMutation) SetType(i int) {
  35986. m._type = &i
  35987. m.add_type = nil
  35988. }
  35989. // GetType returns the value of the "type" field in the mutation.
  35990. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  35991. v := m._type
  35992. if v == nil {
  35993. return
  35994. }
  35995. return *v, true
  35996. }
  35997. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  35998. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36000. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  36001. if !m.op.Is(OpUpdateOne) {
  36002. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36003. }
  36004. if m.id == nil || m.oldValue == nil {
  36005. return v, errors.New("OldType requires an ID field in the mutation")
  36006. }
  36007. oldValue, err := m.oldValue(ctx)
  36008. if err != nil {
  36009. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36010. }
  36011. return oldValue.Type, nil
  36012. }
  36013. // AddType adds i to the "type" field.
  36014. func (m *UsageStatisticMonthMutation) AddType(i int) {
  36015. if m.add_type != nil {
  36016. *m.add_type += i
  36017. } else {
  36018. m.add_type = &i
  36019. }
  36020. }
  36021. // AddedType returns the value that was added to the "type" field in this mutation.
  36022. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  36023. v := m.add_type
  36024. if v == nil {
  36025. return
  36026. }
  36027. return *v, true
  36028. }
  36029. // ResetType resets all changes to the "type" field.
  36030. func (m *UsageStatisticMonthMutation) ResetType() {
  36031. m._type = nil
  36032. m.add_type = nil
  36033. }
  36034. // SetBotID sets the "bot_id" field.
  36035. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  36036. m.bot_id = &s
  36037. }
  36038. // BotID returns the value of the "bot_id" field in the mutation.
  36039. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  36040. v := m.bot_id
  36041. if v == nil {
  36042. return
  36043. }
  36044. return *v, true
  36045. }
  36046. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  36047. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36049. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  36050. if !m.op.Is(OpUpdateOne) {
  36051. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36052. }
  36053. if m.id == nil || m.oldValue == nil {
  36054. return v, errors.New("OldBotID requires an ID field in the mutation")
  36055. }
  36056. oldValue, err := m.oldValue(ctx)
  36057. if err != nil {
  36058. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36059. }
  36060. return oldValue.BotID, nil
  36061. }
  36062. // ClearBotID clears the value of the "bot_id" field.
  36063. func (m *UsageStatisticMonthMutation) ClearBotID() {
  36064. m.bot_id = nil
  36065. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  36066. }
  36067. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36068. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  36069. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  36070. return ok
  36071. }
  36072. // ResetBotID resets all changes to the "bot_id" field.
  36073. func (m *UsageStatisticMonthMutation) ResetBotID() {
  36074. m.bot_id = nil
  36075. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  36076. }
  36077. // SetOrganizationID sets the "organization_id" field.
  36078. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  36079. m.organization_id = &u
  36080. m.addorganization_id = nil
  36081. }
  36082. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36083. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  36084. v := m.organization_id
  36085. if v == nil {
  36086. return
  36087. }
  36088. return *v, true
  36089. }
  36090. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  36091. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36093. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36094. if !m.op.Is(OpUpdateOne) {
  36095. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36096. }
  36097. if m.id == nil || m.oldValue == nil {
  36098. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36099. }
  36100. oldValue, err := m.oldValue(ctx)
  36101. if err != nil {
  36102. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36103. }
  36104. return oldValue.OrganizationID, nil
  36105. }
  36106. // AddOrganizationID adds u to the "organization_id" field.
  36107. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  36108. if m.addorganization_id != nil {
  36109. *m.addorganization_id += u
  36110. } else {
  36111. m.addorganization_id = &u
  36112. }
  36113. }
  36114. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36115. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  36116. v := m.addorganization_id
  36117. if v == nil {
  36118. return
  36119. }
  36120. return *v, true
  36121. }
  36122. // ClearOrganizationID clears the value of the "organization_id" field.
  36123. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  36124. m.organization_id = nil
  36125. m.addorganization_id = nil
  36126. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  36127. }
  36128. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36129. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  36130. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  36131. return ok
  36132. }
  36133. // ResetOrganizationID resets all changes to the "organization_id" field.
  36134. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  36135. m.organization_id = nil
  36136. m.addorganization_id = nil
  36137. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  36138. }
  36139. // SetAiResponse sets the "ai_response" field.
  36140. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  36141. m.ai_response = &u
  36142. m.addai_response = nil
  36143. }
  36144. // AiResponse returns the value of the "ai_response" field in the mutation.
  36145. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  36146. v := m.ai_response
  36147. if v == nil {
  36148. return
  36149. }
  36150. return *v, true
  36151. }
  36152. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  36153. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36155. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36156. if !m.op.Is(OpUpdateOne) {
  36157. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36158. }
  36159. if m.id == nil || m.oldValue == nil {
  36160. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36161. }
  36162. oldValue, err := m.oldValue(ctx)
  36163. if err != nil {
  36164. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36165. }
  36166. return oldValue.AiResponse, nil
  36167. }
  36168. // AddAiResponse adds u to the "ai_response" field.
  36169. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  36170. if m.addai_response != nil {
  36171. *m.addai_response += u
  36172. } else {
  36173. m.addai_response = &u
  36174. }
  36175. }
  36176. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36177. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  36178. v := m.addai_response
  36179. if v == nil {
  36180. return
  36181. }
  36182. return *v, true
  36183. }
  36184. // ResetAiResponse resets all changes to the "ai_response" field.
  36185. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  36186. m.ai_response = nil
  36187. m.addai_response = nil
  36188. }
  36189. // SetSopRun sets the "sop_run" field.
  36190. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  36191. m.sop_run = &u
  36192. m.addsop_run = nil
  36193. }
  36194. // SopRun returns the value of the "sop_run" field in the mutation.
  36195. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  36196. v := m.sop_run
  36197. if v == nil {
  36198. return
  36199. }
  36200. return *v, true
  36201. }
  36202. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  36203. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36205. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36206. if !m.op.Is(OpUpdateOne) {
  36207. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36208. }
  36209. if m.id == nil || m.oldValue == nil {
  36210. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36211. }
  36212. oldValue, err := m.oldValue(ctx)
  36213. if err != nil {
  36214. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36215. }
  36216. return oldValue.SopRun, nil
  36217. }
  36218. // AddSopRun adds u to the "sop_run" field.
  36219. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  36220. if m.addsop_run != nil {
  36221. *m.addsop_run += u
  36222. } else {
  36223. m.addsop_run = &u
  36224. }
  36225. }
  36226. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36227. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  36228. v := m.addsop_run
  36229. if v == nil {
  36230. return
  36231. }
  36232. return *v, true
  36233. }
  36234. // ResetSopRun resets all changes to the "sop_run" field.
  36235. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  36236. m.sop_run = nil
  36237. m.addsop_run = nil
  36238. }
  36239. // SetTotalFriend sets the "total_friend" field.
  36240. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  36241. m.total_friend = &u
  36242. m.addtotal_friend = nil
  36243. }
  36244. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36245. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  36246. v := m.total_friend
  36247. if v == nil {
  36248. return
  36249. }
  36250. return *v, true
  36251. }
  36252. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  36253. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36255. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36256. if !m.op.Is(OpUpdateOne) {
  36257. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36258. }
  36259. if m.id == nil || m.oldValue == nil {
  36260. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36261. }
  36262. oldValue, err := m.oldValue(ctx)
  36263. if err != nil {
  36264. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36265. }
  36266. return oldValue.TotalFriend, nil
  36267. }
  36268. // AddTotalFriend adds u to the "total_friend" field.
  36269. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  36270. if m.addtotal_friend != nil {
  36271. *m.addtotal_friend += u
  36272. } else {
  36273. m.addtotal_friend = &u
  36274. }
  36275. }
  36276. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36277. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  36278. v := m.addtotal_friend
  36279. if v == nil {
  36280. return
  36281. }
  36282. return *v, true
  36283. }
  36284. // ResetTotalFriend resets all changes to the "total_friend" field.
  36285. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  36286. m.total_friend = nil
  36287. m.addtotal_friend = nil
  36288. }
  36289. // SetTotalGroup sets the "total_group" field.
  36290. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  36291. m.total_group = &u
  36292. m.addtotal_group = nil
  36293. }
  36294. // TotalGroup returns the value of the "total_group" field in the mutation.
  36295. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  36296. v := m.total_group
  36297. if v == nil {
  36298. return
  36299. }
  36300. return *v, true
  36301. }
  36302. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  36303. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36305. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36306. if !m.op.Is(OpUpdateOne) {
  36307. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36308. }
  36309. if m.id == nil || m.oldValue == nil {
  36310. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36311. }
  36312. oldValue, err := m.oldValue(ctx)
  36313. if err != nil {
  36314. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36315. }
  36316. return oldValue.TotalGroup, nil
  36317. }
  36318. // AddTotalGroup adds u to the "total_group" field.
  36319. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  36320. if m.addtotal_group != nil {
  36321. *m.addtotal_group += u
  36322. } else {
  36323. m.addtotal_group = &u
  36324. }
  36325. }
  36326. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36327. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  36328. v := m.addtotal_group
  36329. if v == nil {
  36330. return
  36331. }
  36332. return *v, true
  36333. }
  36334. // ResetTotalGroup resets all changes to the "total_group" field.
  36335. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  36336. m.total_group = nil
  36337. m.addtotal_group = nil
  36338. }
  36339. // SetAccountBalance sets the "account_balance" field.
  36340. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  36341. m.account_balance = &u
  36342. m.addaccount_balance = nil
  36343. }
  36344. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36345. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  36346. v := m.account_balance
  36347. if v == nil {
  36348. return
  36349. }
  36350. return *v, true
  36351. }
  36352. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  36353. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36355. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36356. if !m.op.Is(OpUpdateOne) {
  36357. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36358. }
  36359. if m.id == nil || m.oldValue == nil {
  36360. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36361. }
  36362. oldValue, err := m.oldValue(ctx)
  36363. if err != nil {
  36364. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36365. }
  36366. return oldValue.AccountBalance, nil
  36367. }
  36368. // AddAccountBalance adds u to the "account_balance" field.
  36369. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  36370. if m.addaccount_balance != nil {
  36371. *m.addaccount_balance += u
  36372. } else {
  36373. m.addaccount_balance = &u
  36374. }
  36375. }
  36376. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36377. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  36378. v := m.addaccount_balance
  36379. if v == nil {
  36380. return
  36381. }
  36382. return *v, true
  36383. }
  36384. // ResetAccountBalance resets all changes to the "account_balance" field.
  36385. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  36386. m.account_balance = nil
  36387. m.addaccount_balance = nil
  36388. }
  36389. // SetConsumeToken sets the "consume_token" field.
  36390. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  36391. m.consume_token = &u
  36392. m.addconsume_token = nil
  36393. }
  36394. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36395. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  36396. v := m.consume_token
  36397. if v == nil {
  36398. return
  36399. }
  36400. return *v, true
  36401. }
  36402. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  36403. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36405. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36406. if !m.op.Is(OpUpdateOne) {
  36407. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36408. }
  36409. if m.id == nil || m.oldValue == nil {
  36410. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36411. }
  36412. oldValue, err := m.oldValue(ctx)
  36413. if err != nil {
  36414. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36415. }
  36416. return oldValue.ConsumeToken, nil
  36417. }
  36418. // AddConsumeToken adds u to the "consume_token" field.
  36419. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  36420. if m.addconsume_token != nil {
  36421. *m.addconsume_token += u
  36422. } else {
  36423. m.addconsume_token = &u
  36424. }
  36425. }
  36426. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36427. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  36428. v := m.addconsume_token
  36429. if v == nil {
  36430. return
  36431. }
  36432. return *v, true
  36433. }
  36434. // ResetConsumeToken resets all changes to the "consume_token" field.
  36435. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  36436. m.consume_token = nil
  36437. m.addconsume_token = nil
  36438. }
  36439. // SetActiveUser sets the "active_user" field.
  36440. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  36441. m.active_user = &u
  36442. m.addactive_user = nil
  36443. }
  36444. // ActiveUser returns the value of the "active_user" field in the mutation.
  36445. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  36446. v := m.active_user
  36447. if v == nil {
  36448. return
  36449. }
  36450. return *v, true
  36451. }
  36452. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  36453. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36455. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36456. if !m.op.Is(OpUpdateOne) {
  36457. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36458. }
  36459. if m.id == nil || m.oldValue == nil {
  36460. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36461. }
  36462. oldValue, err := m.oldValue(ctx)
  36463. if err != nil {
  36464. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36465. }
  36466. return oldValue.ActiveUser, nil
  36467. }
  36468. // AddActiveUser adds u to the "active_user" field.
  36469. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  36470. if m.addactive_user != nil {
  36471. *m.addactive_user += u
  36472. } else {
  36473. m.addactive_user = &u
  36474. }
  36475. }
  36476. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36477. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  36478. v := m.addactive_user
  36479. if v == nil {
  36480. return
  36481. }
  36482. return *v, true
  36483. }
  36484. // ResetActiveUser resets all changes to the "active_user" field.
  36485. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  36486. m.active_user = nil
  36487. m.addactive_user = nil
  36488. }
  36489. // SetNewUser sets the "new_user" field.
  36490. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  36491. m.new_user = &i
  36492. m.addnew_user = nil
  36493. }
  36494. // NewUser returns the value of the "new_user" field in the mutation.
  36495. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  36496. v := m.new_user
  36497. if v == nil {
  36498. return
  36499. }
  36500. return *v, true
  36501. }
  36502. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  36503. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36505. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36506. if !m.op.Is(OpUpdateOne) {
  36507. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36508. }
  36509. if m.id == nil || m.oldValue == nil {
  36510. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36511. }
  36512. oldValue, err := m.oldValue(ctx)
  36513. if err != nil {
  36514. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36515. }
  36516. return oldValue.NewUser, nil
  36517. }
  36518. // AddNewUser adds i to the "new_user" field.
  36519. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  36520. if m.addnew_user != nil {
  36521. *m.addnew_user += i
  36522. } else {
  36523. m.addnew_user = &i
  36524. }
  36525. }
  36526. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36527. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  36528. v := m.addnew_user
  36529. if v == nil {
  36530. return
  36531. }
  36532. return *v, true
  36533. }
  36534. // ResetNewUser resets all changes to the "new_user" field.
  36535. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  36536. m.new_user = nil
  36537. m.addnew_user = nil
  36538. }
  36539. // SetLabelDist sets the "label_dist" field.
  36540. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36541. m.label_dist = &ctd
  36542. m.appendlabel_dist = nil
  36543. }
  36544. // LabelDist returns the value of the "label_dist" field in the mutation.
  36545. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36546. v := m.label_dist
  36547. if v == nil {
  36548. return
  36549. }
  36550. return *v, true
  36551. }
  36552. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  36553. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36555. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36556. if !m.op.Is(OpUpdateOne) {
  36557. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36558. }
  36559. if m.id == nil || m.oldValue == nil {
  36560. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36561. }
  36562. oldValue, err := m.oldValue(ctx)
  36563. if err != nil {
  36564. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36565. }
  36566. return oldValue.LabelDist, nil
  36567. }
  36568. // AppendLabelDist adds ctd to the "label_dist" field.
  36569. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36570. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36571. }
  36572. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36573. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36574. if len(m.appendlabel_dist) == 0 {
  36575. return nil, false
  36576. }
  36577. return m.appendlabel_dist, true
  36578. }
  36579. // ResetLabelDist resets all changes to the "label_dist" field.
  36580. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  36581. m.label_dist = nil
  36582. m.appendlabel_dist = nil
  36583. }
  36584. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  36585. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  36586. m.predicates = append(m.predicates, ps...)
  36587. }
  36588. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  36589. // users can use type-assertion to append predicates that do not depend on any generated package.
  36590. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  36591. p := make([]predicate.UsageStatisticMonth, len(ps))
  36592. for i := range ps {
  36593. p[i] = ps[i]
  36594. }
  36595. m.Where(p...)
  36596. }
  36597. // Op returns the operation name.
  36598. func (m *UsageStatisticMonthMutation) Op() Op {
  36599. return m.op
  36600. }
  36601. // SetOp allows setting the mutation operation.
  36602. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  36603. m.op = op
  36604. }
  36605. // Type returns the node type of this mutation (UsageStatisticMonth).
  36606. func (m *UsageStatisticMonthMutation) Type() string {
  36607. return m.typ
  36608. }
  36609. // Fields returns all fields that were changed during this mutation. Note that in
  36610. // order to get all numeric fields that were incremented/decremented, call
  36611. // AddedFields().
  36612. func (m *UsageStatisticMonthMutation) Fields() []string {
  36613. fields := make([]string, 0, 17)
  36614. if m.created_at != nil {
  36615. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  36616. }
  36617. if m.updated_at != nil {
  36618. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  36619. }
  36620. if m.status != nil {
  36621. fields = append(fields, usagestatisticmonth.FieldStatus)
  36622. }
  36623. if m.deleted_at != nil {
  36624. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36625. }
  36626. if m.addtime != nil {
  36627. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36628. }
  36629. if m._type != nil {
  36630. fields = append(fields, usagestatisticmonth.FieldType)
  36631. }
  36632. if m.bot_id != nil {
  36633. fields = append(fields, usagestatisticmonth.FieldBotID)
  36634. }
  36635. if m.organization_id != nil {
  36636. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36637. }
  36638. if m.ai_response != nil {
  36639. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36640. }
  36641. if m.sop_run != nil {
  36642. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36643. }
  36644. if m.total_friend != nil {
  36645. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36646. }
  36647. if m.total_group != nil {
  36648. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36649. }
  36650. if m.account_balance != nil {
  36651. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36652. }
  36653. if m.consume_token != nil {
  36654. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36655. }
  36656. if m.active_user != nil {
  36657. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36658. }
  36659. if m.new_user != nil {
  36660. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36661. }
  36662. if m.label_dist != nil {
  36663. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  36664. }
  36665. return fields
  36666. }
  36667. // Field returns the value of a field with the given name. The second boolean
  36668. // return value indicates that this field was not set, or was not defined in the
  36669. // schema.
  36670. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  36671. switch name {
  36672. case usagestatisticmonth.FieldCreatedAt:
  36673. return m.CreatedAt()
  36674. case usagestatisticmonth.FieldUpdatedAt:
  36675. return m.UpdatedAt()
  36676. case usagestatisticmonth.FieldStatus:
  36677. return m.Status()
  36678. case usagestatisticmonth.FieldDeletedAt:
  36679. return m.DeletedAt()
  36680. case usagestatisticmonth.FieldAddtime:
  36681. return m.Addtime()
  36682. case usagestatisticmonth.FieldType:
  36683. return m.GetType()
  36684. case usagestatisticmonth.FieldBotID:
  36685. return m.BotID()
  36686. case usagestatisticmonth.FieldOrganizationID:
  36687. return m.OrganizationID()
  36688. case usagestatisticmonth.FieldAiResponse:
  36689. return m.AiResponse()
  36690. case usagestatisticmonth.FieldSopRun:
  36691. return m.SopRun()
  36692. case usagestatisticmonth.FieldTotalFriend:
  36693. return m.TotalFriend()
  36694. case usagestatisticmonth.FieldTotalGroup:
  36695. return m.TotalGroup()
  36696. case usagestatisticmonth.FieldAccountBalance:
  36697. return m.AccountBalance()
  36698. case usagestatisticmonth.FieldConsumeToken:
  36699. return m.ConsumeToken()
  36700. case usagestatisticmonth.FieldActiveUser:
  36701. return m.ActiveUser()
  36702. case usagestatisticmonth.FieldNewUser:
  36703. return m.NewUser()
  36704. case usagestatisticmonth.FieldLabelDist:
  36705. return m.LabelDist()
  36706. }
  36707. return nil, false
  36708. }
  36709. // OldField returns the old value of the field from the database. An error is
  36710. // returned if the mutation operation is not UpdateOne, or the query to the
  36711. // database failed.
  36712. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36713. switch name {
  36714. case usagestatisticmonth.FieldCreatedAt:
  36715. return m.OldCreatedAt(ctx)
  36716. case usagestatisticmonth.FieldUpdatedAt:
  36717. return m.OldUpdatedAt(ctx)
  36718. case usagestatisticmonth.FieldStatus:
  36719. return m.OldStatus(ctx)
  36720. case usagestatisticmonth.FieldDeletedAt:
  36721. return m.OldDeletedAt(ctx)
  36722. case usagestatisticmonth.FieldAddtime:
  36723. return m.OldAddtime(ctx)
  36724. case usagestatisticmonth.FieldType:
  36725. return m.OldType(ctx)
  36726. case usagestatisticmonth.FieldBotID:
  36727. return m.OldBotID(ctx)
  36728. case usagestatisticmonth.FieldOrganizationID:
  36729. return m.OldOrganizationID(ctx)
  36730. case usagestatisticmonth.FieldAiResponse:
  36731. return m.OldAiResponse(ctx)
  36732. case usagestatisticmonth.FieldSopRun:
  36733. return m.OldSopRun(ctx)
  36734. case usagestatisticmonth.FieldTotalFriend:
  36735. return m.OldTotalFriend(ctx)
  36736. case usagestatisticmonth.FieldTotalGroup:
  36737. return m.OldTotalGroup(ctx)
  36738. case usagestatisticmonth.FieldAccountBalance:
  36739. return m.OldAccountBalance(ctx)
  36740. case usagestatisticmonth.FieldConsumeToken:
  36741. return m.OldConsumeToken(ctx)
  36742. case usagestatisticmonth.FieldActiveUser:
  36743. return m.OldActiveUser(ctx)
  36744. case usagestatisticmonth.FieldNewUser:
  36745. return m.OldNewUser(ctx)
  36746. case usagestatisticmonth.FieldLabelDist:
  36747. return m.OldLabelDist(ctx)
  36748. }
  36749. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36750. }
  36751. // SetField sets the value of a field with the given name. It returns an error if
  36752. // the field is not defined in the schema, or if the type mismatched the field
  36753. // type.
  36754. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  36755. switch name {
  36756. case usagestatisticmonth.FieldCreatedAt:
  36757. v, ok := value.(time.Time)
  36758. if !ok {
  36759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36760. }
  36761. m.SetCreatedAt(v)
  36762. return nil
  36763. case usagestatisticmonth.FieldUpdatedAt:
  36764. v, ok := value.(time.Time)
  36765. if !ok {
  36766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36767. }
  36768. m.SetUpdatedAt(v)
  36769. return nil
  36770. case usagestatisticmonth.FieldStatus:
  36771. v, ok := value.(uint8)
  36772. if !ok {
  36773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36774. }
  36775. m.SetStatus(v)
  36776. return nil
  36777. case usagestatisticmonth.FieldDeletedAt:
  36778. v, ok := value.(time.Time)
  36779. if !ok {
  36780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36781. }
  36782. m.SetDeletedAt(v)
  36783. return nil
  36784. case usagestatisticmonth.FieldAddtime:
  36785. v, ok := value.(uint64)
  36786. if !ok {
  36787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36788. }
  36789. m.SetAddtime(v)
  36790. return nil
  36791. case usagestatisticmonth.FieldType:
  36792. v, ok := value.(int)
  36793. if !ok {
  36794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36795. }
  36796. m.SetType(v)
  36797. return nil
  36798. case usagestatisticmonth.FieldBotID:
  36799. v, ok := value.(string)
  36800. if !ok {
  36801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36802. }
  36803. m.SetBotID(v)
  36804. return nil
  36805. case usagestatisticmonth.FieldOrganizationID:
  36806. v, ok := value.(uint64)
  36807. if !ok {
  36808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36809. }
  36810. m.SetOrganizationID(v)
  36811. return nil
  36812. case usagestatisticmonth.FieldAiResponse:
  36813. v, ok := value.(uint64)
  36814. if !ok {
  36815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36816. }
  36817. m.SetAiResponse(v)
  36818. return nil
  36819. case usagestatisticmonth.FieldSopRun:
  36820. v, ok := value.(uint64)
  36821. if !ok {
  36822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36823. }
  36824. m.SetSopRun(v)
  36825. return nil
  36826. case usagestatisticmonth.FieldTotalFriend:
  36827. v, ok := value.(uint64)
  36828. if !ok {
  36829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36830. }
  36831. m.SetTotalFriend(v)
  36832. return nil
  36833. case usagestatisticmonth.FieldTotalGroup:
  36834. v, ok := value.(uint64)
  36835. if !ok {
  36836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36837. }
  36838. m.SetTotalGroup(v)
  36839. return nil
  36840. case usagestatisticmonth.FieldAccountBalance:
  36841. v, ok := value.(uint64)
  36842. if !ok {
  36843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36844. }
  36845. m.SetAccountBalance(v)
  36846. return nil
  36847. case usagestatisticmonth.FieldConsumeToken:
  36848. v, ok := value.(uint64)
  36849. if !ok {
  36850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36851. }
  36852. m.SetConsumeToken(v)
  36853. return nil
  36854. case usagestatisticmonth.FieldActiveUser:
  36855. v, ok := value.(uint64)
  36856. if !ok {
  36857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36858. }
  36859. m.SetActiveUser(v)
  36860. return nil
  36861. case usagestatisticmonth.FieldNewUser:
  36862. v, ok := value.(int64)
  36863. if !ok {
  36864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36865. }
  36866. m.SetNewUser(v)
  36867. return nil
  36868. case usagestatisticmonth.FieldLabelDist:
  36869. v, ok := value.([]custom_types.LabelDist)
  36870. if !ok {
  36871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36872. }
  36873. m.SetLabelDist(v)
  36874. return nil
  36875. }
  36876. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36877. }
  36878. // AddedFields returns all numeric fields that were incremented/decremented during
  36879. // this mutation.
  36880. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  36881. var fields []string
  36882. if m.addstatus != nil {
  36883. fields = append(fields, usagestatisticmonth.FieldStatus)
  36884. }
  36885. if m.addaddtime != nil {
  36886. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36887. }
  36888. if m.add_type != nil {
  36889. fields = append(fields, usagestatisticmonth.FieldType)
  36890. }
  36891. if m.addorganization_id != nil {
  36892. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36893. }
  36894. if m.addai_response != nil {
  36895. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36896. }
  36897. if m.addsop_run != nil {
  36898. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36899. }
  36900. if m.addtotal_friend != nil {
  36901. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36902. }
  36903. if m.addtotal_group != nil {
  36904. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36905. }
  36906. if m.addaccount_balance != nil {
  36907. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36908. }
  36909. if m.addconsume_token != nil {
  36910. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36911. }
  36912. if m.addactive_user != nil {
  36913. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36914. }
  36915. if m.addnew_user != nil {
  36916. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36917. }
  36918. return fields
  36919. }
  36920. // AddedField returns the numeric value that was incremented/decremented on a field
  36921. // with the given name. The second boolean return value indicates that this field
  36922. // was not set, or was not defined in the schema.
  36923. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  36924. switch name {
  36925. case usagestatisticmonth.FieldStatus:
  36926. return m.AddedStatus()
  36927. case usagestatisticmonth.FieldAddtime:
  36928. return m.AddedAddtime()
  36929. case usagestatisticmonth.FieldType:
  36930. return m.AddedType()
  36931. case usagestatisticmonth.FieldOrganizationID:
  36932. return m.AddedOrganizationID()
  36933. case usagestatisticmonth.FieldAiResponse:
  36934. return m.AddedAiResponse()
  36935. case usagestatisticmonth.FieldSopRun:
  36936. return m.AddedSopRun()
  36937. case usagestatisticmonth.FieldTotalFriend:
  36938. return m.AddedTotalFriend()
  36939. case usagestatisticmonth.FieldTotalGroup:
  36940. return m.AddedTotalGroup()
  36941. case usagestatisticmonth.FieldAccountBalance:
  36942. return m.AddedAccountBalance()
  36943. case usagestatisticmonth.FieldConsumeToken:
  36944. return m.AddedConsumeToken()
  36945. case usagestatisticmonth.FieldActiveUser:
  36946. return m.AddedActiveUser()
  36947. case usagestatisticmonth.FieldNewUser:
  36948. return m.AddedNewUser()
  36949. }
  36950. return nil, false
  36951. }
  36952. // AddField adds the value to the field with the given name. It returns an error if
  36953. // the field is not defined in the schema, or if the type mismatched the field
  36954. // type.
  36955. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  36956. switch name {
  36957. case usagestatisticmonth.FieldStatus:
  36958. v, ok := value.(int8)
  36959. if !ok {
  36960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36961. }
  36962. m.AddStatus(v)
  36963. return nil
  36964. case usagestatisticmonth.FieldAddtime:
  36965. v, ok := value.(int64)
  36966. if !ok {
  36967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36968. }
  36969. m.AddAddtime(v)
  36970. return nil
  36971. case usagestatisticmonth.FieldType:
  36972. v, ok := value.(int)
  36973. if !ok {
  36974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36975. }
  36976. m.AddType(v)
  36977. return nil
  36978. case usagestatisticmonth.FieldOrganizationID:
  36979. v, ok := value.(int64)
  36980. if !ok {
  36981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36982. }
  36983. m.AddOrganizationID(v)
  36984. return nil
  36985. case usagestatisticmonth.FieldAiResponse:
  36986. v, ok := value.(int64)
  36987. if !ok {
  36988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36989. }
  36990. m.AddAiResponse(v)
  36991. return nil
  36992. case usagestatisticmonth.FieldSopRun:
  36993. v, ok := value.(int64)
  36994. if !ok {
  36995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36996. }
  36997. m.AddSopRun(v)
  36998. return nil
  36999. case usagestatisticmonth.FieldTotalFriend:
  37000. v, ok := value.(int64)
  37001. if !ok {
  37002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37003. }
  37004. m.AddTotalFriend(v)
  37005. return nil
  37006. case usagestatisticmonth.FieldTotalGroup:
  37007. v, ok := value.(int64)
  37008. if !ok {
  37009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37010. }
  37011. m.AddTotalGroup(v)
  37012. return nil
  37013. case usagestatisticmonth.FieldAccountBalance:
  37014. v, ok := value.(int64)
  37015. if !ok {
  37016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37017. }
  37018. m.AddAccountBalance(v)
  37019. return nil
  37020. case usagestatisticmonth.FieldConsumeToken:
  37021. v, ok := value.(int64)
  37022. if !ok {
  37023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37024. }
  37025. m.AddConsumeToken(v)
  37026. return nil
  37027. case usagestatisticmonth.FieldActiveUser:
  37028. v, ok := value.(int64)
  37029. if !ok {
  37030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37031. }
  37032. m.AddActiveUser(v)
  37033. return nil
  37034. case usagestatisticmonth.FieldNewUser:
  37035. v, ok := value.(int64)
  37036. if !ok {
  37037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37038. }
  37039. m.AddNewUser(v)
  37040. return nil
  37041. }
  37042. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  37043. }
  37044. // ClearedFields returns all nullable fields that were cleared during this
  37045. // mutation.
  37046. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  37047. var fields []string
  37048. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  37049. fields = append(fields, usagestatisticmonth.FieldStatus)
  37050. }
  37051. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  37052. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  37053. }
  37054. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  37055. fields = append(fields, usagestatisticmonth.FieldBotID)
  37056. }
  37057. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  37058. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  37059. }
  37060. return fields
  37061. }
  37062. // FieldCleared returns a boolean indicating if a field with the given name was
  37063. // cleared in this mutation.
  37064. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  37065. _, ok := m.clearedFields[name]
  37066. return ok
  37067. }
  37068. // ClearField clears the value of the field with the given name. It returns an
  37069. // error if the field is not defined in the schema.
  37070. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  37071. switch name {
  37072. case usagestatisticmonth.FieldStatus:
  37073. m.ClearStatus()
  37074. return nil
  37075. case usagestatisticmonth.FieldDeletedAt:
  37076. m.ClearDeletedAt()
  37077. return nil
  37078. case usagestatisticmonth.FieldBotID:
  37079. m.ClearBotID()
  37080. return nil
  37081. case usagestatisticmonth.FieldOrganizationID:
  37082. m.ClearOrganizationID()
  37083. return nil
  37084. }
  37085. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  37086. }
  37087. // ResetField resets all changes in the mutation for the field with the given name.
  37088. // It returns an error if the field is not defined in the schema.
  37089. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  37090. switch name {
  37091. case usagestatisticmonth.FieldCreatedAt:
  37092. m.ResetCreatedAt()
  37093. return nil
  37094. case usagestatisticmonth.FieldUpdatedAt:
  37095. m.ResetUpdatedAt()
  37096. return nil
  37097. case usagestatisticmonth.FieldStatus:
  37098. m.ResetStatus()
  37099. return nil
  37100. case usagestatisticmonth.FieldDeletedAt:
  37101. m.ResetDeletedAt()
  37102. return nil
  37103. case usagestatisticmonth.FieldAddtime:
  37104. m.ResetAddtime()
  37105. return nil
  37106. case usagestatisticmonth.FieldType:
  37107. m.ResetType()
  37108. return nil
  37109. case usagestatisticmonth.FieldBotID:
  37110. m.ResetBotID()
  37111. return nil
  37112. case usagestatisticmonth.FieldOrganizationID:
  37113. m.ResetOrganizationID()
  37114. return nil
  37115. case usagestatisticmonth.FieldAiResponse:
  37116. m.ResetAiResponse()
  37117. return nil
  37118. case usagestatisticmonth.FieldSopRun:
  37119. m.ResetSopRun()
  37120. return nil
  37121. case usagestatisticmonth.FieldTotalFriend:
  37122. m.ResetTotalFriend()
  37123. return nil
  37124. case usagestatisticmonth.FieldTotalGroup:
  37125. m.ResetTotalGroup()
  37126. return nil
  37127. case usagestatisticmonth.FieldAccountBalance:
  37128. m.ResetAccountBalance()
  37129. return nil
  37130. case usagestatisticmonth.FieldConsumeToken:
  37131. m.ResetConsumeToken()
  37132. return nil
  37133. case usagestatisticmonth.FieldActiveUser:
  37134. m.ResetActiveUser()
  37135. return nil
  37136. case usagestatisticmonth.FieldNewUser:
  37137. m.ResetNewUser()
  37138. return nil
  37139. case usagestatisticmonth.FieldLabelDist:
  37140. m.ResetLabelDist()
  37141. return nil
  37142. }
  37143. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  37144. }
  37145. // AddedEdges returns all edge names that were set/added in this mutation.
  37146. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  37147. edges := make([]string, 0, 0)
  37148. return edges
  37149. }
  37150. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37151. // name in this mutation.
  37152. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  37153. return nil
  37154. }
  37155. // RemovedEdges returns all edge names that were removed in this mutation.
  37156. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  37157. edges := make([]string, 0, 0)
  37158. return edges
  37159. }
  37160. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37161. // the given name in this mutation.
  37162. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  37163. return nil
  37164. }
  37165. // ClearedEdges returns all edge names that were cleared in this mutation.
  37166. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  37167. edges := make([]string, 0, 0)
  37168. return edges
  37169. }
  37170. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37171. // was cleared in this mutation.
  37172. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  37173. return false
  37174. }
  37175. // ClearEdge clears the value of the edge with the given name. It returns an error
  37176. // if that edge is not defined in the schema.
  37177. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  37178. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  37179. }
  37180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37181. // It returns an error if the edge is not defined in the schema.
  37182. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  37183. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  37184. }
  37185. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  37186. type UsageTotalMutation struct {
  37187. config
  37188. op Op
  37189. typ string
  37190. id *uint64
  37191. created_at *time.Time
  37192. updated_at *time.Time
  37193. status *uint8
  37194. addstatus *int8
  37195. _type *int
  37196. add_type *int
  37197. bot_id *string
  37198. total_tokens *uint64
  37199. addtotal_tokens *int64
  37200. start_index *uint64
  37201. addstart_index *int64
  37202. end_index *uint64
  37203. addend_index *int64
  37204. organization_id *uint64
  37205. addorganization_id *int64
  37206. clearedFields map[string]struct{}
  37207. done bool
  37208. oldValue func(context.Context) (*UsageTotal, error)
  37209. predicates []predicate.UsageTotal
  37210. }
  37211. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  37212. // usagetotalOption allows management of the mutation configuration using functional options.
  37213. type usagetotalOption func(*UsageTotalMutation)
  37214. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  37215. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  37216. m := &UsageTotalMutation{
  37217. config: c,
  37218. op: op,
  37219. typ: TypeUsageTotal,
  37220. clearedFields: make(map[string]struct{}),
  37221. }
  37222. for _, opt := range opts {
  37223. opt(m)
  37224. }
  37225. return m
  37226. }
  37227. // withUsageTotalID sets the ID field of the mutation.
  37228. func withUsageTotalID(id uint64) usagetotalOption {
  37229. return func(m *UsageTotalMutation) {
  37230. var (
  37231. err error
  37232. once sync.Once
  37233. value *UsageTotal
  37234. )
  37235. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  37236. once.Do(func() {
  37237. if m.done {
  37238. err = errors.New("querying old values post mutation is not allowed")
  37239. } else {
  37240. value, err = m.Client().UsageTotal.Get(ctx, id)
  37241. }
  37242. })
  37243. return value, err
  37244. }
  37245. m.id = &id
  37246. }
  37247. }
  37248. // withUsageTotal sets the old UsageTotal of the mutation.
  37249. func withUsageTotal(node *UsageTotal) usagetotalOption {
  37250. return func(m *UsageTotalMutation) {
  37251. m.oldValue = func(context.Context) (*UsageTotal, error) {
  37252. return node, nil
  37253. }
  37254. m.id = &node.ID
  37255. }
  37256. }
  37257. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37258. // executed in a transaction (ent.Tx), a transactional client is returned.
  37259. func (m UsageTotalMutation) Client() *Client {
  37260. client := &Client{config: m.config}
  37261. client.init()
  37262. return client
  37263. }
  37264. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37265. // it returns an error otherwise.
  37266. func (m UsageTotalMutation) Tx() (*Tx, error) {
  37267. if _, ok := m.driver.(*txDriver); !ok {
  37268. return nil, errors.New("ent: mutation is not running in a transaction")
  37269. }
  37270. tx := &Tx{config: m.config}
  37271. tx.init()
  37272. return tx, nil
  37273. }
  37274. // SetID sets the value of the id field. Note that this
  37275. // operation is only accepted on creation of UsageTotal entities.
  37276. func (m *UsageTotalMutation) SetID(id uint64) {
  37277. m.id = &id
  37278. }
  37279. // ID returns the ID value in the mutation. Note that the ID is only available
  37280. // if it was provided to the builder or after it was returned from the database.
  37281. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  37282. if m.id == nil {
  37283. return
  37284. }
  37285. return *m.id, true
  37286. }
  37287. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37288. // That means, if the mutation is applied within a transaction with an isolation level such
  37289. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37290. // or updated by the mutation.
  37291. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  37292. switch {
  37293. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37294. id, exists := m.ID()
  37295. if exists {
  37296. return []uint64{id}, nil
  37297. }
  37298. fallthrough
  37299. case m.op.Is(OpUpdate | OpDelete):
  37300. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  37301. default:
  37302. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37303. }
  37304. }
  37305. // SetCreatedAt sets the "created_at" field.
  37306. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  37307. m.created_at = &t
  37308. }
  37309. // CreatedAt returns the value of the "created_at" field in the mutation.
  37310. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  37311. v := m.created_at
  37312. if v == nil {
  37313. return
  37314. }
  37315. return *v, true
  37316. }
  37317. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  37318. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37320. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37321. if !m.op.Is(OpUpdateOne) {
  37322. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37323. }
  37324. if m.id == nil || m.oldValue == nil {
  37325. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37326. }
  37327. oldValue, err := m.oldValue(ctx)
  37328. if err != nil {
  37329. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37330. }
  37331. return oldValue.CreatedAt, nil
  37332. }
  37333. // ResetCreatedAt resets all changes to the "created_at" field.
  37334. func (m *UsageTotalMutation) ResetCreatedAt() {
  37335. m.created_at = nil
  37336. }
  37337. // SetUpdatedAt sets the "updated_at" field.
  37338. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  37339. m.updated_at = &t
  37340. }
  37341. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37342. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  37343. v := m.updated_at
  37344. if v == nil {
  37345. return
  37346. }
  37347. return *v, true
  37348. }
  37349. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  37350. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37352. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37353. if !m.op.Is(OpUpdateOne) {
  37354. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37355. }
  37356. if m.id == nil || m.oldValue == nil {
  37357. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37358. }
  37359. oldValue, err := m.oldValue(ctx)
  37360. if err != nil {
  37361. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37362. }
  37363. return oldValue.UpdatedAt, nil
  37364. }
  37365. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37366. func (m *UsageTotalMutation) ResetUpdatedAt() {
  37367. m.updated_at = nil
  37368. }
  37369. // SetStatus sets the "status" field.
  37370. func (m *UsageTotalMutation) SetStatus(u uint8) {
  37371. m.status = &u
  37372. m.addstatus = nil
  37373. }
  37374. // Status returns the value of the "status" field in the mutation.
  37375. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  37376. v := m.status
  37377. if v == nil {
  37378. return
  37379. }
  37380. return *v, true
  37381. }
  37382. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  37383. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37385. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37386. if !m.op.Is(OpUpdateOne) {
  37387. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37388. }
  37389. if m.id == nil || m.oldValue == nil {
  37390. return v, errors.New("OldStatus requires an ID field in the mutation")
  37391. }
  37392. oldValue, err := m.oldValue(ctx)
  37393. if err != nil {
  37394. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37395. }
  37396. return oldValue.Status, nil
  37397. }
  37398. // AddStatus adds u to the "status" field.
  37399. func (m *UsageTotalMutation) AddStatus(u int8) {
  37400. if m.addstatus != nil {
  37401. *m.addstatus += u
  37402. } else {
  37403. m.addstatus = &u
  37404. }
  37405. }
  37406. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37407. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  37408. v := m.addstatus
  37409. if v == nil {
  37410. return
  37411. }
  37412. return *v, true
  37413. }
  37414. // ClearStatus clears the value of the "status" field.
  37415. func (m *UsageTotalMutation) ClearStatus() {
  37416. m.status = nil
  37417. m.addstatus = nil
  37418. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  37419. }
  37420. // StatusCleared returns if the "status" field was cleared in this mutation.
  37421. func (m *UsageTotalMutation) StatusCleared() bool {
  37422. _, ok := m.clearedFields[usagetotal.FieldStatus]
  37423. return ok
  37424. }
  37425. // ResetStatus resets all changes to the "status" field.
  37426. func (m *UsageTotalMutation) ResetStatus() {
  37427. m.status = nil
  37428. m.addstatus = nil
  37429. delete(m.clearedFields, usagetotal.FieldStatus)
  37430. }
  37431. // SetType sets the "type" field.
  37432. func (m *UsageTotalMutation) SetType(i int) {
  37433. m._type = &i
  37434. m.add_type = nil
  37435. }
  37436. // GetType returns the value of the "type" field in the mutation.
  37437. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  37438. v := m._type
  37439. if v == nil {
  37440. return
  37441. }
  37442. return *v, true
  37443. }
  37444. // OldType returns the old "type" field's value of the UsageTotal entity.
  37445. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37447. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  37448. if !m.op.Is(OpUpdateOne) {
  37449. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37450. }
  37451. if m.id == nil || m.oldValue == nil {
  37452. return v, errors.New("OldType requires an ID field in the mutation")
  37453. }
  37454. oldValue, err := m.oldValue(ctx)
  37455. if err != nil {
  37456. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37457. }
  37458. return oldValue.Type, nil
  37459. }
  37460. // AddType adds i to the "type" field.
  37461. func (m *UsageTotalMutation) AddType(i int) {
  37462. if m.add_type != nil {
  37463. *m.add_type += i
  37464. } else {
  37465. m.add_type = &i
  37466. }
  37467. }
  37468. // AddedType returns the value that was added to the "type" field in this mutation.
  37469. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  37470. v := m.add_type
  37471. if v == nil {
  37472. return
  37473. }
  37474. return *v, true
  37475. }
  37476. // ClearType clears the value of the "type" field.
  37477. func (m *UsageTotalMutation) ClearType() {
  37478. m._type = nil
  37479. m.add_type = nil
  37480. m.clearedFields[usagetotal.FieldType] = struct{}{}
  37481. }
  37482. // TypeCleared returns if the "type" field was cleared in this mutation.
  37483. func (m *UsageTotalMutation) TypeCleared() bool {
  37484. _, ok := m.clearedFields[usagetotal.FieldType]
  37485. return ok
  37486. }
  37487. // ResetType resets all changes to the "type" field.
  37488. func (m *UsageTotalMutation) ResetType() {
  37489. m._type = nil
  37490. m.add_type = nil
  37491. delete(m.clearedFields, usagetotal.FieldType)
  37492. }
  37493. // SetBotID sets the "bot_id" field.
  37494. func (m *UsageTotalMutation) SetBotID(s string) {
  37495. m.bot_id = &s
  37496. }
  37497. // BotID returns the value of the "bot_id" field in the mutation.
  37498. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  37499. v := m.bot_id
  37500. if v == nil {
  37501. return
  37502. }
  37503. return *v, true
  37504. }
  37505. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  37506. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37508. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  37509. if !m.op.Is(OpUpdateOne) {
  37510. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37511. }
  37512. if m.id == nil || m.oldValue == nil {
  37513. return v, errors.New("OldBotID requires an ID field in the mutation")
  37514. }
  37515. oldValue, err := m.oldValue(ctx)
  37516. if err != nil {
  37517. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37518. }
  37519. return oldValue.BotID, nil
  37520. }
  37521. // ResetBotID resets all changes to the "bot_id" field.
  37522. func (m *UsageTotalMutation) ResetBotID() {
  37523. m.bot_id = nil
  37524. }
  37525. // SetTotalTokens sets the "total_tokens" field.
  37526. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  37527. m.total_tokens = &u
  37528. m.addtotal_tokens = nil
  37529. }
  37530. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  37531. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  37532. v := m.total_tokens
  37533. if v == nil {
  37534. return
  37535. }
  37536. return *v, true
  37537. }
  37538. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  37539. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37541. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  37542. if !m.op.Is(OpUpdateOne) {
  37543. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  37544. }
  37545. if m.id == nil || m.oldValue == nil {
  37546. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  37547. }
  37548. oldValue, err := m.oldValue(ctx)
  37549. if err != nil {
  37550. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  37551. }
  37552. return oldValue.TotalTokens, nil
  37553. }
  37554. // AddTotalTokens adds u to the "total_tokens" field.
  37555. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  37556. if m.addtotal_tokens != nil {
  37557. *m.addtotal_tokens += u
  37558. } else {
  37559. m.addtotal_tokens = &u
  37560. }
  37561. }
  37562. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  37563. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  37564. v := m.addtotal_tokens
  37565. if v == nil {
  37566. return
  37567. }
  37568. return *v, true
  37569. }
  37570. // ClearTotalTokens clears the value of the "total_tokens" field.
  37571. func (m *UsageTotalMutation) ClearTotalTokens() {
  37572. m.total_tokens = nil
  37573. m.addtotal_tokens = nil
  37574. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  37575. }
  37576. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  37577. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  37578. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  37579. return ok
  37580. }
  37581. // ResetTotalTokens resets all changes to the "total_tokens" field.
  37582. func (m *UsageTotalMutation) ResetTotalTokens() {
  37583. m.total_tokens = nil
  37584. m.addtotal_tokens = nil
  37585. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  37586. }
  37587. // SetStartIndex sets the "start_index" field.
  37588. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  37589. m.start_index = &u
  37590. m.addstart_index = nil
  37591. }
  37592. // StartIndex returns the value of the "start_index" field in the mutation.
  37593. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  37594. v := m.start_index
  37595. if v == nil {
  37596. return
  37597. }
  37598. return *v, true
  37599. }
  37600. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  37601. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37603. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  37604. if !m.op.Is(OpUpdateOne) {
  37605. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  37606. }
  37607. if m.id == nil || m.oldValue == nil {
  37608. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  37609. }
  37610. oldValue, err := m.oldValue(ctx)
  37611. if err != nil {
  37612. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  37613. }
  37614. return oldValue.StartIndex, nil
  37615. }
  37616. // AddStartIndex adds u to the "start_index" field.
  37617. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  37618. if m.addstart_index != nil {
  37619. *m.addstart_index += u
  37620. } else {
  37621. m.addstart_index = &u
  37622. }
  37623. }
  37624. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  37625. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  37626. v := m.addstart_index
  37627. if v == nil {
  37628. return
  37629. }
  37630. return *v, true
  37631. }
  37632. // ClearStartIndex clears the value of the "start_index" field.
  37633. func (m *UsageTotalMutation) ClearStartIndex() {
  37634. m.start_index = nil
  37635. m.addstart_index = nil
  37636. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  37637. }
  37638. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  37639. func (m *UsageTotalMutation) StartIndexCleared() bool {
  37640. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  37641. return ok
  37642. }
  37643. // ResetStartIndex resets all changes to the "start_index" field.
  37644. func (m *UsageTotalMutation) ResetStartIndex() {
  37645. m.start_index = nil
  37646. m.addstart_index = nil
  37647. delete(m.clearedFields, usagetotal.FieldStartIndex)
  37648. }
  37649. // SetEndIndex sets the "end_index" field.
  37650. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  37651. m.end_index = &u
  37652. m.addend_index = nil
  37653. }
  37654. // EndIndex returns the value of the "end_index" field in the mutation.
  37655. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  37656. v := m.end_index
  37657. if v == nil {
  37658. return
  37659. }
  37660. return *v, true
  37661. }
  37662. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  37663. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37665. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  37666. if !m.op.Is(OpUpdateOne) {
  37667. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  37668. }
  37669. if m.id == nil || m.oldValue == nil {
  37670. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  37671. }
  37672. oldValue, err := m.oldValue(ctx)
  37673. if err != nil {
  37674. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  37675. }
  37676. return oldValue.EndIndex, nil
  37677. }
  37678. // AddEndIndex adds u to the "end_index" field.
  37679. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  37680. if m.addend_index != nil {
  37681. *m.addend_index += u
  37682. } else {
  37683. m.addend_index = &u
  37684. }
  37685. }
  37686. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  37687. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  37688. v := m.addend_index
  37689. if v == nil {
  37690. return
  37691. }
  37692. return *v, true
  37693. }
  37694. // ClearEndIndex clears the value of the "end_index" field.
  37695. func (m *UsageTotalMutation) ClearEndIndex() {
  37696. m.end_index = nil
  37697. m.addend_index = nil
  37698. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  37699. }
  37700. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  37701. func (m *UsageTotalMutation) EndIndexCleared() bool {
  37702. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  37703. return ok
  37704. }
  37705. // ResetEndIndex resets all changes to the "end_index" field.
  37706. func (m *UsageTotalMutation) ResetEndIndex() {
  37707. m.end_index = nil
  37708. m.addend_index = nil
  37709. delete(m.clearedFields, usagetotal.FieldEndIndex)
  37710. }
  37711. // SetOrganizationID sets the "organization_id" field.
  37712. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  37713. m.organization_id = &u
  37714. m.addorganization_id = nil
  37715. }
  37716. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37717. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  37718. v := m.organization_id
  37719. if v == nil {
  37720. return
  37721. }
  37722. return *v, true
  37723. }
  37724. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  37725. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37727. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37728. if !m.op.Is(OpUpdateOne) {
  37729. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37730. }
  37731. if m.id == nil || m.oldValue == nil {
  37732. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37733. }
  37734. oldValue, err := m.oldValue(ctx)
  37735. if err != nil {
  37736. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37737. }
  37738. return oldValue.OrganizationID, nil
  37739. }
  37740. // AddOrganizationID adds u to the "organization_id" field.
  37741. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  37742. if m.addorganization_id != nil {
  37743. *m.addorganization_id += u
  37744. } else {
  37745. m.addorganization_id = &u
  37746. }
  37747. }
  37748. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37749. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  37750. v := m.addorganization_id
  37751. if v == nil {
  37752. return
  37753. }
  37754. return *v, true
  37755. }
  37756. // ClearOrganizationID clears the value of the "organization_id" field.
  37757. func (m *UsageTotalMutation) ClearOrganizationID() {
  37758. m.organization_id = nil
  37759. m.addorganization_id = nil
  37760. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  37761. }
  37762. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37763. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  37764. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  37765. return ok
  37766. }
  37767. // ResetOrganizationID resets all changes to the "organization_id" field.
  37768. func (m *UsageTotalMutation) ResetOrganizationID() {
  37769. m.organization_id = nil
  37770. m.addorganization_id = nil
  37771. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  37772. }
  37773. // Where appends a list predicates to the UsageTotalMutation builder.
  37774. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  37775. m.predicates = append(m.predicates, ps...)
  37776. }
  37777. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  37778. // users can use type-assertion to append predicates that do not depend on any generated package.
  37779. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  37780. p := make([]predicate.UsageTotal, len(ps))
  37781. for i := range ps {
  37782. p[i] = ps[i]
  37783. }
  37784. m.Where(p...)
  37785. }
  37786. // Op returns the operation name.
  37787. func (m *UsageTotalMutation) Op() Op {
  37788. return m.op
  37789. }
  37790. // SetOp allows setting the mutation operation.
  37791. func (m *UsageTotalMutation) SetOp(op Op) {
  37792. m.op = op
  37793. }
  37794. // Type returns the node type of this mutation (UsageTotal).
  37795. func (m *UsageTotalMutation) Type() string {
  37796. return m.typ
  37797. }
  37798. // Fields returns all fields that were changed during this mutation. Note that in
  37799. // order to get all numeric fields that were incremented/decremented, call
  37800. // AddedFields().
  37801. func (m *UsageTotalMutation) Fields() []string {
  37802. fields := make([]string, 0, 9)
  37803. if m.created_at != nil {
  37804. fields = append(fields, usagetotal.FieldCreatedAt)
  37805. }
  37806. if m.updated_at != nil {
  37807. fields = append(fields, usagetotal.FieldUpdatedAt)
  37808. }
  37809. if m.status != nil {
  37810. fields = append(fields, usagetotal.FieldStatus)
  37811. }
  37812. if m._type != nil {
  37813. fields = append(fields, usagetotal.FieldType)
  37814. }
  37815. if m.bot_id != nil {
  37816. fields = append(fields, usagetotal.FieldBotID)
  37817. }
  37818. if m.total_tokens != nil {
  37819. fields = append(fields, usagetotal.FieldTotalTokens)
  37820. }
  37821. if m.start_index != nil {
  37822. fields = append(fields, usagetotal.FieldStartIndex)
  37823. }
  37824. if m.end_index != nil {
  37825. fields = append(fields, usagetotal.FieldEndIndex)
  37826. }
  37827. if m.organization_id != nil {
  37828. fields = append(fields, usagetotal.FieldOrganizationID)
  37829. }
  37830. return fields
  37831. }
  37832. // Field returns the value of a field with the given name. The second boolean
  37833. // return value indicates that this field was not set, or was not defined in the
  37834. // schema.
  37835. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  37836. switch name {
  37837. case usagetotal.FieldCreatedAt:
  37838. return m.CreatedAt()
  37839. case usagetotal.FieldUpdatedAt:
  37840. return m.UpdatedAt()
  37841. case usagetotal.FieldStatus:
  37842. return m.Status()
  37843. case usagetotal.FieldType:
  37844. return m.GetType()
  37845. case usagetotal.FieldBotID:
  37846. return m.BotID()
  37847. case usagetotal.FieldTotalTokens:
  37848. return m.TotalTokens()
  37849. case usagetotal.FieldStartIndex:
  37850. return m.StartIndex()
  37851. case usagetotal.FieldEndIndex:
  37852. return m.EndIndex()
  37853. case usagetotal.FieldOrganizationID:
  37854. return m.OrganizationID()
  37855. }
  37856. return nil, false
  37857. }
  37858. // OldField returns the old value of the field from the database. An error is
  37859. // returned if the mutation operation is not UpdateOne, or the query to the
  37860. // database failed.
  37861. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37862. switch name {
  37863. case usagetotal.FieldCreatedAt:
  37864. return m.OldCreatedAt(ctx)
  37865. case usagetotal.FieldUpdatedAt:
  37866. return m.OldUpdatedAt(ctx)
  37867. case usagetotal.FieldStatus:
  37868. return m.OldStatus(ctx)
  37869. case usagetotal.FieldType:
  37870. return m.OldType(ctx)
  37871. case usagetotal.FieldBotID:
  37872. return m.OldBotID(ctx)
  37873. case usagetotal.FieldTotalTokens:
  37874. return m.OldTotalTokens(ctx)
  37875. case usagetotal.FieldStartIndex:
  37876. return m.OldStartIndex(ctx)
  37877. case usagetotal.FieldEndIndex:
  37878. return m.OldEndIndex(ctx)
  37879. case usagetotal.FieldOrganizationID:
  37880. return m.OldOrganizationID(ctx)
  37881. }
  37882. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  37883. }
  37884. // SetField sets the value of a field with the given name. It returns an error if
  37885. // the field is not defined in the schema, or if the type mismatched the field
  37886. // type.
  37887. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  37888. switch name {
  37889. case usagetotal.FieldCreatedAt:
  37890. v, ok := value.(time.Time)
  37891. if !ok {
  37892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37893. }
  37894. m.SetCreatedAt(v)
  37895. return nil
  37896. case usagetotal.FieldUpdatedAt:
  37897. v, ok := value.(time.Time)
  37898. if !ok {
  37899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37900. }
  37901. m.SetUpdatedAt(v)
  37902. return nil
  37903. case usagetotal.FieldStatus:
  37904. v, ok := value.(uint8)
  37905. if !ok {
  37906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37907. }
  37908. m.SetStatus(v)
  37909. return nil
  37910. case usagetotal.FieldType:
  37911. v, ok := value.(int)
  37912. if !ok {
  37913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37914. }
  37915. m.SetType(v)
  37916. return nil
  37917. case usagetotal.FieldBotID:
  37918. v, ok := value.(string)
  37919. if !ok {
  37920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37921. }
  37922. m.SetBotID(v)
  37923. return nil
  37924. case usagetotal.FieldTotalTokens:
  37925. v, ok := value.(uint64)
  37926. if !ok {
  37927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37928. }
  37929. m.SetTotalTokens(v)
  37930. return nil
  37931. case usagetotal.FieldStartIndex:
  37932. v, ok := value.(uint64)
  37933. if !ok {
  37934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37935. }
  37936. m.SetStartIndex(v)
  37937. return nil
  37938. case usagetotal.FieldEndIndex:
  37939. v, ok := value.(uint64)
  37940. if !ok {
  37941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37942. }
  37943. m.SetEndIndex(v)
  37944. return nil
  37945. case usagetotal.FieldOrganizationID:
  37946. v, ok := value.(uint64)
  37947. if !ok {
  37948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37949. }
  37950. m.SetOrganizationID(v)
  37951. return nil
  37952. }
  37953. return fmt.Errorf("unknown UsageTotal field %s", name)
  37954. }
  37955. // AddedFields returns all numeric fields that were incremented/decremented during
  37956. // this mutation.
  37957. func (m *UsageTotalMutation) AddedFields() []string {
  37958. var fields []string
  37959. if m.addstatus != nil {
  37960. fields = append(fields, usagetotal.FieldStatus)
  37961. }
  37962. if m.add_type != nil {
  37963. fields = append(fields, usagetotal.FieldType)
  37964. }
  37965. if m.addtotal_tokens != nil {
  37966. fields = append(fields, usagetotal.FieldTotalTokens)
  37967. }
  37968. if m.addstart_index != nil {
  37969. fields = append(fields, usagetotal.FieldStartIndex)
  37970. }
  37971. if m.addend_index != nil {
  37972. fields = append(fields, usagetotal.FieldEndIndex)
  37973. }
  37974. if m.addorganization_id != nil {
  37975. fields = append(fields, usagetotal.FieldOrganizationID)
  37976. }
  37977. return fields
  37978. }
  37979. // AddedField returns the numeric value that was incremented/decremented on a field
  37980. // with the given name. The second boolean return value indicates that this field
  37981. // was not set, or was not defined in the schema.
  37982. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  37983. switch name {
  37984. case usagetotal.FieldStatus:
  37985. return m.AddedStatus()
  37986. case usagetotal.FieldType:
  37987. return m.AddedType()
  37988. case usagetotal.FieldTotalTokens:
  37989. return m.AddedTotalTokens()
  37990. case usagetotal.FieldStartIndex:
  37991. return m.AddedStartIndex()
  37992. case usagetotal.FieldEndIndex:
  37993. return m.AddedEndIndex()
  37994. case usagetotal.FieldOrganizationID:
  37995. return m.AddedOrganizationID()
  37996. }
  37997. return nil, false
  37998. }
  37999. // AddField adds the value to the field with the given name. It returns an error if
  38000. // the field is not defined in the schema, or if the type mismatched the field
  38001. // type.
  38002. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  38003. switch name {
  38004. case usagetotal.FieldStatus:
  38005. v, ok := value.(int8)
  38006. if !ok {
  38007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38008. }
  38009. m.AddStatus(v)
  38010. return nil
  38011. case usagetotal.FieldType:
  38012. v, ok := value.(int)
  38013. if !ok {
  38014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38015. }
  38016. m.AddType(v)
  38017. return nil
  38018. case usagetotal.FieldTotalTokens:
  38019. v, ok := value.(int64)
  38020. if !ok {
  38021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38022. }
  38023. m.AddTotalTokens(v)
  38024. return nil
  38025. case usagetotal.FieldStartIndex:
  38026. v, ok := value.(int64)
  38027. if !ok {
  38028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38029. }
  38030. m.AddStartIndex(v)
  38031. return nil
  38032. case usagetotal.FieldEndIndex:
  38033. v, ok := value.(int64)
  38034. if !ok {
  38035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38036. }
  38037. m.AddEndIndex(v)
  38038. return nil
  38039. case usagetotal.FieldOrganizationID:
  38040. v, ok := value.(int64)
  38041. if !ok {
  38042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38043. }
  38044. m.AddOrganizationID(v)
  38045. return nil
  38046. }
  38047. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  38048. }
  38049. // ClearedFields returns all nullable fields that were cleared during this
  38050. // mutation.
  38051. func (m *UsageTotalMutation) ClearedFields() []string {
  38052. var fields []string
  38053. if m.FieldCleared(usagetotal.FieldStatus) {
  38054. fields = append(fields, usagetotal.FieldStatus)
  38055. }
  38056. if m.FieldCleared(usagetotal.FieldType) {
  38057. fields = append(fields, usagetotal.FieldType)
  38058. }
  38059. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  38060. fields = append(fields, usagetotal.FieldTotalTokens)
  38061. }
  38062. if m.FieldCleared(usagetotal.FieldStartIndex) {
  38063. fields = append(fields, usagetotal.FieldStartIndex)
  38064. }
  38065. if m.FieldCleared(usagetotal.FieldEndIndex) {
  38066. fields = append(fields, usagetotal.FieldEndIndex)
  38067. }
  38068. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  38069. fields = append(fields, usagetotal.FieldOrganizationID)
  38070. }
  38071. return fields
  38072. }
  38073. // FieldCleared returns a boolean indicating if a field with the given name was
  38074. // cleared in this mutation.
  38075. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  38076. _, ok := m.clearedFields[name]
  38077. return ok
  38078. }
  38079. // ClearField clears the value of the field with the given name. It returns an
  38080. // error if the field is not defined in the schema.
  38081. func (m *UsageTotalMutation) ClearField(name string) error {
  38082. switch name {
  38083. case usagetotal.FieldStatus:
  38084. m.ClearStatus()
  38085. return nil
  38086. case usagetotal.FieldType:
  38087. m.ClearType()
  38088. return nil
  38089. case usagetotal.FieldTotalTokens:
  38090. m.ClearTotalTokens()
  38091. return nil
  38092. case usagetotal.FieldStartIndex:
  38093. m.ClearStartIndex()
  38094. return nil
  38095. case usagetotal.FieldEndIndex:
  38096. m.ClearEndIndex()
  38097. return nil
  38098. case usagetotal.FieldOrganizationID:
  38099. m.ClearOrganizationID()
  38100. return nil
  38101. }
  38102. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  38103. }
  38104. // ResetField resets all changes in the mutation for the field with the given name.
  38105. // It returns an error if the field is not defined in the schema.
  38106. func (m *UsageTotalMutation) ResetField(name string) error {
  38107. switch name {
  38108. case usagetotal.FieldCreatedAt:
  38109. m.ResetCreatedAt()
  38110. return nil
  38111. case usagetotal.FieldUpdatedAt:
  38112. m.ResetUpdatedAt()
  38113. return nil
  38114. case usagetotal.FieldStatus:
  38115. m.ResetStatus()
  38116. return nil
  38117. case usagetotal.FieldType:
  38118. m.ResetType()
  38119. return nil
  38120. case usagetotal.FieldBotID:
  38121. m.ResetBotID()
  38122. return nil
  38123. case usagetotal.FieldTotalTokens:
  38124. m.ResetTotalTokens()
  38125. return nil
  38126. case usagetotal.FieldStartIndex:
  38127. m.ResetStartIndex()
  38128. return nil
  38129. case usagetotal.FieldEndIndex:
  38130. m.ResetEndIndex()
  38131. return nil
  38132. case usagetotal.FieldOrganizationID:
  38133. m.ResetOrganizationID()
  38134. return nil
  38135. }
  38136. return fmt.Errorf("unknown UsageTotal field %s", name)
  38137. }
  38138. // AddedEdges returns all edge names that were set/added in this mutation.
  38139. func (m *UsageTotalMutation) AddedEdges() []string {
  38140. edges := make([]string, 0, 0)
  38141. return edges
  38142. }
  38143. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38144. // name in this mutation.
  38145. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  38146. return nil
  38147. }
  38148. // RemovedEdges returns all edge names that were removed in this mutation.
  38149. func (m *UsageTotalMutation) RemovedEdges() []string {
  38150. edges := make([]string, 0, 0)
  38151. return edges
  38152. }
  38153. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38154. // the given name in this mutation.
  38155. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  38156. return nil
  38157. }
  38158. // ClearedEdges returns all edge names that were cleared in this mutation.
  38159. func (m *UsageTotalMutation) ClearedEdges() []string {
  38160. edges := make([]string, 0, 0)
  38161. return edges
  38162. }
  38163. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38164. // was cleared in this mutation.
  38165. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  38166. return false
  38167. }
  38168. // ClearEdge clears the value of the edge with the given name. It returns an error
  38169. // if that edge is not defined in the schema.
  38170. func (m *UsageTotalMutation) ClearEdge(name string) error {
  38171. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  38172. }
  38173. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38174. // It returns an error if the edge is not defined in the schema.
  38175. func (m *UsageTotalMutation) ResetEdge(name string) error {
  38176. return fmt.Errorf("unknown UsageTotal edge %s", name)
  38177. }
  38178. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  38179. type WhatsappMutation struct {
  38180. config
  38181. op Op
  38182. typ string
  38183. id *uint64
  38184. created_at *time.Time
  38185. updated_at *time.Time
  38186. status *uint8
  38187. addstatus *int8
  38188. deleted_at *time.Time
  38189. wa_id *string
  38190. wa_name *string
  38191. callback *string
  38192. account *string
  38193. cc *string
  38194. phone *string
  38195. cc_phone *string
  38196. phone_name *string
  38197. phone_status *int8
  38198. addphone_status *int8
  38199. organization_id *uint64
  38200. addorganization_id *int64
  38201. api_base *string
  38202. api_key *string
  38203. allow_list *[]string
  38204. appendallow_list []string
  38205. group_allow_list *[]string
  38206. appendgroup_allow_list []string
  38207. block_list *[]string
  38208. appendblock_list []string
  38209. group_block_list *[]string
  38210. appendgroup_block_list []string
  38211. clearedFields map[string]struct{}
  38212. agent *uint64
  38213. clearedagent bool
  38214. done bool
  38215. oldValue func(context.Context) (*Whatsapp, error)
  38216. predicates []predicate.Whatsapp
  38217. }
  38218. var _ ent.Mutation = (*WhatsappMutation)(nil)
  38219. // whatsappOption allows management of the mutation configuration using functional options.
  38220. type whatsappOption func(*WhatsappMutation)
  38221. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  38222. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  38223. m := &WhatsappMutation{
  38224. config: c,
  38225. op: op,
  38226. typ: TypeWhatsapp,
  38227. clearedFields: make(map[string]struct{}),
  38228. }
  38229. for _, opt := range opts {
  38230. opt(m)
  38231. }
  38232. return m
  38233. }
  38234. // withWhatsappID sets the ID field of the mutation.
  38235. func withWhatsappID(id uint64) whatsappOption {
  38236. return func(m *WhatsappMutation) {
  38237. var (
  38238. err error
  38239. once sync.Once
  38240. value *Whatsapp
  38241. )
  38242. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  38243. once.Do(func() {
  38244. if m.done {
  38245. err = errors.New("querying old values post mutation is not allowed")
  38246. } else {
  38247. value, err = m.Client().Whatsapp.Get(ctx, id)
  38248. }
  38249. })
  38250. return value, err
  38251. }
  38252. m.id = &id
  38253. }
  38254. }
  38255. // withWhatsapp sets the old Whatsapp of the mutation.
  38256. func withWhatsapp(node *Whatsapp) whatsappOption {
  38257. return func(m *WhatsappMutation) {
  38258. m.oldValue = func(context.Context) (*Whatsapp, error) {
  38259. return node, nil
  38260. }
  38261. m.id = &node.ID
  38262. }
  38263. }
  38264. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38265. // executed in a transaction (ent.Tx), a transactional client is returned.
  38266. func (m WhatsappMutation) Client() *Client {
  38267. client := &Client{config: m.config}
  38268. client.init()
  38269. return client
  38270. }
  38271. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38272. // it returns an error otherwise.
  38273. func (m WhatsappMutation) Tx() (*Tx, error) {
  38274. if _, ok := m.driver.(*txDriver); !ok {
  38275. return nil, errors.New("ent: mutation is not running in a transaction")
  38276. }
  38277. tx := &Tx{config: m.config}
  38278. tx.init()
  38279. return tx, nil
  38280. }
  38281. // SetID sets the value of the id field. Note that this
  38282. // operation is only accepted on creation of Whatsapp entities.
  38283. func (m *WhatsappMutation) SetID(id uint64) {
  38284. m.id = &id
  38285. }
  38286. // ID returns the ID value in the mutation. Note that the ID is only available
  38287. // if it was provided to the builder or after it was returned from the database.
  38288. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  38289. if m.id == nil {
  38290. return
  38291. }
  38292. return *m.id, true
  38293. }
  38294. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38295. // That means, if the mutation is applied within a transaction with an isolation level such
  38296. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38297. // or updated by the mutation.
  38298. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  38299. switch {
  38300. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38301. id, exists := m.ID()
  38302. if exists {
  38303. return []uint64{id}, nil
  38304. }
  38305. fallthrough
  38306. case m.op.Is(OpUpdate | OpDelete):
  38307. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  38308. default:
  38309. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38310. }
  38311. }
  38312. // SetCreatedAt sets the "created_at" field.
  38313. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  38314. m.created_at = &t
  38315. }
  38316. // CreatedAt returns the value of the "created_at" field in the mutation.
  38317. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  38318. v := m.created_at
  38319. if v == nil {
  38320. return
  38321. }
  38322. return *v, true
  38323. }
  38324. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  38325. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38327. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38328. if !m.op.Is(OpUpdateOne) {
  38329. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38330. }
  38331. if m.id == nil || m.oldValue == nil {
  38332. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38333. }
  38334. oldValue, err := m.oldValue(ctx)
  38335. if err != nil {
  38336. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38337. }
  38338. return oldValue.CreatedAt, nil
  38339. }
  38340. // ResetCreatedAt resets all changes to the "created_at" field.
  38341. func (m *WhatsappMutation) ResetCreatedAt() {
  38342. m.created_at = nil
  38343. }
  38344. // SetUpdatedAt sets the "updated_at" field.
  38345. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  38346. m.updated_at = &t
  38347. }
  38348. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38349. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  38350. v := m.updated_at
  38351. if v == nil {
  38352. return
  38353. }
  38354. return *v, true
  38355. }
  38356. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  38357. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38359. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38360. if !m.op.Is(OpUpdateOne) {
  38361. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38362. }
  38363. if m.id == nil || m.oldValue == nil {
  38364. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38365. }
  38366. oldValue, err := m.oldValue(ctx)
  38367. if err != nil {
  38368. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38369. }
  38370. return oldValue.UpdatedAt, nil
  38371. }
  38372. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38373. func (m *WhatsappMutation) ResetUpdatedAt() {
  38374. m.updated_at = nil
  38375. }
  38376. // SetStatus sets the "status" field.
  38377. func (m *WhatsappMutation) SetStatus(u uint8) {
  38378. m.status = &u
  38379. m.addstatus = nil
  38380. }
  38381. // Status returns the value of the "status" field in the mutation.
  38382. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  38383. v := m.status
  38384. if v == nil {
  38385. return
  38386. }
  38387. return *v, true
  38388. }
  38389. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  38390. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38392. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38393. if !m.op.Is(OpUpdateOne) {
  38394. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38395. }
  38396. if m.id == nil || m.oldValue == nil {
  38397. return v, errors.New("OldStatus requires an ID field in the mutation")
  38398. }
  38399. oldValue, err := m.oldValue(ctx)
  38400. if err != nil {
  38401. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38402. }
  38403. return oldValue.Status, nil
  38404. }
  38405. // AddStatus adds u to the "status" field.
  38406. func (m *WhatsappMutation) AddStatus(u int8) {
  38407. if m.addstatus != nil {
  38408. *m.addstatus += u
  38409. } else {
  38410. m.addstatus = &u
  38411. }
  38412. }
  38413. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38414. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  38415. v := m.addstatus
  38416. if v == nil {
  38417. return
  38418. }
  38419. return *v, true
  38420. }
  38421. // ClearStatus clears the value of the "status" field.
  38422. func (m *WhatsappMutation) ClearStatus() {
  38423. m.status = nil
  38424. m.addstatus = nil
  38425. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  38426. }
  38427. // StatusCleared returns if the "status" field was cleared in this mutation.
  38428. func (m *WhatsappMutation) StatusCleared() bool {
  38429. _, ok := m.clearedFields[whatsapp.FieldStatus]
  38430. return ok
  38431. }
  38432. // ResetStatus resets all changes to the "status" field.
  38433. func (m *WhatsappMutation) ResetStatus() {
  38434. m.status = nil
  38435. m.addstatus = nil
  38436. delete(m.clearedFields, whatsapp.FieldStatus)
  38437. }
  38438. // SetDeletedAt sets the "deleted_at" field.
  38439. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  38440. m.deleted_at = &t
  38441. }
  38442. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38443. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  38444. v := m.deleted_at
  38445. if v == nil {
  38446. return
  38447. }
  38448. return *v, true
  38449. }
  38450. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  38451. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38453. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38454. if !m.op.Is(OpUpdateOne) {
  38455. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38456. }
  38457. if m.id == nil || m.oldValue == nil {
  38458. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38459. }
  38460. oldValue, err := m.oldValue(ctx)
  38461. if err != nil {
  38462. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38463. }
  38464. return oldValue.DeletedAt, nil
  38465. }
  38466. // ClearDeletedAt clears the value of the "deleted_at" field.
  38467. func (m *WhatsappMutation) ClearDeletedAt() {
  38468. m.deleted_at = nil
  38469. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  38470. }
  38471. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38472. func (m *WhatsappMutation) DeletedAtCleared() bool {
  38473. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  38474. return ok
  38475. }
  38476. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38477. func (m *WhatsappMutation) ResetDeletedAt() {
  38478. m.deleted_at = nil
  38479. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  38480. }
  38481. // SetWaID sets the "wa_id" field.
  38482. func (m *WhatsappMutation) SetWaID(s string) {
  38483. m.wa_id = &s
  38484. }
  38485. // WaID returns the value of the "wa_id" field in the mutation.
  38486. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  38487. v := m.wa_id
  38488. if v == nil {
  38489. return
  38490. }
  38491. return *v, true
  38492. }
  38493. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  38494. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38496. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  38497. if !m.op.Is(OpUpdateOne) {
  38498. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38499. }
  38500. if m.id == nil || m.oldValue == nil {
  38501. return v, errors.New("OldWaID requires an ID field in the mutation")
  38502. }
  38503. oldValue, err := m.oldValue(ctx)
  38504. if err != nil {
  38505. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38506. }
  38507. return oldValue.WaID, nil
  38508. }
  38509. // ClearWaID clears the value of the "wa_id" field.
  38510. func (m *WhatsappMutation) ClearWaID() {
  38511. m.wa_id = nil
  38512. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  38513. }
  38514. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38515. func (m *WhatsappMutation) WaIDCleared() bool {
  38516. _, ok := m.clearedFields[whatsapp.FieldWaID]
  38517. return ok
  38518. }
  38519. // ResetWaID resets all changes to the "wa_id" field.
  38520. func (m *WhatsappMutation) ResetWaID() {
  38521. m.wa_id = nil
  38522. delete(m.clearedFields, whatsapp.FieldWaID)
  38523. }
  38524. // SetWaName sets the "wa_name" field.
  38525. func (m *WhatsappMutation) SetWaName(s string) {
  38526. m.wa_name = &s
  38527. }
  38528. // WaName returns the value of the "wa_name" field in the mutation.
  38529. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  38530. v := m.wa_name
  38531. if v == nil {
  38532. return
  38533. }
  38534. return *v, true
  38535. }
  38536. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  38537. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38539. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  38540. if !m.op.Is(OpUpdateOne) {
  38541. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38542. }
  38543. if m.id == nil || m.oldValue == nil {
  38544. return v, errors.New("OldWaName requires an ID field in the mutation")
  38545. }
  38546. oldValue, err := m.oldValue(ctx)
  38547. if err != nil {
  38548. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38549. }
  38550. return oldValue.WaName, nil
  38551. }
  38552. // ClearWaName clears the value of the "wa_name" field.
  38553. func (m *WhatsappMutation) ClearWaName() {
  38554. m.wa_name = nil
  38555. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  38556. }
  38557. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38558. func (m *WhatsappMutation) WaNameCleared() bool {
  38559. _, ok := m.clearedFields[whatsapp.FieldWaName]
  38560. return ok
  38561. }
  38562. // ResetWaName resets all changes to the "wa_name" field.
  38563. func (m *WhatsappMutation) ResetWaName() {
  38564. m.wa_name = nil
  38565. delete(m.clearedFields, whatsapp.FieldWaName)
  38566. }
  38567. // SetCallback sets the "callback" field.
  38568. func (m *WhatsappMutation) SetCallback(s string) {
  38569. m.callback = &s
  38570. }
  38571. // Callback returns the value of the "callback" field in the mutation.
  38572. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  38573. v := m.callback
  38574. if v == nil {
  38575. return
  38576. }
  38577. return *v, true
  38578. }
  38579. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  38580. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38582. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  38583. if !m.op.Is(OpUpdateOne) {
  38584. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  38585. }
  38586. if m.id == nil || m.oldValue == nil {
  38587. return v, errors.New("OldCallback requires an ID field in the mutation")
  38588. }
  38589. oldValue, err := m.oldValue(ctx)
  38590. if err != nil {
  38591. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  38592. }
  38593. return oldValue.Callback, nil
  38594. }
  38595. // ClearCallback clears the value of the "callback" field.
  38596. func (m *WhatsappMutation) ClearCallback() {
  38597. m.callback = nil
  38598. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  38599. }
  38600. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  38601. func (m *WhatsappMutation) CallbackCleared() bool {
  38602. _, ok := m.clearedFields[whatsapp.FieldCallback]
  38603. return ok
  38604. }
  38605. // ResetCallback resets all changes to the "callback" field.
  38606. func (m *WhatsappMutation) ResetCallback() {
  38607. m.callback = nil
  38608. delete(m.clearedFields, whatsapp.FieldCallback)
  38609. }
  38610. // SetAgentID sets the "agent_id" field.
  38611. func (m *WhatsappMutation) SetAgentID(u uint64) {
  38612. m.agent = &u
  38613. }
  38614. // AgentID returns the value of the "agent_id" field in the mutation.
  38615. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  38616. v := m.agent
  38617. if v == nil {
  38618. return
  38619. }
  38620. return *v, true
  38621. }
  38622. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  38623. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38625. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38626. if !m.op.Is(OpUpdateOne) {
  38627. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38628. }
  38629. if m.id == nil || m.oldValue == nil {
  38630. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38631. }
  38632. oldValue, err := m.oldValue(ctx)
  38633. if err != nil {
  38634. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38635. }
  38636. return oldValue.AgentID, nil
  38637. }
  38638. // ResetAgentID resets all changes to the "agent_id" field.
  38639. func (m *WhatsappMutation) ResetAgentID() {
  38640. m.agent = nil
  38641. }
  38642. // SetAccount sets the "account" field.
  38643. func (m *WhatsappMutation) SetAccount(s string) {
  38644. m.account = &s
  38645. }
  38646. // Account returns the value of the "account" field in the mutation.
  38647. func (m *WhatsappMutation) Account() (r string, exists bool) {
  38648. v := m.account
  38649. if v == nil {
  38650. return
  38651. }
  38652. return *v, true
  38653. }
  38654. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  38655. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38657. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  38658. if !m.op.Is(OpUpdateOne) {
  38659. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  38660. }
  38661. if m.id == nil || m.oldValue == nil {
  38662. return v, errors.New("OldAccount requires an ID field in the mutation")
  38663. }
  38664. oldValue, err := m.oldValue(ctx)
  38665. if err != nil {
  38666. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  38667. }
  38668. return oldValue.Account, nil
  38669. }
  38670. // ClearAccount clears the value of the "account" field.
  38671. func (m *WhatsappMutation) ClearAccount() {
  38672. m.account = nil
  38673. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  38674. }
  38675. // AccountCleared returns if the "account" field was cleared in this mutation.
  38676. func (m *WhatsappMutation) AccountCleared() bool {
  38677. _, ok := m.clearedFields[whatsapp.FieldAccount]
  38678. return ok
  38679. }
  38680. // ResetAccount resets all changes to the "account" field.
  38681. func (m *WhatsappMutation) ResetAccount() {
  38682. m.account = nil
  38683. delete(m.clearedFields, whatsapp.FieldAccount)
  38684. }
  38685. // SetCc sets the "cc" field.
  38686. func (m *WhatsappMutation) SetCc(s string) {
  38687. m.cc = &s
  38688. }
  38689. // Cc returns the value of the "cc" field in the mutation.
  38690. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  38691. v := m.cc
  38692. if v == nil {
  38693. return
  38694. }
  38695. return *v, true
  38696. }
  38697. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  38698. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38700. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  38701. if !m.op.Is(OpUpdateOne) {
  38702. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  38703. }
  38704. if m.id == nil || m.oldValue == nil {
  38705. return v, errors.New("OldCc requires an ID field in the mutation")
  38706. }
  38707. oldValue, err := m.oldValue(ctx)
  38708. if err != nil {
  38709. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  38710. }
  38711. return oldValue.Cc, nil
  38712. }
  38713. // ResetCc resets all changes to the "cc" field.
  38714. func (m *WhatsappMutation) ResetCc() {
  38715. m.cc = nil
  38716. }
  38717. // SetPhone sets the "phone" field.
  38718. func (m *WhatsappMutation) SetPhone(s string) {
  38719. m.phone = &s
  38720. }
  38721. // Phone returns the value of the "phone" field in the mutation.
  38722. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  38723. v := m.phone
  38724. if v == nil {
  38725. return
  38726. }
  38727. return *v, true
  38728. }
  38729. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  38730. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38732. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  38733. if !m.op.Is(OpUpdateOne) {
  38734. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  38735. }
  38736. if m.id == nil || m.oldValue == nil {
  38737. return v, errors.New("OldPhone requires an ID field in the mutation")
  38738. }
  38739. oldValue, err := m.oldValue(ctx)
  38740. if err != nil {
  38741. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  38742. }
  38743. return oldValue.Phone, nil
  38744. }
  38745. // ResetPhone resets all changes to the "phone" field.
  38746. func (m *WhatsappMutation) ResetPhone() {
  38747. m.phone = nil
  38748. }
  38749. // SetCcPhone sets the "cc_phone" field.
  38750. func (m *WhatsappMutation) SetCcPhone(s string) {
  38751. m.cc_phone = &s
  38752. }
  38753. // CcPhone returns the value of the "cc_phone" field in the mutation.
  38754. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  38755. v := m.cc_phone
  38756. if v == nil {
  38757. return
  38758. }
  38759. return *v, true
  38760. }
  38761. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  38762. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38764. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  38765. if !m.op.Is(OpUpdateOne) {
  38766. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  38767. }
  38768. if m.id == nil || m.oldValue == nil {
  38769. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  38770. }
  38771. oldValue, err := m.oldValue(ctx)
  38772. if err != nil {
  38773. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  38774. }
  38775. return oldValue.CcPhone, nil
  38776. }
  38777. // ResetCcPhone resets all changes to the "cc_phone" field.
  38778. func (m *WhatsappMutation) ResetCcPhone() {
  38779. m.cc_phone = nil
  38780. }
  38781. // SetPhoneName sets the "phone_name" field.
  38782. func (m *WhatsappMutation) SetPhoneName(s string) {
  38783. m.phone_name = &s
  38784. }
  38785. // PhoneName returns the value of the "phone_name" field in the mutation.
  38786. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  38787. v := m.phone_name
  38788. if v == nil {
  38789. return
  38790. }
  38791. return *v, true
  38792. }
  38793. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  38794. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38796. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  38797. if !m.op.Is(OpUpdateOne) {
  38798. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  38799. }
  38800. if m.id == nil || m.oldValue == nil {
  38801. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  38802. }
  38803. oldValue, err := m.oldValue(ctx)
  38804. if err != nil {
  38805. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  38806. }
  38807. return oldValue.PhoneName, nil
  38808. }
  38809. // ResetPhoneName resets all changes to the "phone_name" field.
  38810. func (m *WhatsappMutation) ResetPhoneName() {
  38811. m.phone_name = nil
  38812. }
  38813. // SetPhoneStatus sets the "phone_status" field.
  38814. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  38815. m.phone_status = &i
  38816. m.addphone_status = nil
  38817. }
  38818. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  38819. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  38820. v := m.phone_status
  38821. if v == nil {
  38822. return
  38823. }
  38824. return *v, true
  38825. }
  38826. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  38827. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38829. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  38830. if !m.op.Is(OpUpdateOne) {
  38831. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  38832. }
  38833. if m.id == nil || m.oldValue == nil {
  38834. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  38835. }
  38836. oldValue, err := m.oldValue(ctx)
  38837. if err != nil {
  38838. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  38839. }
  38840. return oldValue.PhoneStatus, nil
  38841. }
  38842. // AddPhoneStatus adds i to the "phone_status" field.
  38843. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  38844. if m.addphone_status != nil {
  38845. *m.addphone_status += i
  38846. } else {
  38847. m.addphone_status = &i
  38848. }
  38849. }
  38850. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  38851. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  38852. v := m.addphone_status
  38853. if v == nil {
  38854. return
  38855. }
  38856. return *v, true
  38857. }
  38858. // ResetPhoneStatus resets all changes to the "phone_status" field.
  38859. func (m *WhatsappMutation) ResetPhoneStatus() {
  38860. m.phone_status = nil
  38861. m.addphone_status = nil
  38862. }
  38863. // SetOrganizationID sets the "organization_id" field.
  38864. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  38865. m.organization_id = &u
  38866. m.addorganization_id = nil
  38867. }
  38868. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38869. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  38870. v := m.organization_id
  38871. if v == nil {
  38872. return
  38873. }
  38874. return *v, true
  38875. }
  38876. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  38877. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38879. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38880. if !m.op.Is(OpUpdateOne) {
  38881. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38882. }
  38883. if m.id == nil || m.oldValue == nil {
  38884. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38885. }
  38886. oldValue, err := m.oldValue(ctx)
  38887. if err != nil {
  38888. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38889. }
  38890. return oldValue.OrganizationID, nil
  38891. }
  38892. // AddOrganizationID adds u to the "organization_id" field.
  38893. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  38894. if m.addorganization_id != nil {
  38895. *m.addorganization_id += u
  38896. } else {
  38897. m.addorganization_id = &u
  38898. }
  38899. }
  38900. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38901. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  38902. v := m.addorganization_id
  38903. if v == nil {
  38904. return
  38905. }
  38906. return *v, true
  38907. }
  38908. // ClearOrganizationID clears the value of the "organization_id" field.
  38909. func (m *WhatsappMutation) ClearOrganizationID() {
  38910. m.organization_id = nil
  38911. m.addorganization_id = nil
  38912. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  38913. }
  38914. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38915. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  38916. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  38917. return ok
  38918. }
  38919. // ResetOrganizationID resets all changes to the "organization_id" field.
  38920. func (m *WhatsappMutation) ResetOrganizationID() {
  38921. m.organization_id = nil
  38922. m.addorganization_id = nil
  38923. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  38924. }
  38925. // SetAPIBase sets the "api_base" field.
  38926. func (m *WhatsappMutation) SetAPIBase(s string) {
  38927. m.api_base = &s
  38928. }
  38929. // APIBase returns the value of the "api_base" field in the mutation.
  38930. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  38931. v := m.api_base
  38932. if v == nil {
  38933. return
  38934. }
  38935. return *v, true
  38936. }
  38937. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  38938. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38940. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38941. if !m.op.Is(OpUpdateOne) {
  38942. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38943. }
  38944. if m.id == nil || m.oldValue == nil {
  38945. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38946. }
  38947. oldValue, err := m.oldValue(ctx)
  38948. if err != nil {
  38949. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38950. }
  38951. return oldValue.APIBase, nil
  38952. }
  38953. // ClearAPIBase clears the value of the "api_base" field.
  38954. func (m *WhatsappMutation) ClearAPIBase() {
  38955. m.api_base = nil
  38956. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  38957. }
  38958. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38959. func (m *WhatsappMutation) APIBaseCleared() bool {
  38960. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  38961. return ok
  38962. }
  38963. // ResetAPIBase resets all changes to the "api_base" field.
  38964. func (m *WhatsappMutation) ResetAPIBase() {
  38965. m.api_base = nil
  38966. delete(m.clearedFields, whatsapp.FieldAPIBase)
  38967. }
  38968. // SetAPIKey sets the "api_key" field.
  38969. func (m *WhatsappMutation) SetAPIKey(s string) {
  38970. m.api_key = &s
  38971. }
  38972. // APIKey returns the value of the "api_key" field in the mutation.
  38973. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  38974. v := m.api_key
  38975. if v == nil {
  38976. return
  38977. }
  38978. return *v, true
  38979. }
  38980. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  38981. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38983. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38984. if !m.op.Is(OpUpdateOne) {
  38985. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38986. }
  38987. if m.id == nil || m.oldValue == nil {
  38988. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38989. }
  38990. oldValue, err := m.oldValue(ctx)
  38991. if err != nil {
  38992. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38993. }
  38994. return oldValue.APIKey, nil
  38995. }
  38996. // ClearAPIKey clears the value of the "api_key" field.
  38997. func (m *WhatsappMutation) ClearAPIKey() {
  38998. m.api_key = nil
  38999. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  39000. }
  39001. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39002. func (m *WhatsappMutation) APIKeyCleared() bool {
  39003. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  39004. return ok
  39005. }
  39006. // ResetAPIKey resets all changes to the "api_key" field.
  39007. func (m *WhatsappMutation) ResetAPIKey() {
  39008. m.api_key = nil
  39009. delete(m.clearedFields, whatsapp.FieldAPIKey)
  39010. }
  39011. // SetAllowList sets the "allow_list" field.
  39012. func (m *WhatsappMutation) SetAllowList(s []string) {
  39013. m.allow_list = &s
  39014. m.appendallow_list = nil
  39015. }
  39016. // AllowList returns the value of the "allow_list" field in the mutation.
  39017. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  39018. v := m.allow_list
  39019. if v == nil {
  39020. return
  39021. }
  39022. return *v, true
  39023. }
  39024. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  39025. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39027. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  39028. if !m.op.Is(OpUpdateOne) {
  39029. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  39030. }
  39031. if m.id == nil || m.oldValue == nil {
  39032. return v, errors.New("OldAllowList requires an ID field in the mutation")
  39033. }
  39034. oldValue, err := m.oldValue(ctx)
  39035. if err != nil {
  39036. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  39037. }
  39038. return oldValue.AllowList, nil
  39039. }
  39040. // AppendAllowList adds s to the "allow_list" field.
  39041. func (m *WhatsappMutation) AppendAllowList(s []string) {
  39042. m.appendallow_list = append(m.appendallow_list, s...)
  39043. }
  39044. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  39045. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  39046. if len(m.appendallow_list) == 0 {
  39047. return nil, false
  39048. }
  39049. return m.appendallow_list, true
  39050. }
  39051. // ClearAllowList clears the value of the "allow_list" field.
  39052. func (m *WhatsappMutation) ClearAllowList() {
  39053. m.allow_list = nil
  39054. m.appendallow_list = nil
  39055. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  39056. }
  39057. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  39058. func (m *WhatsappMutation) AllowListCleared() bool {
  39059. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  39060. return ok
  39061. }
  39062. // ResetAllowList resets all changes to the "allow_list" field.
  39063. func (m *WhatsappMutation) ResetAllowList() {
  39064. m.allow_list = nil
  39065. m.appendallow_list = nil
  39066. delete(m.clearedFields, whatsapp.FieldAllowList)
  39067. }
  39068. // SetGroupAllowList sets the "group_allow_list" field.
  39069. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  39070. m.group_allow_list = &s
  39071. m.appendgroup_allow_list = nil
  39072. }
  39073. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  39074. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  39075. v := m.group_allow_list
  39076. if v == nil {
  39077. return
  39078. }
  39079. return *v, true
  39080. }
  39081. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  39082. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39084. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  39085. if !m.op.Is(OpUpdateOne) {
  39086. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  39087. }
  39088. if m.id == nil || m.oldValue == nil {
  39089. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  39090. }
  39091. oldValue, err := m.oldValue(ctx)
  39092. if err != nil {
  39093. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  39094. }
  39095. return oldValue.GroupAllowList, nil
  39096. }
  39097. // AppendGroupAllowList adds s to the "group_allow_list" field.
  39098. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  39099. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  39100. }
  39101. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  39102. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  39103. if len(m.appendgroup_allow_list) == 0 {
  39104. return nil, false
  39105. }
  39106. return m.appendgroup_allow_list, true
  39107. }
  39108. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  39109. func (m *WhatsappMutation) ClearGroupAllowList() {
  39110. m.group_allow_list = nil
  39111. m.appendgroup_allow_list = nil
  39112. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  39113. }
  39114. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  39115. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  39116. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  39117. return ok
  39118. }
  39119. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  39120. func (m *WhatsappMutation) ResetGroupAllowList() {
  39121. m.group_allow_list = nil
  39122. m.appendgroup_allow_list = nil
  39123. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  39124. }
  39125. // SetBlockList sets the "block_list" field.
  39126. func (m *WhatsappMutation) SetBlockList(s []string) {
  39127. m.block_list = &s
  39128. m.appendblock_list = nil
  39129. }
  39130. // BlockList returns the value of the "block_list" field in the mutation.
  39131. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  39132. v := m.block_list
  39133. if v == nil {
  39134. return
  39135. }
  39136. return *v, true
  39137. }
  39138. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  39139. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39141. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  39142. if !m.op.Is(OpUpdateOne) {
  39143. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  39144. }
  39145. if m.id == nil || m.oldValue == nil {
  39146. return v, errors.New("OldBlockList requires an ID field in the mutation")
  39147. }
  39148. oldValue, err := m.oldValue(ctx)
  39149. if err != nil {
  39150. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  39151. }
  39152. return oldValue.BlockList, nil
  39153. }
  39154. // AppendBlockList adds s to the "block_list" field.
  39155. func (m *WhatsappMutation) AppendBlockList(s []string) {
  39156. m.appendblock_list = append(m.appendblock_list, s...)
  39157. }
  39158. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  39159. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  39160. if len(m.appendblock_list) == 0 {
  39161. return nil, false
  39162. }
  39163. return m.appendblock_list, true
  39164. }
  39165. // ClearBlockList clears the value of the "block_list" field.
  39166. func (m *WhatsappMutation) ClearBlockList() {
  39167. m.block_list = nil
  39168. m.appendblock_list = nil
  39169. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  39170. }
  39171. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  39172. func (m *WhatsappMutation) BlockListCleared() bool {
  39173. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  39174. return ok
  39175. }
  39176. // ResetBlockList resets all changes to the "block_list" field.
  39177. func (m *WhatsappMutation) ResetBlockList() {
  39178. m.block_list = nil
  39179. m.appendblock_list = nil
  39180. delete(m.clearedFields, whatsapp.FieldBlockList)
  39181. }
  39182. // SetGroupBlockList sets the "group_block_list" field.
  39183. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  39184. m.group_block_list = &s
  39185. m.appendgroup_block_list = nil
  39186. }
  39187. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  39188. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  39189. v := m.group_block_list
  39190. if v == nil {
  39191. return
  39192. }
  39193. return *v, true
  39194. }
  39195. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  39196. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39198. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  39199. if !m.op.Is(OpUpdateOne) {
  39200. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  39201. }
  39202. if m.id == nil || m.oldValue == nil {
  39203. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  39204. }
  39205. oldValue, err := m.oldValue(ctx)
  39206. if err != nil {
  39207. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  39208. }
  39209. return oldValue.GroupBlockList, nil
  39210. }
  39211. // AppendGroupBlockList adds s to the "group_block_list" field.
  39212. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  39213. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  39214. }
  39215. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  39216. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  39217. if len(m.appendgroup_block_list) == 0 {
  39218. return nil, false
  39219. }
  39220. return m.appendgroup_block_list, true
  39221. }
  39222. // ClearGroupBlockList clears the value of the "group_block_list" field.
  39223. func (m *WhatsappMutation) ClearGroupBlockList() {
  39224. m.group_block_list = nil
  39225. m.appendgroup_block_list = nil
  39226. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  39227. }
  39228. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  39229. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  39230. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  39231. return ok
  39232. }
  39233. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  39234. func (m *WhatsappMutation) ResetGroupBlockList() {
  39235. m.group_block_list = nil
  39236. m.appendgroup_block_list = nil
  39237. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  39238. }
  39239. // ClearAgent clears the "agent" edge to the Agent entity.
  39240. func (m *WhatsappMutation) ClearAgent() {
  39241. m.clearedagent = true
  39242. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  39243. }
  39244. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  39245. func (m *WhatsappMutation) AgentCleared() bool {
  39246. return m.clearedagent
  39247. }
  39248. // AgentIDs returns the "agent" edge IDs in the mutation.
  39249. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39250. // AgentID instead. It exists only for internal usage by the builders.
  39251. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  39252. if id := m.agent; id != nil {
  39253. ids = append(ids, *id)
  39254. }
  39255. return
  39256. }
  39257. // ResetAgent resets all changes to the "agent" edge.
  39258. func (m *WhatsappMutation) ResetAgent() {
  39259. m.agent = nil
  39260. m.clearedagent = false
  39261. }
  39262. // Where appends a list predicates to the WhatsappMutation builder.
  39263. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  39264. m.predicates = append(m.predicates, ps...)
  39265. }
  39266. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  39267. // users can use type-assertion to append predicates that do not depend on any generated package.
  39268. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  39269. p := make([]predicate.Whatsapp, len(ps))
  39270. for i := range ps {
  39271. p[i] = ps[i]
  39272. }
  39273. m.Where(p...)
  39274. }
  39275. // Op returns the operation name.
  39276. func (m *WhatsappMutation) Op() Op {
  39277. return m.op
  39278. }
  39279. // SetOp allows setting the mutation operation.
  39280. func (m *WhatsappMutation) SetOp(op Op) {
  39281. m.op = op
  39282. }
  39283. // Type returns the node type of this mutation (Whatsapp).
  39284. func (m *WhatsappMutation) Type() string {
  39285. return m.typ
  39286. }
  39287. // Fields returns all fields that were changed during this mutation. Note that in
  39288. // order to get all numeric fields that were incremented/decremented, call
  39289. // AddedFields().
  39290. func (m *WhatsappMutation) Fields() []string {
  39291. fields := make([]string, 0, 21)
  39292. if m.created_at != nil {
  39293. fields = append(fields, whatsapp.FieldCreatedAt)
  39294. }
  39295. if m.updated_at != nil {
  39296. fields = append(fields, whatsapp.FieldUpdatedAt)
  39297. }
  39298. if m.status != nil {
  39299. fields = append(fields, whatsapp.FieldStatus)
  39300. }
  39301. if m.deleted_at != nil {
  39302. fields = append(fields, whatsapp.FieldDeletedAt)
  39303. }
  39304. if m.wa_id != nil {
  39305. fields = append(fields, whatsapp.FieldWaID)
  39306. }
  39307. if m.wa_name != nil {
  39308. fields = append(fields, whatsapp.FieldWaName)
  39309. }
  39310. if m.callback != nil {
  39311. fields = append(fields, whatsapp.FieldCallback)
  39312. }
  39313. if m.agent != nil {
  39314. fields = append(fields, whatsapp.FieldAgentID)
  39315. }
  39316. if m.account != nil {
  39317. fields = append(fields, whatsapp.FieldAccount)
  39318. }
  39319. if m.cc != nil {
  39320. fields = append(fields, whatsapp.FieldCc)
  39321. }
  39322. if m.phone != nil {
  39323. fields = append(fields, whatsapp.FieldPhone)
  39324. }
  39325. if m.cc_phone != nil {
  39326. fields = append(fields, whatsapp.FieldCcPhone)
  39327. }
  39328. if m.phone_name != nil {
  39329. fields = append(fields, whatsapp.FieldPhoneName)
  39330. }
  39331. if m.phone_status != nil {
  39332. fields = append(fields, whatsapp.FieldPhoneStatus)
  39333. }
  39334. if m.organization_id != nil {
  39335. fields = append(fields, whatsapp.FieldOrganizationID)
  39336. }
  39337. if m.api_base != nil {
  39338. fields = append(fields, whatsapp.FieldAPIBase)
  39339. }
  39340. if m.api_key != nil {
  39341. fields = append(fields, whatsapp.FieldAPIKey)
  39342. }
  39343. if m.allow_list != nil {
  39344. fields = append(fields, whatsapp.FieldAllowList)
  39345. }
  39346. if m.group_allow_list != nil {
  39347. fields = append(fields, whatsapp.FieldGroupAllowList)
  39348. }
  39349. if m.block_list != nil {
  39350. fields = append(fields, whatsapp.FieldBlockList)
  39351. }
  39352. if m.group_block_list != nil {
  39353. fields = append(fields, whatsapp.FieldGroupBlockList)
  39354. }
  39355. return fields
  39356. }
  39357. // Field returns the value of a field with the given name. The second boolean
  39358. // return value indicates that this field was not set, or was not defined in the
  39359. // schema.
  39360. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  39361. switch name {
  39362. case whatsapp.FieldCreatedAt:
  39363. return m.CreatedAt()
  39364. case whatsapp.FieldUpdatedAt:
  39365. return m.UpdatedAt()
  39366. case whatsapp.FieldStatus:
  39367. return m.Status()
  39368. case whatsapp.FieldDeletedAt:
  39369. return m.DeletedAt()
  39370. case whatsapp.FieldWaID:
  39371. return m.WaID()
  39372. case whatsapp.FieldWaName:
  39373. return m.WaName()
  39374. case whatsapp.FieldCallback:
  39375. return m.Callback()
  39376. case whatsapp.FieldAgentID:
  39377. return m.AgentID()
  39378. case whatsapp.FieldAccount:
  39379. return m.Account()
  39380. case whatsapp.FieldCc:
  39381. return m.Cc()
  39382. case whatsapp.FieldPhone:
  39383. return m.Phone()
  39384. case whatsapp.FieldCcPhone:
  39385. return m.CcPhone()
  39386. case whatsapp.FieldPhoneName:
  39387. return m.PhoneName()
  39388. case whatsapp.FieldPhoneStatus:
  39389. return m.PhoneStatus()
  39390. case whatsapp.FieldOrganizationID:
  39391. return m.OrganizationID()
  39392. case whatsapp.FieldAPIBase:
  39393. return m.APIBase()
  39394. case whatsapp.FieldAPIKey:
  39395. return m.APIKey()
  39396. case whatsapp.FieldAllowList:
  39397. return m.AllowList()
  39398. case whatsapp.FieldGroupAllowList:
  39399. return m.GroupAllowList()
  39400. case whatsapp.FieldBlockList:
  39401. return m.BlockList()
  39402. case whatsapp.FieldGroupBlockList:
  39403. return m.GroupBlockList()
  39404. }
  39405. return nil, false
  39406. }
  39407. // OldField returns the old value of the field from the database. An error is
  39408. // returned if the mutation operation is not UpdateOne, or the query to the
  39409. // database failed.
  39410. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39411. switch name {
  39412. case whatsapp.FieldCreatedAt:
  39413. return m.OldCreatedAt(ctx)
  39414. case whatsapp.FieldUpdatedAt:
  39415. return m.OldUpdatedAt(ctx)
  39416. case whatsapp.FieldStatus:
  39417. return m.OldStatus(ctx)
  39418. case whatsapp.FieldDeletedAt:
  39419. return m.OldDeletedAt(ctx)
  39420. case whatsapp.FieldWaID:
  39421. return m.OldWaID(ctx)
  39422. case whatsapp.FieldWaName:
  39423. return m.OldWaName(ctx)
  39424. case whatsapp.FieldCallback:
  39425. return m.OldCallback(ctx)
  39426. case whatsapp.FieldAgentID:
  39427. return m.OldAgentID(ctx)
  39428. case whatsapp.FieldAccount:
  39429. return m.OldAccount(ctx)
  39430. case whatsapp.FieldCc:
  39431. return m.OldCc(ctx)
  39432. case whatsapp.FieldPhone:
  39433. return m.OldPhone(ctx)
  39434. case whatsapp.FieldCcPhone:
  39435. return m.OldCcPhone(ctx)
  39436. case whatsapp.FieldPhoneName:
  39437. return m.OldPhoneName(ctx)
  39438. case whatsapp.FieldPhoneStatus:
  39439. return m.OldPhoneStatus(ctx)
  39440. case whatsapp.FieldOrganizationID:
  39441. return m.OldOrganizationID(ctx)
  39442. case whatsapp.FieldAPIBase:
  39443. return m.OldAPIBase(ctx)
  39444. case whatsapp.FieldAPIKey:
  39445. return m.OldAPIKey(ctx)
  39446. case whatsapp.FieldAllowList:
  39447. return m.OldAllowList(ctx)
  39448. case whatsapp.FieldGroupAllowList:
  39449. return m.OldGroupAllowList(ctx)
  39450. case whatsapp.FieldBlockList:
  39451. return m.OldBlockList(ctx)
  39452. case whatsapp.FieldGroupBlockList:
  39453. return m.OldGroupBlockList(ctx)
  39454. }
  39455. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  39456. }
  39457. // SetField sets the value of a field with the given name. It returns an error if
  39458. // the field is not defined in the schema, or if the type mismatched the field
  39459. // type.
  39460. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  39461. switch name {
  39462. case whatsapp.FieldCreatedAt:
  39463. v, ok := value.(time.Time)
  39464. if !ok {
  39465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39466. }
  39467. m.SetCreatedAt(v)
  39468. return nil
  39469. case whatsapp.FieldUpdatedAt:
  39470. v, ok := value.(time.Time)
  39471. if !ok {
  39472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39473. }
  39474. m.SetUpdatedAt(v)
  39475. return nil
  39476. case whatsapp.FieldStatus:
  39477. v, ok := value.(uint8)
  39478. if !ok {
  39479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39480. }
  39481. m.SetStatus(v)
  39482. return nil
  39483. case whatsapp.FieldDeletedAt:
  39484. v, ok := value.(time.Time)
  39485. if !ok {
  39486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39487. }
  39488. m.SetDeletedAt(v)
  39489. return nil
  39490. case whatsapp.FieldWaID:
  39491. v, ok := value.(string)
  39492. if !ok {
  39493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39494. }
  39495. m.SetWaID(v)
  39496. return nil
  39497. case whatsapp.FieldWaName:
  39498. v, ok := value.(string)
  39499. if !ok {
  39500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39501. }
  39502. m.SetWaName(v)
  39503. return nil
  39504. case whatsapp.FieldCallback:
  39505. v, ok := value.(string)
  39506. if !ok {
  39507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39508. }
  39509. m.SetCallback(v)
  39510. return nil
  39511. case whatsapp.FieldAgentID:
  39512. v, ok := value.(uint64)
  39513. if !ok {
  39514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39515. }
  39516. m.SetAgentID(v)
  39517. return nil
  39518. case whatsapp.FieldAccount:
  39519. v, ok := value.(string)
  39520. if !ok {
  39521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39522. }
  39523. m.SetAccount(v)
  39524. return nil
  39525. case whatsapp.FieldCc:
  39526. v, ok := value.(string)
  39527. if !ok {
  39528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39529. }
  39530. m.SetCc(v)
  39531. return nil
  39532. case whatsapp.FieldPhone:
  39533. v, ok := value.(string)
  39534. if !ok {
  39535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39536. }
  39537. m.SetPhone(v)
  39538. return nil
  39539. case whatsapp.FieldCcPhone:
  39540. v, ok := value.(string)
  39541. if !ok {
  39542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39543. }
  39544. m.SetCcPhone(v)
  39545. return nil
  39546. case whatsapp.FieldPhoneName:
  39547. v, ok := value.(string)
  39548. if !ok {
  39549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39550. }
  39551. m.SetPhoneName(v)
  39552. return nil
  39553. case whatsapp.FieldPhoneStatus:
  39554. v, ok := value.(int8)
  39555. if !ok {
  39556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39557. }
  39558. m.SetPhoneStatus(v)
  39559. return nil
  39560. case whatsapp.FieldOrganizationID:
  39561. v, ok := value.(uint64)
  39562. if !ok {
  39563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39564. }
  39565. m.SetOrganizationID(v)
  39566. return nil
  39567. case whatsapp.FieldAPIBase:
  39568. v, ok := value.(string)
  39569. if !ok {
  39570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39571. }
  39572. m.SetAPIBase(v)
  39573. return nil
  39574. case whatsapp.FieldAPIKey:
  39575. v, ok := value.(string)
  39576. if !ok {
  39577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39578. }
  39579. m.SetAPIKey(v)
  39580. return nil
  39581. case whatsapp.FieldAllowList:
  39582. v, ok := value.([]string)
  39583. if !ok {
  39584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39585. }
  39586. m.SetAllowList(v)
  39587. return nil
  39588. case whatsapp.FieldGroupAllowList:
  39589. v, ok := value.([]string)
  39590. if !ok {
  39591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39592. }
  39593. m.SetGroupAllowList(v)
  39594. return nil
  39595. case whatsapp.FieldBlockList:
  39596. v, ok := value.([]string)
  39597. if !ok {
  39598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39599. }
  39600. m.SetBlockList(v)
  39601. return nil
  39602. case whatsapp.FieldGroupBlockList:
  39603. v, ok := value.([]string)
  39604. if !ok {
  39605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39606. }
  39607. m.SetGroupBlockList(v)
  39608. return nil
  39609. }
  39610. return fmt.Errorf("unknown Whatsapp field %s", name)
  39611. }
  39612. // AddedFields returns all numeric fields that were incremented/decremented during
  39613. // this mutation.
  39614. func (m *WhatsappMutation) AddedFields() []string {
  39615. var fields []string
  39616. if m.addstatus != nil {
  39617. fields = append(fields, whatsapp.FieldStatus)
  39618. }
  39619. if m.addphone_status != nil {
  39620. fields = append(fields, whatsapp.FieldPhoneStatus)
  39621. }
  39622. if m.addorganization_id != nil {
  39623. fields = append(fields, whatsapp.FieldOrganizationID)
  39624. }
  39625. return fields
  39626. }
  39627. // AddedField returns the numeric value that was incremented/decremented on a field
  39628. // with the given name. The second boolean return value indicates that this field
  39629. // was not set, or was not defined in the schema.
  39630. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  39631. switch name {
  39632. case whatsapp.FieldStatus:
  39633. return m.AddedStatus()
  39634. case whatsapp.FieldPhoneStatus:
  39635. return m.AddedPhoneStatus()
  39636. case whatsapp.FieldOrganizationID:
  39637. return m.AddedOrganizationID()
  39638. }
  39639. return nil, false
  39640. }
  39641. // AddField adds the value to the field with the given name. It returns an error if
  39642. // the field is not defined in the schema, or if the type mismatched the field
  39643. // type.
  39644. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  39645. switch name {
  39646. case whatsapp.FieldStatus:
  39647. v, ok := value.(int8)
  39648. if !ok {
  39649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39650. }
  39651. m.AddStatus(v)
  39652. return nil
  39653. case whatsapp.FieldPhoneStatus:
  39654. v, ok := value.(int8)
  39655. if !ok {
  39656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39657. }
  39658. m.AddPhoneStatus(v)
  39659. return nil
  39660. case whatsapp.FieldOrganizationID:
  39661. v, ok := value.(int64)
  39662. if !ok {
  39663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39664. }
  39665. m.AddOrganizationID(v)
  39666. return nil
  39667. }
  39668. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  39669. }
  39670. // ClearedFields returns all nullable fields that were cleared during this
  39671. // mutation.
  39672. func (m *WhatsappMutation) ClearedFields() []string {
  39673. var fields []string
  39674. if m.FieldCleared(whatsapp.FieldStatus) {
  39675. fields = append(fields, whatsapp.FieldStatus)
  39676. }
  39677. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  39678. fields = append(fields, whatsapp.FieldDeletedAt)
  39679. }
  39680. if m.FieldCleared(whatsapp.FieldWaID) {
  39681. fields = append(fields, whatsapp.FieldWaID)
  39682. }
  39683. if m.FieldCleared(whatsapp.FieldWaName) {
  39684. fields = append(fields, whatsapp.FieldWaName)
  39685. }
  39686. if m.FieldCleared(whatsapp.FieldCallback) {
  39687. fields = append(fields, whatsapp.FieldCallback)
  39688. }
  39689. if m.FieldCleared(whatsapp.FieldAccount) {
  39690. fields = append(fields, whatsapp.FieldAccount)
  39691. }
  39692. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  39693. fields = append(fields, whatsapp.FieldOrganizationID)
  39694. }
  39695. if m.FieldCleared(whatsapp.FieldAPIBase) {
  39696. fields = append(fields, whatsapp.FieldAPIBase)
  39697. }
  39698. if m.FieldCleared(whatsapp.FieldAPIKey) {
  39699. fields = append(fields, whatsapp.FieldAPIKey)
  39700. }
  39701. if m.FieldCleared(whatsapp.FieldAllowList) {
  39702. fields = append(fields, whatsapp.FieldAllowList)
  39703. }
  39704. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  39705. fields = append(fields, whatsapp.FieldGroupAllowList)
  39706. }
  39707. if m.FieldCleared(whatsapp.FieldBlockList) {
  39708. fields = append(fields, whatsapp.FieldBlockList)
  39709. }
  39710. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  39711. fields = append(fields, whatsapp.FieldGroupBlockList)
  39712. }
  39713. return fields
  39714. }
  39715. // FieldCleared returns a boolean indicating if a field with the given name was
  39716. // cleared in this mutation.
  39717. func (m *WhatsappMutation) FieldCleared(name string) bool {
  39718. _, ok := m.clearedFields[name]
  39719. return ok
  39720. }
  39721. // ClearField clears the value of the field with the given name. It returns an
  39722. // error if the field is not defined in the schema.
  39723. func (m *WhatsappMutation) ClearField(name string) error {
  39724. switch name {
  39725. case whatsapp.FieldStatus:
  39726. m.ClearStatus()
  39727. return nil
  39728. case whatsapp.FieldDeletedAt:
  39729. m.ClearDeletedAt()
  39730. return nil
  39731. case whatsapp.FieldWaID:
  39732. m.ClearWaID()
  39733. return nil
  39734. case whatsapp.FieldWaName:
  39735. m.ClearWaName()
  39736. return nil
  39737. case whatsapp.FieldCallback:
  39738. m.ClearCallback()
  39739. return nil
  39740. case whatsapp.FieldAccount:
  39741. m.ClearAccount()
  39742. return nil
  39743. case whatsapp.FieldOrganizationID:
  39744. m.ClearOrganizationID()
  39745. return nil
  39746. case whatsapp.FieldAPIBase:
  39747. m.ClearAPIBase()
  39748. return nil
  39749. case whatsapp.FieldAPIKey:
  39750. m.ClearAPIKey()
  39751. return nil
  39752. case whatsapp.FieldAllowList:
  39753. m.ClearAllowList()
  39754. return nil
  39755. case whatsapp.FieldGroupAllowList:
  39756. m.ClearGroupAllowList()
  39757. return nil
  39758. case whatsapp.FieldBlockList:
  39759. m.ClearBlockList()
  39760. return nil
  39761. case whatsapp.FieldGroupBlockList:
  39762. m.ClearGroupBlockList()
  39763. return nil
  39764. }
  39765. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  39766. }
  39767. // ResetField resets all changes in the mutation for the field with the given name.
  39768. // It returns an error if the field is not defined in the schema.
  39769. func (m *WhatsappMutation) ResetField(name string) error {
  39770. switch name {
  39771. case whatsapp.FieldCreatedAt:
  39772. m.ResetCreatedAt()
  39773. return nil
  39774. case whatsapp.FieldUpdatedAt:
  39775. m.ResetUpdatedAt()
  39776. return nil
  39777. case whatsapp.FieldStatus:
  39778. m.ResetStatus()
  39779. return nil
  39780. case whatsapp.FieldDeletedAt:
  39781. m.ResetDeletedAt()
  39782. return nil
  39783. case whatsapp.FieldWaID:
  39784. m.ResetWaID()
  39785. return nil
  39786. case whatsapp.FieldWaName:
  39787. m.ResetWaName()
  39788. return nil
  39789. case whatsapp.FieldCallback:
  39790. m.ResetCallback()
  39791. return nil
  39792. case whatsapp.FieldAgentID:
  39793. m.ResetAgentID()
  39794. return nil
  39795. case whatsapp.FieldAccount:
  39796. m.ResetAccount()
  39797. return nil
  39798. case whatsapp.FieldCc:
  39799. m.ResetCc()
  39800. return nil
  39801. case whatsapp.FieldPhone:
  39802. m.ResetPhone()
  39803. return nil
  39804. case whatsapp.FieldCcPhone:
  39805. m.ResetCcPhone()
  39806. return nil
  39807. case whatsapp.FieldPhoneName:
  39808. m.ResetPhoneName()
  39809. return nil
  39810. case whatsapp.FieldPhoneStatus:
  39811. m.ResetPhoneStatus()
  39812. return nil
  39813. case whatsapp.FieldOrganizationID:
  39814. m.ResetOrganizationID()
  39815. return nil
  39816. case whatsapp.FieldAPIBase:
  39817. m.ResetAPIBase()
  39818. return nil
  39819. case whatsapp.FieldAPIKey:
  39820. m.ResetAPIKey()
  39821. return nil
  39822. case whatsapp.FieldAllowList:
  39823. m.ResetAllowList()
  39824. return nil
  39825. case whatsapp.FieldGroupAllowList:
  39826. m.ResetGroupAllowList()
  39827. return nil
  39828. case whatsapp.FieldBlockList:
  39829. m.ResetBlockList()
  39830. return nil
  39831. case whatsapp.FieldGroupBlockList:
  39832. m.ResetGroupBlockList()
  39833. return nil
  39834. }
  39835. return fmt.Errorf("unknown Whatsapp field %s", name)
  39836. }
  39837. // AddedEdges returns all edge names that were set/added in this mutation.
  39838. func (m *WhatsappMutation) AddedEdges() []string {
  39839. edges := make([]string, 0, 1)
  39840. if m.agent != nil {
  39841. edges = append(edges, whatsapp.EdgeAgent)
  39842. }
  39843. return edges
  39844. }
  39845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39846. // name in this mutation.
  39847. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  39848. switch name {
  39849. case whatsapp.EdgeAgent:
  39850. if id := m.agent; id != nil {
  39851. return []ent.Value{*id}
  39852. }
  39853. }
  39854. return nil
  39855. }
  39856. // RemovedEdges returns all edge names that were removed in this mutation.
  39857. func (m *WhatsappMutation) RemovedEdges() []string {
  39858. edges := make([]string, 0, 1)
  39859. return edges
  39860. }
  39861. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39862. // the given name in this mutation.
  39863. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  39864. return nil
  39865. }
  39866. // ClearedEdges returns all edge names that were cleared in this mutation.
  39867. func (m *WhatsappMutation) ClearedEdges() []string {
  39868. edges := make([]string, 0, 1)
  39869. if m.clearedagent {
  39870. edges = append(edges, whatsapp.EdgeAgent)
  39871. }
  39872. return edges
  39873. }
  39874. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39875. // was cleared in this mutation.
  39876. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  39877. switch name {
  39878. case whatsapp.EdgeAgent:
  39879. return m.clearedagent
  39880. }
  39881. return false
  39882. }
  39883. // ClearEdge clears the value of the edge with the given name. It returns an error
  39884. // if that edge is not defined in the schema.
  39885. func (m *WhatsappMutation) ClearEdge(name string) error {
  39886. switch name {
  39887. case whatsapp.EdgeAgent:
  39888. m.ClearAgent()
  39889. return nil
  39890. }
  39891. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  39892. }
  39893. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39894. // It returns an error if the edge is not defined in the schema.
  39895. func (m *WhatsappMutation) ResetEdge(name string) error {
  39896. switch name {
  39897. case whatsapp.EdgeAgent:
  39898. m.ResetAgent()
  39899. return nil
  39900. }
  39901. return fmt.Errorf("unknown Whatsapp edge %s", name)
  39902. }
  39903. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  39904. type WhatsappChannelMutation struct {
  39905. config
  39906. op Op
  39907. typ string
  39908. id *uint64
  39909. created_at *time.Time
  39910. updated_at *time.Time
  39911. status *uint8
  39912. addstatus *int8
  39913. deleted_at *time.Time
  39914. ak *string
  39915. sk *string
  39916. wa_id *string
  39917. wa_name *string
  39918. waba_id *uint64
  39919. addwaba_id *int64
  39920. business_id *uint64
  39921. addbusiness_id *int64
  39922. organization_id *uint64
  39923. addorganization_id *int64
  39924. verify_account *string
  39925. clearedFields map[string]struct{}
  39926. done bool
  39927. oldValue func(context.Context) (*WhatsappChannel, error)
  39928. predicates []predicate.WhatsappChannel
  39929. }
  39930. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  39931. // whatsappchannelOption allows management of the mutation configuration using functional options.
  39932. type whatsappchannelOption func(*WhatsappChannelMutation)
  39933. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  39934. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  39935. m := &WhatsappChannelMutation{
  39936. config: c,
  39937. op: op,
  39938. typ: TypeWhatsappChannel,
  39939. clearedFields: make(map[string]struct{}),
  39940. }
  39941. for _, opt := range opts {
  39942. opt(m)
  39943. }
  39944. return m
  39945. }
  39946. // withWhatsappChannelID sets the ID field of the mutation.
  39947. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  39948. return func(m *WhatsappChannelMutation) {
  39949. var (
  39950. err error
  39951. once sync.Once
  39952. value *WhatsappChannel
  39953. )
  39954. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  39955. once.Do(func() {
  39956. if m.done {
  39957. err = errors.New("querying old values post mutation is not allowed")
  39958. } else {
  39959. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  39960. }
  39961. })
  39962. return value, err
  39963. }
  39964. m.id = &id
  39965. }
  39966. }
  39967. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  39968. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  39969. return func(m *WhatsappChannelMutation) {
  39970. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  39971. return node, nil
  39972. }
  39973. m.id = &node.ID
  39974. }
  39975. }
  39976. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39977. // executed in a transaction (ent.Tx), a transactional client is returned.
  39978. func (m WhatsappChannelMutation) Client() *Client {
  39979. client := &Client{config: m.config}
  39980. client.init()
  39981. return client
  39982. }
  39983. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39984. // it returns an error otherwise.
  39985. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  39986. if _, ok := m.driver.(*txDriver); !ok {
  39987. return nil, errors.New("ent: mutation is not running in a transaction")
  39988. }
  39989. tx := &Tx{config: m.config}
  39990. tx.init()
  39991. return tx, nil
  39992. }
  39993. // SetID sets the value of the id field. Note that this
  39994. // operation is only accepted on creation of WhatsappChannel entities.
  39995. func (m *WhatsappChannelMutation) SetID(id uint64) {
  39996. m.id = &id
  39997. }
  39998. // ID returns the ID value in the mutation. Note that the ID is only available
  39999. // if it was provided to the builder or after it was returned from the database.
  40000. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  40001. if m.id == nil {
  40002. return
  40003. }
  40004. return *m.id, true
  40005. }
  40006. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40007. // That means, if the mutation is applied within a transaction with an isolation level such
  40008. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40009. // or updated by the mutation.
  40010. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  40011. switch {
  40012. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40013. id, exists := m.ID()
  40014. if exists {
  40015. return []uint64{id}, nil
  40016. }
  40017. fallthrough
  40018. case m.op.Is(OpUpdate | OpDelete):
  40019. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  40020. default:
  40021. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40022. }
  40023. }
  40024. // SetCreatedAt sets the "created_at" field.
  40025. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  40026. m.created_at = &t
  40027. }
  40028. // CreatedAt returns the value of the "created_at" field in the mutation.
  40029. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  40030. v := m.created_at
  40031. if v == nil {
  40032. return
  40033. }
  40034. return *v, true
  40035. }
  40036. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  40037. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40039. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40040. if !m.op.Is(OpUpdateOne) {
  40041. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40042. }
  40043. if m.id == nil || m.oldValue == nil {
  40044. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40045. }
  40046. oldValue, err := m.oldValue(ctx)
  40047. if err != nil {
  40048. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40049. }
  40050. return oldValue.CreatedAt, nil
  40051. }
  40052. // ResetCreatedAt resets all changes to the "created_at" field.
  40053. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  40054. m.created_at = nil
  40055. }
  40056. // SetUpdatedAt sets the "updated_at" field.
  40057. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  40058. m.updated_at = &t
  40059. }
  40060. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40061. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  40062. v := m.updated_at
  40063. if v == nil {
  40064. return
  40065. }
  40066. return *v, true
  40067. }
  40068. // OldUpdatedAt returns the old "updated_at" 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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40072. if !m.op.Is(OpUpdateOne) {
  40073. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40074. }
  40075. if m.id == nil || m.oldValue == nil {
  40076. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  40081. }
  40082. return oldValue.UpdatedAt, nil
  40083. }
  40084. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40085. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  40086. m.updated_at = nil
  40087. }
  40088. // SetStatus sets the "status" field.
  40089. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  40090. m.status = &u
  40091. m.addstatus = nil
  40092. }
  40093. // Status returns the value of the "status" field in the mutation.
  40094. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  40095. v := m.status
  40096. if v == nil {
  40097. return
  40098. }
  40099. return *v, true
  40100. }
  40101. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  40102. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40104. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40105. if !m.op.Is(OpUpdateOne) {
  40106. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40107. }
  40108. if m.id == nil || m.oldValue == nil {
  40109. return v, errors.New("OldStatus requires an ID field in the mutation")
  40110. }
  40111. oldValue, err := m.oldValue(ctx)
  40112. if err != nil {
  40113. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40114. }
  40115. return oldValue.Status, nil
  40116. }
  40117. // AddStatus adds u to the "status" field.
  40118. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  40119. if m.addstatus != nil {
  40120. *m.addstatus += u
  40121. } else {
  40122. m.addstatus = &u
  40123. }
  40124. }
  40125. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40126. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  40127. v := m.addstatus
  40128. if v == nil {
  40129. return
  40130. }
  40131. return *v, true
  40132. }
  40133. // ClearStatus clears the value of the "status" field.
  40134. func (m *WhatsappChannelMutation) ClearStatus() {
  40135. m.status = nil
  40136. m.addstatus = nil
  40137. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  40138. }
  40139. // StatusCleared returns if the "status" field was cleared in this mutation.
  40140. func (m *WhatsappChannelMutation) StatusCleared() bool {
  40141. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  40142. return ok
  40143. }
  40144. // ResetStatus resets all changes to the "status" field.
  40145. func (m *WhatsappChannelMutation) ResetStatus() {
  40146. m.status = nil
  40147. m.addstatus = nil
  40148. delete(m.clearedFields, whatsappchannel.FieldStatus)
  40149. }
  40150. // SetDeletedAt sets the "deleted_at" field.
  40151. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  40152. m.deleted_at = &t
  40153. }
  40154. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40155. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  40156. v := m.deleted_at
  40157. if v == nil {
  40158. return
  40159. }
  40160. return *v, true
  40161. }
  40162. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  40163. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40165. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40166. if !m.op.Is(OpUpdateOne) {
  40167. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40168. }
  40169. if m.id == nil || m.oldValue == nil {
  40170. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40171. }
  40172. oldValue, err := m.oldValue(ctx)
  40173. if err != nil {
  40174. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40175. }
  40176. return oldValue.DeletedAt, nil
  40177. }
  40178. // ClearDeletedAt clears the value of the "deleted_at" field.
  40179. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  40180. m.deleted_at = nil
  40181. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  40182. }
  40183. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40184. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  40185. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  40186. return ok
  40187. }
  40188. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40189. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  40190. m.deleted_at = nil
  40191. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  40192. }
  40193. // SetAk sets the "ak" field.
  40194. func (m *WhatsappChannelMutation) SetAk(s string) {
  40195. m.ak = &s
  40196. }
  40197. // Ak returns the value of the "ak" field in the mutation.
  40198. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  40199. v := m.ak
  40200. if v == nil {
  40201. return
  40202. }
  40203. return *v, true
  40204. }
  40205. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  40206. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40208. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  40209. if !m.op.Is(OpUpdateOne) {
  40210. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  40211. }
  40212. if m.id == nil || m.oldValue == nil {
  40213. return v, errors.New("OldAk requires an ID field in the mutation")
  40214. }
  40215. oldValue, err := m.oldValue(ctx)
  40216. if err != nil {
  40217. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  40218. }
  40219. return oldValue.Ak, nil
  40220. }
  40221. // ClearAk clears the value of the "ak" field.
  40222. func (m *WhatsappChannelMutation) ClearAk() {
  40223. m.ak = nil
  40224. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  40225. }
  40226. // AkCleared returns if the "ak" field was cleared in this mutation.
  40227. func (m *WhatsappChannelMutation) AkCleared() bool {
  40228. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  40229. return ok
  40230. }
  40231. // ResetAk resets all changes to the "ak" field.
  40232. func (m *WhatsappChannelMutation) ResetAk() {
  40233. m.ak = nil
  40234. delete(m.clearedFields, whatsappchannel.FieldAk)
  40235. }
  40236. // SetSk sets the "sk" field.
  40237. func (m *WhatsappChannelMutation) SetSk(s string) {
  40238. m.sk = &s
  40239. }
  40240. // Sk returns the value of the "sk" field in the mutation.
  40241. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  40242. v := m.sk
  40243. if v == nil {
  40244. return
  40245. }
  40246. return *v, true
  40247. }
  40248. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  40249. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40251. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  40252. if !m.op.Is(OpUpdateOne) {
  40253. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  40254. }
  40255. if m.id == nil || m.oldValue == nil {
  40256. return v, errors.New("OldSk requires an ID field in the mutation")
  40257. }
  40258. oldValue, err := m.oldValue(ctx)
  40259. if err != nil {
  40260. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  40261. }
  40262. return oldValue.Sk, nil
  40263. }
  40264. // ResetSk resets all changes to the "sk" field.
  40265. func (m *WhatsappChannelMutation) ResetSk() {
  40266. m.sk = nil
  40267. }
  40268. // SetWaID sets the "wa_id" field.
  40269. func (m *WhatsappChannelMutation) SetWaID(s string) {
  40270. m.wa_id = &s
  40271. }
  40272. // WaID returns the value of the "wa_id" field in the mutation.
  40273. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  40274. v := m.wa_id
  40275. if v == nil {
  40276. return
  40277. }
  40278. return *v, true
  40279. }
  40280. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  40281. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40283. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  40284. if !m.op.Is(OpUpdateOne) {
  40285. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  40286. }
  40287. if m.id == nil || m.oldValue == nil {
  40288. return v, errors.New("OldWaID requires an ID field in the mutation")
  40289. }
  40290. oldValue, err := m.oldValue(ctx)
  40291. if err != nil {
  40292. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  40293. }
  40294. return oldValue.WaID, nil
  40295. }
  40296. // ClearWaID clears the value of the "wa_id" field.
  40297. func (m *WhatsappChannelMutation) ClearWaID() {
  40298. m.wa_id = nil
  40299. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  40300. }
  40301. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  40302. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  40303. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  40304. return ok
  40305. }
  40306. // ResetWaID resets all changes to the "wa_id" field.
  40307. func (m *WhatsappChannelMutation) ResetWaID() {
  40308. m.wa_id = nil
  40309. delete(m.clearedFields, whatsappchannel.FieldWaID)
  40310. }
  40311. // SetWaName sets the "wa_name" field.
  40312. func (m *WhatsappChannelMutation) SetWaName(s string) {
  40313. m.wa_name = &s
  40314. }
  40315. // WaName returns the value of the "wa_name" field in the mutation.
  40316. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  40317. v := m.wa_name
  40318. if v == nil {
  40319. return
  40320. }
  40321. return *v, true
  40322. }
  40323. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  40324. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40326. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  40327. if !m.op.Is(OpUpdateOne) {
  40328. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  40329. }
  40330. if m.id == nil || m.oldValue == nil {
  40331. return v, errors.New("OldWaName requires an ID field in the mutation")
  40332. }
  40333. oldValue, err := m.oldValue(ctx)
  40334. if err != nil {
  40335. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  40336. }
  40337. return oldValue.WaName, nil
  40338. }
  40339. // ClearWaName clears the value of the "wa_name" field.
  40340. func (m *WhatsappChannelMutation) ClearWaName() {
  40341. m.wa_name = nil
  40342. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  40343. }
  40344. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  40345. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  40346. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  40347. return ok
  40348. }
  40349. // ResetWaName resets all changes to the "wa_name" field.
  40350. func (m *WhatsappChannelMutation) ResetWaName() {
  40351. m.wa_name = nil
  40352. delete(m.clearedFields, whatsappchannel.FieldWaName)
  40353. }
  40354. // SetWabaID sets the "waba_id" field.
  40355. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  40356. m.waba_id = &u
  40357. m.addwaba_id = nil
  40358. }
  40359. // WabaID returns the value of the "waba_id" field in the mutation.
  40360. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  40361. v := m.waba_id
  40362. if v == nil {
  40363. return
  40364. }
  40365. return *v, true
  40366. }
  40367. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  40368. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40370. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  40371. if !m.op.Is(OpUpdateOne) {
  40372. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  40373. }
  40374. if m.id == nil || m.oldValue == nil {
  40375. return v, errors.New("OldWabaID requires an ID field in the mutation")
  40376. }
  40377. oldValue, err := m.oldValue(ctx)
  40378. if err != nil {
  40379. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  40380. }
  40381. return oldValue.WabaID, nil
  40382. }
  40383. // AddWabaID adds u to the "waba_id" field.
  40384. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  40385. if m.addwaba_id != nil {
  40386. *m.addwaba_id += u
  40387. } else {
  40388. m.addwaba_id = &u
  40389. }
  40390. }
  40391. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  40392. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  40393. v := m.addwaba_id
  40394. if v == nil {
  40395. return
  40396. }
  40397. return *v, true
  40398. }
  40399. // ResetWabaID resets all changes to the "waba_id" field.
  40400. func (m *WhatsappChannelMutation) ResetWabaID() {
  40401. m.waba_id = nil
  40402. m.addwaba_id = nil
  40403. }
  40404. // SetBusinessID sets the "business_id" field.
  40405. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  40406. m.business_id = &u
  40407. m.addbusiness_id = nil
  40408. }
  40409. // BusinessID returns the value of the "business_id" field in the mutation.
  40410. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  40411. v := m.business_id
  40412. if v == nil {
  40413. return
  40414. }
  40415. return *v, true
  40416. }
  40417. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  40418. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40420. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  40421. if !m.op.Is(OpUpdateOne) {
  40422. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  40423. }
  40424. if m.id == nil || m.oldValue == nil {
  40425. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  40426. }
  40427. oldValue, err := m.oldValue(ctx)
  40428. if err != nil {
  40429. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  40430. }
  40431. return oldValue.BusinessID, nil
  40432. }
  40433. // AddBusinessID adds u to the "business_id" field.
  40434. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  40435. if m.addbusiness_id != nil {
  40436. *m.addbusiness_id += u
  40437. } else {
  40438. m.addbusiness_id = &u
  40439. }
  40440. }
  40441. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  40442. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  40443. v := m.addbusiness_id
  40444. if v == nil {
  40445. return
  40446. }
  40447. return *v, true
  40448. }
  40449. // ResetBusinessID resets all changes to the "business_id" field.
  40450. func (m *WhatsappChannelMutation) ResetBusinessID() {
  40451. m.business_id = nil
  40452. m.addbusiness_id = nil
  40453. }
  40454. // SetOrganizationID sets the "organization_id" field.
  40455. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  40456. m.organization_id = &u
  40457. m.addorganization_id = nil
  40458. }
  40459. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40460. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  40461. v := m.organization_id
  40462. if v == nil {
  40463. return
  40464. }
  40465. return *v, true
  40466. }
  40467. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  40468. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40470. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40471. if !m.op.Is(OpUpdateOne) {
  40472. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40473. }
  40474. if m.id == nil || m.oldValue == nil {
  40475. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40476. }
  40477. oldValue, err := m.oldValue(ctx)
  40478. if err != nil {
  40479. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40480. }
  40481. return oldValue.OrganizationID, nil
  40482. }
  40483. // AddOrganizationID adds u to the "organization_id" field.
  40484. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  40485. if m.addorganization_id != nil {
  40486. *m.addorganization_id += u
  40487. } else {
  40488. m.addorganization_id = &u
  40489. }
  40490. }
  40491. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40492. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  40493. v := m.addorganization_id
  40494. if v == nil {
  40495. return
  40496. }
  40497. return *v, true
  40498. }
  40499. // ClearOrganizationID clears the value of the "organization_id" field.
  40500. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  40501. m.organization_id = nil
  40502. m.addorganization_id = nil
  40503. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  40504. }
  40505. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40506. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  40507. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  40508. return ok
  40509. }
  40510. // ResetOrganizationID resets all changes to the "organization_id" field.
  40511. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  40512. m.organization_id = nil
  40513. m.addorganization_id = nil
  40514. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  40515. }
  40516. // SetVerifyAccount sets the "verify_account" field.
  40517. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  40518. m.verify_account = &s
  40519. }
  40520. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  40521. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  40522. v := m.verify_account
  40523. if v == nil {
  40524. return
  40525. }
  40526. return *v, true
  40527. }
  40528. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  40529. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40531. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  40532. if !m.op.Is(OpUpdateOne) {
  40533. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  40534. }
  40535. if m.id == nil || m.oldValue == nil {
  40536. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  40537. }
  40538. oldValue, err := m.oldValue(ctx)
  40539. if err != nil {
  40540. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  40541. }
  40542. return oldValue.VerifyAccount, nil
  40543. }
  40544. // ResetVerifyAccount resets all changes to the "verify_account" field.
  40545. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  40546. m.verify_account = nil
  40547. }
  40548. // Where appends a list predicates to the WhatsappChannelMutation builder.
  40549. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  40550. m.predicates = append(m.predicates, ps...)
  40551. }
  40552. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  40553. // users can use type-assertion to append predicates that do not depend on any generated package.
  40554. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  40555. p := make([]predicate.WhatsappChannel, len(ps))
  40556. for i := range ps {
  40557. p[i] = ps[i]
  40558. }
  40559. m.Where(p...)
  40560. }
  40561. // Op returns the operation name.
  40562. func (m *WhatsappChannelMutation) Op() Op {
  40563. return m.op
  40564. }
  40565. // SetOp allows setting the mutation operation.
  40566. func (m *WhatsappChannelMutation) SetOp(op Op) {
  40567. m.op = op
  40568. }
  40569. // Type returns the node type of this mutation (WhatsappChannel).
  40570. func (m *WhatsappChannelMutation) Type() string {
  40571. return m.typ
  40572. }
  40573. // Fields returns all fields that were changed during this mutation. Note that in
  40574. // order to get all numeric fields that were incremented/decremented, call
  40575. // AddedFields().
  40576. func (m *WhatsappChannelMutation) Fields() []string {
  40577. fields := make([]string, 0, 12)
  40578. if m.created_at != nil {
  40579. fields = append(fields, whatsappchannel.FieldCreatedAt)
  40580. }
  40581. if m.updated_at != nil {
  40582. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  40583. }
  40584. if m.status != nil {
  40585. fields = append(fields, whatsappchannel.FieldStatus)
  40586. }
  40587. if m.deleted_at != nil {
  40588. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40589. }
  40590. if m.ak != nil {
  40591. fields = append(fields, whatsappchannel.FieldAk)
  40592. }
  40593. if m.sk != nil {
  40594. fields = append(fields, whatsappchannel.FieldSk)
  40595. }
  40596. if m.wa_id != nil {
  40597. fields = append(fields, whatsappchannel.FieldWaID)
  40598. }
  40599. if m.wa_name != nil {
  40600. fields = append(fields, whatsappchannel.FieldWaName)
  40601. }
  40602. if m.waba_id != nil {
  40603. fields = append(fields, whatsappchannel.FieldWabaID)
  40604. }
  40605. if m.business_id != nil {
  40606. fields = append(fields, whatsappchannel.FieldBusinessID)
  40607. }
  40608. if m.organization_id != nil {
  40609. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40610. }
  40611. if m.verify_account != nil {
  40612. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  40613. }
  40614. return fields
  40615. }
  40616. // Field returns the value of a field with the given name. The second boolean
  40617. // return value indicates that this field was not set, or was not defined in the
  40618. // schema.
  40619. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  40620. switch name {
  40621. case whatsappchannel.FieldCreatedAt:
  40622. return m.CreatedAt()
  40623. case whatsappchannel.FieldUpdatedAt:
  40624. return m.UpdatedAt()
  40625. case whatsappchannel.FieldStatus:
  40626. return m.Status()
  40627. case whatsappchannel.FieldDeletedAt:
  40628. return m.DeletedAt()
  40629. case whatsappchannel.FieldAk:
  40630. return m.Ak()
  40631. case whatsappchannel.FieldSk:
  40632. return m.Sk()
  40633. case whatsappchannel.FieldWaID:
  40634. return m.WaID()
  40635. case whatsappchannel.FieldWaName:
  40636. return m.WaName()
  40637. case whatsappchannel.FieldWabaID:
  40638. return m.WabaID()
  40639. case whatsappchannel.FieldBusinessID:
  40640. return m.BusinessID()
  40641. case whatsappchannel.FieldOrganizationID:
  40642. return m.OrganizationID()
  40643. case whatsappchannel.FieldVerifyAccount:
  40644. return m.VerifyAccount()
  40645. }
  40646. return nil, false
  40647. }
  40648. // OldField returns the old value of the field from the database. An error is
  40649. // returned if the mutation operation is not UpdateOne, or the query to the
  40650. // database failed.
  40651. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40652. switch name {
  40653. case whatsappchannel.FieldCreatedAt:
  40654. return m.OldCreatedAt(ctx)
  40655. case whatsappchannel.FieldUpdatedAt:
  40656. return m.OldUpdatedAt(ctx)
  40657. case whatsappchannel.FieldStatus:
  40658. return m.OldStatus(ctx)
  40659. case whatsappchannel.FieldDeletedAt:
  40660. return m.OldDeletedAt(ctx)
  40661. case whatsappchannel.FieldAk:
  40662. return m.OldAk(ctx)
  40663. case whatsappchannel.FieldSk:
  40664. return m.OldSk(ctx)
  40665. case whatsappchannel.FieldWaID:
  40666. return m.OldWaID(ctx)
  40667. case whatsappchannel.FieldWaName:
  40668. return m.OldWaName(ctx)
  40669. case whatsappchannel.FieldWabaID:
  40670. return m.OldWabaID(ctx)
  40671. case whatsappchannel.FieldBusinessID:
  40672. return m.OldBusinessID(ctx)
  40673. case whatsappchannel.FieldOrganizationID:
  40674. return m.OldOrganizationID(ctx)
  40675. case whatsappchannel.FieldVerifyAccount:
  40676. return m.OldVerifyAccount(ctx)
  40677. }
  40678. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  40679. }
  40680. // SetField sets the value of a field with the given name. It returns an error if
  40681. // the field is not defined in the schema, or if the type mismatched the field
  40682. // type.
  40683. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  40684. switch name {
  40685. case whatsappchannel.FieldCreatedAt:
  40686. v, ok := value.(time.Time)
  40687. if !ok {
  40688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40689. }
  40690. m.SetCreatedAt(v)
  40691. return nil
  40692. case whatsappchannel.FieldUpdatedAt:
  40693. v, ok := value.(time.Time)
  40694. if !ok {
  40695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40696. }
  40697. m.SetUpdatedAt(v)
  40698. return nil
  40699. case whatsappchannel.FieldStatus:
  40700. v, ok := value.(uint8)
  40701. if !ok {
  40702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40703. }
  40704. m.SetStatus(v)
  40705. return nil
  40706. case whatsappchannel.FieldDeletedAt:
  40707. v, ok := value.(time.Time)
  40708. if !ok {
  40709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40710. }
  40711. m.SetDeletedAt(v)
  40712. return nil
  40713. case whatsappchannel.FieldAk:
  40714. v, ok := value.(string)
  40715. if !ok {
  40716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40717. }
  40718. m.SetAk(v)
  40719. return nil
  40720. case whatsappchannel.FieldSk:
  40721. v, ok := value.(string)
  40722. if !ok {
  40723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40724. }
  40725. m.SetSk(v)
  40726. return nil
  40727. case whatsappchannel.FieldWaID:
  40728. v, ok := value.(string)
  40729. if !ok {
  40730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40731. }
  40732. m.SetWaID(v)
  40733. return nil
  40734. case whatsappchannel.FieldWaName:
  40735. v, ok := value.(string)
  40736. if !ok {
  40737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40738. }
  40739. m.SetWaName(v)
  40740. return nil
  40741. case whatsappchannel.FieldWabaID:
  40742. v, ok := value.(uint64)
  40743. if !ok {
  40744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40745. }
  40746. m.SetWabaID(v)
  40747. return nil
  40748. case whatsappchannel.FieldBusinessID:
  40749. v, ok := value.(uint64)
  40750. if !ok {
  40751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40752. }
  40753. m.SetBusinessID(v)
  40754. return nil
  40755. case whatsappchannel.FieldOrganizationID:
  40756. v, ok := value.(uint64)
  40757. if !ok {
  40758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40759. }
  40760. m.SetOrganizationID(v)
  40761. return nil
  40762. case whatsappchannel.FieldVerifyAccount:
  40763. v, ok := value.(string)
  40764. if !ok {
  40765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40766. }
  40767. m.SetVerifyAccount(v)
  40768. return nil
  40769. }
  40770. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40771. }
  40772. // AddedFields returns all numeric fields that were incremented/decremented during
  40773. // this mutation.
  40774. func (m *WhatsappChannelMutation) AddedFields() []string {
  40775. var fields []string
  40776. if m.addstatus != nil {
  40777. fields = append(fields, whatsappchannel.FieldStatus)
  40778. }
  40779. if m.addwaba_id != nil {
  40780. fields = append(fields, whatsappchannel.FieldWabaID)
  40781. }
  40782. if m.addbusiness_id != nil {
  40783. fields = append(fields, whatsappchannel.FieldBusinessID)
  40784. }
  40785. if m.addorganization_id != nil {
  40786. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40787. }
  40788. return fields
  40789. }
  40790. // AddedField returns the numeric value that was incremented/decremented on a field
  40791. // with the given name. The second boolean return value indicates that this field
  40792. // was not set, or was not defined in the schema.
  40793. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  40794. switch name {
  40795. case whatsappchannel.FieldStatus:
  40796. return m.AddedStatus()
  40797. case whatsappchannel.FieldWabaID:
  40798. return m.AddedWabaID()
  40799. case whatsappchannel.FieldBusinessID:
  40800. return m.AddedBusinessID()
  40801. case whatsappchannel.FieldOrganizationID:
  40802. return m.AddedOrganizationID()
  40803. }
  40804. return nil, false
  40805. }
  40806. // AddField adds the value to the field with the given name. It returns an error if
  40807. // the field is not defined in the schema, or if the type mismatched the field
  40808. // type.
  40809. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  40810. switch name {
  40811. case whatsappchannel.FieldStatus:
  40812. v, ok := value.(int8)
  40813. if !ok {
  40814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40815. }
  40816. m.AddStatus(v)
  40817. return nil
  40818. case whatsappchannel.FieldWabaID:
  40819. v, ok := value.(int64)
  40820. if !ok {
  40821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40822. }
  40823. m.AddWabaID(v)
  40824. return nil
  40825. case whatsappchannel.FieldBusinessID:
  40826. v, ok := value.(int64)
  40827. if !ok {
  40828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40829. }
  40830. m.AddBusinessID(v)
  40831. return nil
  40832. case whatsappchannel.FieldOrganizationID:
  40833. v, ok := value.(int64)
  40834. if !ok {
  40835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40836. }
  40837. m.AddOrganizationID(v)
  40838. return nil
  40839. }
  40840. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  40841. }
  40842. // ClearedFields returns all nullable fields that were cleared during this
  40843. // mutation.
  40844. func (m *WhatsappChannelMutation) ClearedFields() []string {
  40845. var fields []string
  40846. if m.FieldCleared(whatsappchannel.FieldStatus) {
  40847. fields = append(fields, whatsappchannel.FieldStatus)
  40848. }
  40849. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  40850. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40851. }
  40852. if m.FieldCleared(whatsappchannel.FieldAk) {
  40853. fields = append(fields, whatsappchannel.FieldAk)
  40854. }
  40855. if m.FieldCleared(whatsappchannel.FieldWaID) {
  40856. fields = append(fields, whatsappchannel.FieldWaID)
  40857. }
  40858. if m.FieldCleared(whatsappchannel.FieldWaName) {
  40859. fields = append(fields, whatsappchannel.FieldWaName)
  40860. }
  40861. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  40862. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40863. }
  40864. return fields
  40865. }
  40866. // FieldCleared returns a boolean indicating if a field with the given name was
  40867. // cleared in this mutation.
  40868. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  40869. _, ok := m.clearedFields[name]
  40870. return ok
  40871. }
  40872. // ClearField clears the value of the field with the given name. It returns an
  40873. // error if the field is not defined in the schema.
  40874. func (m *WhatsappChannelMutation) ClearField(name string) error {
  40875. switch name {
  40876. case whatsappchannel.FieldStatus:
  40877. m.ClearStatus()
  40878. return nil
  40879. case whatsappchannel.FieldDeletedAt:
  40880. m.ClearDeletedAt()
  40881. return nil
  40882. case whatsappchannel.FieldAk:
  40883. m.ClearAk()
  40884. return nil
  40885. case whatsappchannel.FieldWaID:
  40886. m.ClearWaID()
  40887. return nil
  40888. case whatsappchannel.FieldWaName:
  40889. m.ClearWaName()
  40890. return nil
  40891. case whatsappchannel.FieldOrganizationID:
  40892. m.ClearOrganizationID()
  40893. return nil
  40894. }
  40895. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  40896. }
  40897. // ResetField resets all changes in the mutation for the field with the given name.
  40898. // It returns an error if the field is not defined in the schema.
  40899. func (m *WhatsappChannelMutation) ResetField(name string) error {
  40900. switch name {
  40901. case whatsappchannel.FieldCreatedAt:
  40902. m.ResetCreatedAt()
  40903. return nil
  40904. case whatsappchannel.FieldUpdatedAt:
  40905. m.ResetUpdatedAt()
  40906. return nil
  40907. case whatsappchannel.FieldStatus:
  40908. m.ResetStatus()
  40909. return nil
  40910. case whatsappchannel.FieldDeletedAt:
  40911. m.ResetDeletedAt()
  40912. return nil
  40913. case whatsappchannel.FieldAk:
  40914. m.ResetAk()
  40915. return nil
  40916. case whatsappchannel.FieldSk:
  40917. m.ResetSk()
  40918. return nil
  40919. case whatsappchannel.FieldWaID:
  40920. m.ResetWaID()
  40921. return nil
  40922. case whatsappchannel.FieldWaName:
  40923. m.ResetWaName()
  40924. return nil
  40925. case whatsappchannel.FieldWabaID:
  40926. m.ResetWabaID()
  40927. return nil
  40928. case whatsappchannel.FieldBusinessID:
  40929. m.ResetBusinessID()
  40930. return nil
  40931. case whatsappchannel.FieldOrganizationID:
  40932. m.ResetOrganizationID()
  40933. return nil
  40934. case whatsappchannel.FieldVerifyAccount:
  40935. m.ResetVerifyAccount()
  40936. return nil
  40937. }
  40938. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40939. }
  40940. // AddedEdges returns all edge names that were set/added in this mutation.
  40941. func (m *WhatsappChannelMutation) AddedEdges() []string {
  40942. edges := make([]string, 0, 0)
  40943. return edges
  40944. }
  40945. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40946. // name in this mutation.
  40947. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  40948. return nil
  40949. }
  40950. // RemovedEdges returns all edge names that were removed in this mutation.
  40951. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  40952. edges := make([]string, 0, 0)
  40953. return edges
  40954. }
  40955. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40956. // the given name in this mutation.
  40957. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  40958. return nil
  40959. }
  40960. // ClearedEdges returns all edge names that were cleared in this mutation.
  40961. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  40962. edges := make([]string, 0, 0)
  40963. return edges
  40964. }
  40965. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40966. // was cleared in this mutation.
  40967. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  40968. return false
  40969. }
  40970. // ClearEdge clears the value of the edge with the given name. It returns an error
  40971. // if that edge is not defined in the schema.
  40972. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  40973. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  40974. }
  40975. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40976. // It returns an error if the edge is not defined in the schema.
  40977. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  40978. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  40979. }
  40980. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  40981. type WorkExperienceMutation struct {
  40982. config
  40983. op Op
  40984. typ string
  40985. id *uint64
  40986. created_at *time.Time
  40987. updated_at *time.Time
  40988. deleted_at *time.Time
  40989. start_date *time.Time
  40990. end_date *time.Time
  40991. company *string
  40992. experience *string
  40993. organization_id *uint64
  40994. addorganization_id *int64
  40995. clearedFields map[string]struct{}
  40996. employee *uint64
  40997. clearedemployee bool
  40998. done bool
  40999. oldValue func(context.Context) (*WorkExperience, error)
  41000. predicates []predicate.WorkExperience
  41001. }
  41002. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  41003. // workexperienceOption allows management of the mutation configuration using functional options.
  41004. type workexperienceOption func(*WorkExperienceMutation)
  41005. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  41006. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  41007. m := &WorkExperienceMutation{
  41008. config: c,
  41009. op: op,
  41010. typ: TypeWorkExperience,
  41011. clearedFields: make(map[string]struct{}),
  41012. }
  41013. for _, opt := range opts {
  41014. opt(m)
  41015. }
  41016. return m
  41017. }
  41018. // withWorkExperienceID sets the ID field of the mutation.
  41019. func withWorkExperienceID(id uint64) workexperienceOption {
  41020. return func(m *WorkExperienceMutation) {
  41021. var (
  41022. err error
  41023. once sync.Once
  41024. value *WorkExperience
  41025. )
  41026. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  41027. once.Do(func() {
  41028. if m.done {
  41029. err = errors.New("querying old values post mutation is not allowed")
  41030. } else {
  41031. value, err = m.Client().WorkExperience.Get(ctx, id)
  41032. }
  41033. })
  41034. return value, err
  41035. }
  41036. m.id = &id
  41037. }
  41038. }
  41039. // withWorkExperience sets the old WorkExperience of the mutation.
  41040. func withWorkExperience(node *WorkExperience) workexperienceOption {
  41041. return func(m *WorkExperienceMutation) {
  41042. m.oldValue = func(context.Context) (*WorkExperience, error) {
  41043. return node, nil
  41044. }
  41045. m.id = &node.ID
  41046. }
  41047. }
  41048. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41049. // executed in a transaction (ent.Tx), a transactional client is returned.
  41050. func (m WorkExperienceMutation) Client() *Client {
  41051. client := &Client{config: m.config}
  41052. client.init()
  41053. return client
  41054. }
  41055. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41056. // it returns an error otherwise.
  41057. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  41058. if _, ok := m.driver.(*txDriver); !ok {
  41059. return nil, errors.New("ent: mutation is not running in a transaction")
  41060. }
  41061. tx := &Tx{config: m.config}
  41062. tx.init()
  41063. return tx, nil
  41064. }
  41065. // SetID sets the value of the id field. Note that this
  41066. // operation is only accepted on creation of WorkExperience entities.
  41067. func (m *WorkExperienceMutation) SetID(id uint64) {
  41068. m.id = &id
  41069. }
  41070. // ID returns the ID value in the mutation. Note that the ID is only available
  41071. // if it was provided to the builder or after it was returned from the database.
  41072. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  41073. if m.id == nil {
  41074. return
  41075. }
  41076. return *m.id, true
  41077. }
  41078. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41079. // That means, if the mutation is applied within a transaction with an isolation level such
  41080. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41081. // or updated by the mutation.
  41082. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  41083. switch {
  41084. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41085. id, exists := m.ID()
  41086. if exists {
  41087. return []uint64{id}, nil
  41088. }
  41089. fallthrough
  41090. case m.op.Is(OpUpdate | OpDelete):
  41091. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  41092. default:
  41093. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41094. }
  41095. }
  41096. // SetCreatedAt sets the "created_at" field.
  41097. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  41098. m.created_at = &t
  41099. }
  41100. // CreatedAt returns the value of the "created_at" field in the mutation.
  41101. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  41102. v := m.created_at
  41103. if v == nil {
  41104. return
  41105. }
  41106. return *v, true
  41107. }
  41108. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  41109. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41111. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41112. if !m.op.Is(OpUpdateOne) {
  41113. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41114. }
  41115. if m.id == nil || m.oldValue == nil {
  41116. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41117. }
  41118. oldValue, err := m.oldValue(ctx)
  41119. if err != nil {
  41120. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41121. }
  41122. return oldValue.CreatedAt, nil
  41123. }
  41124. // ResetCreatedAt resets all changes to the "created_at" field.
  41125. func (m *WorkExperienceMutation) ResetCreatedAt() {
  41126. m.created_at = nil
  41127. }
  41128. // SetUpdatedAt sets the "updated_at" field.
  41129. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  41130. m.updated_at = &t
  41131. }
  41132. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41133. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  41134. v := m.updated_at
  41135. if v == nil {
  41136. return
  41137. }
  41138. return *v, true
  41139. }
  41140. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  41141. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41143. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41144. if !m.op.Is(OpUpdateOne) {
  41145. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41146. }
  41147. if m.id == nil || m.oldValue == nil {
  41148. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41149. }
  41150. oldValue, err := m.oldValue(ctx)
  41151. if err != nil {
  41152. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41153. }
  41154. return oldValue.UpdatedAt, nil
  41155. }
  41156. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41157. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  41158. m.updated_at = nil
  41159. }
  41160. // SetDeletedAt sets the "deleted_at" field.
  41161. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  41162. m.deleted_at = &t
  41163. }
  41164. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41165. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  41166. v := m.deleted_at
  41167. if v == nil {
  41168. return
  41169. }
  41170. return *v, true
  41171. }
  41172. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  41173. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41175. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41176. if !m.op.Is(OpUpdateOne) {
  41177. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41178. }
  41179. if m.id == nil || m.oldValue == nil {
  41180. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41181. }
  41182. oldValue, err := m.oldValue(ctx)
  41183. if err != nil {
  41184. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41185. }
  41186. return oldValue.DeletedAt, nil
  41187. }
  41188. // ClearDeletedAt clears the value of the "deleted_at" field.
  41189. func (m *WorkExperienceMutation) ClearDeletedAt() {
  41190. m.deleted_at = nil
  41191. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  41192. }
  41193. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41194. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  41195. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  41196. return ok
  41197. }
  41198. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41199. func (m *WorkExperienceMutation) ResetDeletedAt() {
  41200. m.deleted_at = nil
  41201. delete(m.clearedFields, workexperience.FieldDeletedAt)
  41202. }
  41203. // SetEmployeeID sets the "employee_id" field.
  41204. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  41205. m.employee = &u
  41206. }
  41207. // EmployeeID returns the value of the "employee_id" field in the mutation.
  41208. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  41209. v := m.employee
  41210. if v == nil {
  41211. return
  41212. }
  41213. return *v, true
  41214. }
  41215. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  41216. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41218. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  41219. if !m.op.Is(OpUpdateOne) {
  41220. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  41221. }
  41222. if m.id == nil || m.oldValue == nil {
  41223. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  41224. }
  41225. oldValue, err := m.oldValue(ctx)
  41226. if err != nil {
  41227. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  41228. }
  41229. return oldValue.EmployeeID, nil
  41230. }
  41231. // ResetEmployeeID resets all changes to the "employee_id" field.
  41232. func (m *WorkExperienceMutation) ResetEmployeeID() {
  41233. m.employee = nil
  41234. }
  41235. // SetStartDate sets the "start_date" field.
  41236. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  41237. m.start_date = &t
  41238. }
  41239. // StartDate returns the value of the "start_date" field in the mutation.
  41240. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  41241. v := m.start_date
  41242. if v == nil {
  41243. return
  41244. }
  41245. return *v, true
  41246. }
  41247. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  41248. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41250. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  41251. if !m.op.Is(OpUpdateOne) {
  41252. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  41253. }
  41254. if m.id == nil || m.oldValue == nil {
  41255. return v, errors.New("OldStartDate requires an ID field in the mutation")
  41256. }
  41257. oldValue, err := m.oldValue(ctx)
  41258. if err != nil {
  41259. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  41260. }
  41261. return oldValue.StartDate, nil
  41262. }
  41263. // ResetStartDate resets all changes to the "start_date" field.
  41264. func (m *WorkExperienceMutation) ResetStartDate() {
  41265. m.start_date = nil
  41266. }
  41267. // SetEndDate sets the "end_date" field.
  41268. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  41269. m.end_date = &t
  41270. }
  41271. // EndDate returns the value of the "end_date" field in the mutation.
  41272. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  41273. v := m.end_date
  41274. if v == nil {
  41275. return
  41276. }
  41277. return *v, true
  41278. }
  41279. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  41280. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41282. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  41283. if !m.op.Is(OpUpdateOne) {
  41284. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  41285. }
  41286. if m.id == nil || m.oldValue == nil {
  41287. return v, errors.New("OldEndDate requires an ID field in the mutation")
  41288. }
  41289. oldValue, err := m.oldValue(ctx)
  41290. if err != nil {
  41291. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  41292. }
  41293. return oldValue.EndDate, nil
  41294. }
  41295. // ResetEndDate resets all changes to the "end_date" field.
  41296. func (m *WorkExperienceMutation) ResetEndDate() {
  41297. m.end_date = nil
  41298. }
  41299. // SetCompany sets the "company" field.
  41300. func (m *WorkExperienceMutation) SetCompany(s string) {
  41301. m.company = &s
  41302. }
  41303. // Company returns the value of the "company" field in the mutation.
  41304. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  41305. v := m.company
  41306. if v == nil {
  41307. return
  41308. }
  41309. return *v, true
  41310. }
  41311. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  41312. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41314. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  41315. if !m.op.Is(OpUpdateOne) {
  41316. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  41317. }
  41318. if m.id == nil || m.oldValue == nil {
  41319. return v, errors.New("OldCompany requires an ID field in the mutation")
  41320. }
  41321. oldValue, err := m.oldValue(ctx)
  41322. if err != nil {
  41323. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  41324. }
  41325. return oldValue.Company, nil
  41326. }
  41327. // ResetCompany resets all changes to the "company" field.
  41328. func (m *WorkExperienceMutation) ResetCompany() {
  41329. m.company = nil
  41330. }
  41331. // SetExperience sets the "experience" field.
  41332. func (m *WorkExperienceMutation) SetExperience(s string) {
  41333. m.experience = &s
  41334. }
  41335. // Experience returns the value of the "experience" field in the mutation.
  41336. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  41337. v := m.experience
  41338. if v == nil {
  41339. return
  41340. }
  41341. return *v, true
  41342. }
  41343. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  41344. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41346. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  41347. if !m.op.Is(OpUpdateOne) {
  41348. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  41349. }
  41350. if m.id == nil || m.oldValue == nil {
  41351. return v, errors.New("OldExperience requires an ID field in the mutation")
  41352. }
  41353. oldValue, err := m.oldValue(ctx)
  41354. if err != nil {
  41355. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  41356. }
  41357. return oldValue.Experience, nil
  41358. }
  41359. // ResetExperience resets all changes to the "experience" field.
  41360. func (m *WorkExperienceMutation) ResetExperience() {
  41361. m.experience = nil
  41362. }
  41363. // SetOrganizationID sets the "organization_id" field.
  41364. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  41365. m.organization_id = &u
  41366. m.addorganization_id = nil
  41367. }
  41368. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41369. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  41370. v := m.organization_id
  41371. if v == nil {
  41372. return
  41373. }
  41374. return *v, true
  41375. }
  41376. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  41377. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41379. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41380. if !m.op.Is(OpUpdateOne) {
  41381. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41382. }
  41383. if m.id == nil || m.oldValue == nil {
  41384. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41385. }
  41386. oldValue, err := m.oldValue(ctx)
  41387. if err != nil {
  41388. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41389. }
  41390. return oldValue.OrganizationID, nil
  41391. }
  41392. // AddOrganizationID adds u to the "organization_id" field.
  41393. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  41394. if m.addorganization_id != nil {
  41395. *m.addorganization_id += u
  41396. } else {
  41397. m.addorganization_id = &u
  41398. }
  41399. }
  41400. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41401. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  41402. v := m.addorganization_id
  41403. if v == nil {
  41404. return
  41405. }
  41406. return *v, true
  41407. }
  41408. // ResetOrganizationID resets all changes to the "organization_id" field.
  41409. func (m *WorkExperienceMutation) ResetOrganizationID() {
  41410. m.organization_id = nil
  41411. m.addorganization_id = nil
  41412. }
  41413. // ClearEmployee clears the "employee" edge to the Employee entity.
  41414. func (m *WorkExperienceMutation) ClearEmployee() {
  41415. m.clearedemployee = true
  41416. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  41417. }
  41418. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  41419. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  41420. return m.clearedemployee
  41421. }
  41422. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  41423. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41424. // EmployeeID instead. It exists only for internal usage by the builders.
  41425. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  41426. if id := m.employee; id != nil {
  41427. ids = append(ids, *id)
  41428. }
  41429. return
  41430. }
  41431. // ResetEmployee resets all changes to the "employee" edge.
  41432. func (m *WorkExperienceMutation) ResetEmployee() {
  41433. m.employee = nil
  41434. m.clearedemployee = false
  41435. }
  41436. // Where appends a list predicates to the WorkExperienceMutation builder.
  41437. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  41438. m.predicates = append(m.predicates, ps...)
  41439. }
  41440. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  41441. // users can use type-assertion to append predicates that do not depend on any generated package.
  41442. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  41443. p := make([]predicate.WorkExperience, len(ps))
  41444. for i := range ps {
  41445. p[i] = ps[i]
  41446. }
  41447. m.Where(p...)
  41448. }
  41449. // Op returns the operation name.
  41450. func (m *WorkExperienceMutation) Op() Op {
  41451. return m.op
  41452. }
  41453. // SetOp allows setting the mutation operation.
  41454. func (m *WorkExperienceMutation) SetOp(op Op) {
  41455. m.op = op
  41456. }
  41457. // Type returns the node type of this mutation (WorkExperience).
  41458. func (m *WorkExperienceMutation) Type() string {
  41459. return m.typ
  41460. }
  41461. // Fields returns all fields that were changed during this mutation. Note that in
  41462. // order to get all numeric fields that were incremented/decremented, call
  41463. // AddedFields().
  41464. func (m *WorkExperienceMutation) Fields() []string {
  41465. fields := make([]string, 0, 9)
  41466. if m.created_at != nil {
  41467. fields = append(fields, workexperience.FieldCreatedAt)
  41468. }
  41469. if m.updated_at != nil {
  41470. fields = append(fields, workexperience.FieldUpdatedAt)
  41471. }
  41472. if m.deleted_at != nil {
  41473. fields = append(fields, workexperience.FieldDeletedAt)
  41474. }
  41475. if m.employee != nil {
  41476. fields = append(fields, workexperience.FieldEmployeeID)
  41477. }
  41478. if m.start_date != nil {
  41479. fields = append(fields, workexperience.FieldStartDate)
  41480. }
  41481. if m.end_date != nil {
  41482. fields = append(fields, workexperience.FieldEndDate)
  41483. }
  41484. if m.company != nil {
  41485. fields = append(fields, workexperience.FieldCompany)
  41486. }
  41487. if m.experience != nil {
  41488. fields = append(fields, workexperience.FieldExperience)
  41489. }
  41490. if m.organization_id != nil {
  41491. fields = append(fields, workexperience.FieldOrganizationID)
  41492. }
  41493. return fields
  41494. }
  41495. // Field returns the value of a field with the given name. The second boolean
  41496. // return value indicates that this field was not set, or was not defined in the
  41497. // schema.
  41498. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  41499. switch name {
  41500. case workexperience.FieldCreatedAt:
  41501. return m.CreatedAt()
  41502. case workexperience.FieldUpdatedAt:
  41503. return m.UpdatedAt()
  41504. case workexperience.FieldDeletedAt:
  41505. return m.DeletedAt()
  41506. case workexperience.FieldEmployeeID:
  41507. return m.EmployeeID()
  41508. case workexperience.FieldStartDate:
  41509. return m.StartDate()
  41510. case workexperience.FieldEndDate:
  41511. return m.EndDate()
  41512. case workexperience.FieldCompany:
  41513. return m.Company()
  41514. case workexperience.FieldExperience:
  41515. return m.Experience()
  41516. case workexperience.FieldOrganizationID:
  41517. return m.OrganizationID()
  41518. }
  41519. return nil, false
  41520. }
  41521. // OldField returns the old value of the field from the database. An error is
  41522. // returned if the mutation operation is not UpdateOne, or the query to the
  41523. // database failed.
  41524. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41525. switch name {
  41526. case workexperience.FieldCreatedAt:
  41527. return m.OldCreatedAt(ctx)
  41528. case workexperience.FieldUpdatedAt:
  41529. return m.OldUpdatedAt(ctx)
  41530. case workexperience.FieldDeletedAt:
  41531. return m.OldDeletedAt(ctx)
  41532. case workexperience.FieldEmployeeID:
  41533. return m.OldEmployeeID(ctx)
  41534. case workexperience.FieldStartDate:
  41535. return m.OldStartDate(ctx)
  41536. case workexperience.FieldEndDate:
  41537. return m.OldEndDate(ctx)
  41538. case workexperience.FieldCompany:
  41539. return m.OldCompany(ctx)
  41540. case workexperience.FieldExperience:
  41541. return m.OldExperience(ctx)
  41542. case workexperience.FieldOrganizationID:
  41543. return m.OldOrganizationID(ctx)
  41544. }
  41545. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  41546. }
  41547. // SetField sets the value of a field with the given name. It returns an error if
  41548. // the field is not defined in the schema, or if the type mismatched the field
  41549. // type.
  41550. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  41551. switch name {
  41552. case workexperience.FieldCreatedAt:
  41553. v, ok := value.(time.Time)
  41554. if !ok {
  41555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41556. }
  41557. m.SetCreatedAt(v)
  41558. return nil
  41559. case workexperience.FieldUpdatedAt:
  41560. v, ok := value.(time.Time)
  41561. if !ok {
  41562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41563. }
  41564. m.SetUpdatedAt(v)
  41565. return nil
  41566. case workexperience.FieldDeletedAt:
  41567. v, ok := value.(time.Time)
  41568. if !ok {
  41569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41570. }
  41571. m.SetDeletedAt(v)
  41572. return nil
  41573. case workexperience.FieldEmployeeID:
  41574. v, ok := value.(uint64)
  41575. if !ok {
  41576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41577. }
  41578. m.SetEmployeeID(v)
  41579. return nil
  41580. case workexperience.FieldStartDate:
  41581. v, ok := value.(time.Time)
  41582. if !ok {
  41583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41584. }
  41585. m.SetStartDate(v)
  41586. return nil
  41587. case workexperience.FieldEndDate:
  41588. v, ok := value.(time.Time)
  41589. if !ok {
  41590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41591. }
  41592. m.SetEndDate(v)
  41593. return nil
  41594. case workexperience.FieldCompany:
  41595. v, ok := value.(string)
  41596. if !ok {
  41597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41598. }
  41599. m.SetCompany(v)
  41600. return nil
  41601. case workexperience.FieldExperience:
  41602. v, ok := value.(string)
  41603. if !ok {
  41604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41605. }
  41606. m.SetExperience(v)
  41607. return nil
  41608. case workexperience.FieldOrganizationID:
  41609. v, ok := value.(uint64)
  41610. if !ok {
  41611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41612. }
  41613. m.SetOrganizationID(v)
  41614. return nil
  41615. }
  41616. return fmt.Errorf("unknown WorkExperience field %s", name)
  41617. }
  41618. // AddedFields returns all numeric fields that were incremented/decremented during
  41619. // this mutation.
  41620. func (m *WorkExperienceMutation) AddedFields() []string {
  41621. var fields []string
  41622. if m.addorganization_id != nil {
  41623. fields = append(fields, workexperience.FieldOrganizationID)
  41624. }
  41625. return fields
  41626. }
  41627. // AddedField returns the numeric value that was incremented/decremented on a field
  41628. // with the given name. The second boolean return value indicates that this field
  41629. // was not set, or was not defined in the schema.
  41630. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  41631. switch name {
  41632. case workexperience.FieldOrganizationID:
  41633. return m.AddedOrganizationID()
  41634. }
  41635. return nil, false
  41636. }
  41637. // AddField adds the value to the field with the given name. It returns an error if
  41638. // the field is not defined in the schema, or if the type mismatched the field
  41639. // type.
  41640. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  41641. switch name {
  41642. case workexperience.FieldOrganizationID:
  41643. v, ok := value.(int64)
  41644. if !ok {
  41645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41646. }
  41647. m.AddOrganizationID(v)
  41648. return nil
  41649. }
  41650. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  41651. }
  41652. // ClearedFields returns all nullable fields that were cleared during this
  41653. // mutation.
  41654. func (m *WorkExperienceMutation) ClearedFields() []string {
  41655. var fields []string
  41656. if m.FieldCleared(workexperience.FieldDeletedAt) {
  41657. fields = append(fields, workexperience.FieldDeletedAt)
  41658. }
  41659. return fields
  41660. }
  41661. // FieldCleared returns a boolean indicating if a field with the given name was
  41662. // cleared in this mutation.
  41663. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  41664. _, ok := m.clearedFields[name]
  41665. return ok
  41666. }
  41667. // ClearField clears the value of the field with the given name. It returns an
  41668. // error if the field is not defined in the schema.
  41669. func (m *WorkExperienceMutation) ClearField(name string) error {
  41670. switch name {
  41671. case workexperience.FieldDeletedAt:
  41672. m.ClearDeletedAt()
  41673. return nil
  41674. }
  41675. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  41676. }
  41677. // ResetField resets all changes in the mutation for the field with the given name.
  41678. // It returns an error if the field is not defined in the schema.
  41679. func (m *WorkExperienceMutation) ResetField(name string) error {
  41680. switch name {
  41681. case workexperience.FieldCreatedAt:
  41682. m.ResetCreatedAt()
  41683. return nil
  41684. case workexperience.FieldUpdatedAt:
  41685. m.ResetUpdatedAt()
  41686. return nil
  41687. case workexperience.FieldDeletedAt:
  41688. m.ResetDeletedAt()
  41689. return nil
  41690. case workexperience.FieldEmployeeID:
  41691. m.ResetEmployeeID()
  41692. return nil
  41693. case workexperience.FieldStartDate:
  41694. m.ResetStartDate()
  41695. return nil
  41696. case workexperience.FieldEndDate:
  41697. m.ResetEndDate()
  41698. return nil
  41699. case workexperience.FieldCompany:
  41700. m.ResetCompany()
  41701. return nil
  41702. case workexperience.FieldExperience:
  41703. m.ResetExperience()
  41704. return nil
  41705. case workexperience.FieldOrganizationID:
  41706. m.ResetOrganizationID()
  41707. return nil
  41708. }
  41709. return fmt.Errorf("unknown WorkExperience field %s", name)
  41710. }
  41711. // AddedEdges returns all edge names that were set/added in this mutation.
  41712. func (m *WorkExperienceMutation) AddedEdges() []string {
  41713. edges := make([]string, 0, 1)
  41714. if m.employee != nil {
  41715. edges = append(edges, workexperience.EdgeEmployee)
  41716. }
  41717. return edges
  41718. }
  41719. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41720. // name in this mutation.
  41721. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  41722. switch name {
  41723. case workexperience.EdgeEmployee:
  41724. if id := m.employee; id != nil {
  41725. return []ent.Value{*id}
  41726. }
  41727. }
  41728. return nil
  41729. }
  41730. // RemovedEdges returns all edge names that were removed in this mutation.
  41731. func (m *WorkExperienceMutation) RemovedEdges() []string {
  41732. edges := make([]string, 0, 1)
  41733. return edges
  41734. }
  41735. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41736. // the given name in this mutation.
  41737. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  41738. return nil
  41739. }
  41740. // ClearedEdges returns all edge names that were cleared in this mutation.
  41741. func (m *WorkExperienceMutation) ClearedEdges() []string {
  41742. edges := make([]string, 0, 1)
  41743. if m.clearedemployee {
  41744. edges = append(edges, workexperience.EdgeEmployee)
  41745. }
  41746. return edges
  41747. }
  41748. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41749. // was cleared in this mutation.
  41750. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  41751. switch name {
  41752. case workexperience.EdgeEmployee:
  41753. return m.clearedemployee
  41754. }
  41755. return false
  41756. }
  41757. // ClearEdge clears the value of the edge with the given name. It returns an error
  41758. // if that edge is not defined in the schema.
  41759. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  41760. switch name {
  41761. case workexperience.EdgeEmployee:
  41762. m.ClearEmployee()
  41763. return nil
  41764. }
  41765. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  41766. }
  41767. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41768. // It returns an error if the edge is not defined in the schema.
  41769. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  41770. switch name {
  41771. case workexperience.EdgeEmployee:
  41772. m.ResetEmployee()
  41773. return nil
  41774. }
  41775. return fmt.Errorf("unknown WorkExperience edge %s", name)
  41776. }
  41777. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  41778. type WpChatroomMutation struct {
  41779. config
  41780. op Op
  41781. typ string
  41782. id *uint64
  41783. created_at *time.Time
  41784. updated_at *time.Time
  41785. status *uint8
  41786. addstatus *int8
  41787. wx_wxid *string
  41788. chatroom_id *string
  41789. nickname *string
  41790. owner *string
  41791. avatar *string
  41792. member_list *[]string
  41793. appendmember_list []string
  41794. clearedFields map[string]struct{}
  41795. done bool
  41796. oldValue func(context.Context) (*WpChatroom, error)
  41797. predicates []predicate.WpChatroom
  41798. }
  41799. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  41800. // wpchatroomOption allows management of the mutation configuration using functional options.
  41801. type wpchatroomOption func(*WpChatroomMutation)
  41802. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  41803. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  41804. m := &WpChatroomMutation{
  41805. config: c,
  41806. op: op,
  41807. typ: TypeWpChatroom,
  41808. clearedFields: make(map[string]struct{}),
  41809. }
  41810. for _, opt := range opts {
  41811. opt(m)
  41812. }
  41813. return m
  41814. }
  41815. // withWpChatroomID sets the ID field of the mutation.
  41816. func withWpChatroomID(id uint64) wpchatroomOption {
  41817. return func(m *WpChatroomMutation) {
  41818. var (
  41819. err error
  41820. once sync.Once
  41821. value *WpChatroom
  41822. )
  41823. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  41824. once.Do(func() {
  41825. if m.done {
  41826. err = errors.New("querying old values post mutation is not allowed")
  41827. } else {
  41828. value, err = m.Client().WpChatroom.Get(ctx, id)
  41829. }
  41830. })
  41831. return value, err
  41832. }
  41833. m.id = &id
  41834. }
  41835. }
  41836. // withWpChatroom sets the old WpChatroom of the mutation.
  41837. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  41838. return func(m *WpChatroomMutation) {
  41839. m.oldValue = func(context.Context) (*WpChatroom, error) {
  41840. return node, nil
  41841. }
  41842. m.id = &node.ID
  41843. }
  41844. }
  41845. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41846. // executed in a transaction (ent.Tx), a transactional client is returned.
  41847. func (m WpChatroomMutation) Client() *Client {
  41848. client := &Client{config: m.config}
  41849. client.init()
  41850. return client
  41851. }
  41852. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41853. // it returns an error otherwise.
  41854. func (m WpChatroomMutation) Tx() (*Tx, error) {
  41855. if _, ok := m.driver.(*txDriver); !ok {
  41856. return nil, errors.New("ent: mutation is not running in a transaction")
  41857. }
  41858. tx := &Tx{config: m.config}
  41859. tx.init()
  41860. return tx, nil
  41861. }
  41862. // SetID sets the value of the id field. Note that this
  41863. // operation is only accepted on creation of WpChatroom entities.
  41864. func (m *WpChatroomMutation) SetID(id uint64) {
  41865. m.id = &id
  41866. }
  41867. // ID returns the ID value in the mutation. Note that the ID is only available
  41868. // if it was provided to the builder or after it was returned from the database.
  41869. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  41870. if m.id == nil {
  41871. return
  41872. }
  41873. return *m.id, true
  41874. }
  41875. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41876. // That means, if the mutation is applied within a transaction with an isolation level such
  41877. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41878. // or updated by the mutation.
  41879. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  41880. switch {
  41881. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41882. id, exists := m.ID()
  41883. if exists {
  41884. return []uint64{id}, nil
  41885. }
  41886. fallthrough
  41887. case m.op.Is(OpUpdate | OpDelete):
  41888. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  41889. default:
  41890. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41891. }
  41892. }
  41893. // SetCreatedAt sets the "created_at" field.
  41894. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  41895. m.created_at = &t
  41896. }
  41897. // CreatedAt returns the value of the "created_at" field in the mutation.
  41898. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  41899. v := m.created_at
  41900. if v == nil {
  41901. return
  41902. }
  41903. return *v, true
  41904. }
  41905. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  41906. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41908. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41909. if !m.op.Is(OpUpdateOne) {
  41910. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41911. }
  41912. if m.id == nil || m.oldValue == nil {
  41913. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41914. }
  41915. oldValue, err := m.oldValue(ctx)
  41916. if err != nil {
  41917. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41918. }
  41919. return oldValue.CreatedAt, nil
  41920. }
  41921. // ResetCreatedAt resets all changes to the "created_at" field.
  41922. func (m *WpChatroomMutation) ResetCreatedAt() {
  41923. m.created_at = nil
  41924. }
  41925. // SetUpdatedAt sets the "updated_at" field.
  41926. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  41927. m.updated_at = &t
  41928. }
  41929. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41930. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  41931. v := m.updated_at
  41932. if v == nil {
  41933. return
  41934. }
  41935. return *v, true
  41936. }
  41937. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  41938. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41940. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41941. if !m.op.Is(OpUpdateOne) {
  41942. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41943. }
  41944. if m.id == nil || m.oldValue == nil {
  41945. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41946. }
  41947. oldValue, err := m.oldValue(ctx)
  41948. if err != nil {
  41949. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41950. }
  41951. return oldValue.UpdatedAt, nil
  41952. }
  41953. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41954. func (m *WpChatroomMutation) ResetUpdatedAt() {
  41955. m.updated_at = nil
  41956. }
  41957. // SetStatus sets the "status" field.
  41958. func (m *WpChatroomMutation) SetStatus(u uint8) {
  41959. m.status = &u
  41960. m.addstatus = nil
  41961. }
  41962. // Status returns the value of the "status" field in the mutation.
  41963. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  41964. v := m.status
  41965. if v == nil {
  41966. return
  41967. }
  41968. return *v, true
  41969. }
  41970. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  41971. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41973. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41974. if !m.op.Is(OpUpdateOne) {
  41975. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41976. }
  41977. if m.id == nil || m.oldValue == nil {
  41978. return v, errors.New("OldStatus requires an ID field in the mutation")
  41979. }
  41980. oldValue, err := m.oldValue(ctx)
  41981. if err != nil {
  41982. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41983. }
  41984. return oldValue.Status, nil
  41985. }
  41986. // AddStatus adds u to the "status" field.
  41987. func (m *WpChatroomMutation) AddStatus(u int8) {
  41988. if m.addstatus != nil {
  41989. *m.addstatus += u
  41990. } else {
  41991. m.addstatus = &u
  41992. }
  41993. }
  41994. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41995. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  41996. v := m.addstatus
  41997. if v == nil {
  41998. return
  41999. }
  42000. return *v, true
  42001. }
  42002. // ClearStatus clears the value of the "status" field.
  42003. func (m *WpChatroomMutation) ClearStatus() {
  42004. m.status = nil
  42005. m.addstatus = nil
  42006. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  42007. }
  42008. // StatusCleared returns if the "status" field was cleared in this mutation.
  42009. func (m *WpChatroomMutation) StatusCleared() bool {
  42010. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  42011. return ok
  42012. }
  42013. // ResetStatus resets all changes to the "status" field.
  42014. func (m *WpChatroomMutation) ResetStatus() {
  42015. m.status = nil
  42016. m.addstatus = nil
  42017. delete(m.clearedFields, wpchatroom.FieldStatus)
  42018. }
  42019. // SetWxWxid sets the "wx_wxid" field.
  42020. func (m *WpChatroomMutation) SetWxWxid(s string) {
  42021. m.wx_wxid = &s
  42022. }
  42023. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  42024. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  42025. v := m.wx_wxid
  42026. if v == nil {
  42027. return
  42028. }
  42029. return *v, true
  42030. }
  42031. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  42032. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42034. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42035. if !m.op.Is(OpUpdateOne) {
  42036. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42037. }
  42038. if m.id == nil || m.oldValue == nil {
  42039. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42040. }
  42041. oldValue, err := m.oldValue(ctx)
  42042. if err != nil {
  42043. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42044. }
  42045. return oldValue.WxWxid, nil
  42046. }
  42047. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42048. func (m *WpChatroomMutation) ResetWxWxid() {
  42049. m.wx_wxid = nil
  42050. }
  42051. // SetChatroomID sets the "chatroom_id" field.
  42052. func (m *WpChatroomMutation) SetChatroomID(s string) {
  42053. m.chatroom_id = &s
  42054. }
  42055. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  42056. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  42057. v := m.chatroom_id
  42058. if v == nil {
  42059. return
  42060. }
  42061. return *v, true
  42062. }
  42063. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  42064. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42066. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  42067. if !m.op.Is(OpUpdateOne) {
  42068. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  42069. }
  42070. if m.id == nil || m.oldValue == nil {
  42071. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  42072. }
  42073. oldValue, err := m.oldValue(ctx)
  42074. if err != nil {
  42075. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  42076. }
  42077. return oldValue.ChatroomID, nil
  42078. }
  42079. // ResetChatroomID resets all changes to the "chatroom_id" field.
  42080. func (m *WpChatroomMutation) ResetChatroomID() {
  42081. m.chatroom_id = nil
  42082. }
  42083. // SetNickname sets the "nickname" field.
  42084. func (m *WpChatroomMutation) SetNickname(s string) {
  42085. m.nickname = &s
  42086. }
  42087. // Nickname returns the value of the "nickname" field in the mutation.
  42088. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  42089. v := m.nickname
  42090. if v == nil {
  42091. return
  42092. }
  42093. return *v, true
  42094. }
  42095. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  42096. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42098. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  42099. if !m.op.Is(OpUpdateOne) {
  42100. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42101. }
  42102. if m.id == nil || m.oldValue == nil {
  42103. return v, errors.New("OldNickname requires an ID field in the mutation")
  42104. }
  42105. oldValue, err := m.oldValue(ctx)
  42106. if err != nil {
  42107. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42108. }
  42109. return oldValue.Nickname, nil
  42110. }
  42111. // ResetNickname resets all changes to the "nickname" field.
  42112. func (m *WpChatroomMutation) ResetNickname() {
  42113. m.nickname = nil
  42114. }
  42115. // SetOwner sets the "owner" field.
  42116. func (m *WpChatroomMutation) SetOwner(s string) {
  42117. m.owner = &s
  42118. }
  42119. // Owner returns the value of the "owner" field in the mutation.
  42120. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  42121. v := m.owner
  42122. if v == nil {
  42123. return
  42124. }
  42125. return *v, true
  42126. }
  42127. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  42128. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42130. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  42131. if !m.op.Is(OpUpdateOne) {
  42132. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  42133. }
  42134. if m.id == nil || m.oldValue == nil {
  42135. return v, errors.New("OldOwner requires an ID field in the mutation")
  42136. }
  42137. oldValue, err := m.oldValue(ctx)
  42138. if err != nil {
  42139. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  42140. }
  42141. return oldValue.Owner, nil
  42142. }
  42143. // ResetOwner resets all changes to the "owner" field.
  42144. func (m *WpChatroomMutation) ResetOwner() {
  42145. m.owner = nil
  42146. }
  42147. // SetAvatar sets the "avatar" field.
  42148. func (m *WpChatroomMutation) SetAvatar(s string) {
  42149. m.avatar = &s
  42150. }
  42151. // Avatar returns the value of the "avatar" field in the mutation.
  42152. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  42153. v := m.avatar
  42154. if v == nil {
  42155. return
  42156. }
  42157. return *v, true
  42158. }
  42159. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  42160. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42162. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42163. if !m.op.Is(OpUpdateOne) {
  42164. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42165. }
  42166. if m.id == nil || m.oldValue == nil {
  42167. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42168. }
  42169. oldValue, err := m.oldValue(ctx)
  42170. if err != nil {
  42171. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42172. }
  42173. return oldValue.Avatar, nil
  42174. }
  42175. // ResetAvatar resets all changes to the "avatar" field.
  42176. func (m *WpChatroomMutation) ResetAvatar() {
  42177. m.avatar = nil
  42178. }
  42179. // SetMemberList sets the "member_list" field.
  42180. func (m *WpChatroomMutation) SetMemberList(s []string) {
  42181. m.member_list = &s
  42182. m.appendmember_list = nil
  42183. }
  42184. // MemberList returns the value of the "member_list" field in the mutation.
  42185. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  42186. v := m.member_list
  42187. if v == nil {
  42188. return
  42189. }
  42190. return *v, true
  42191. }
  42192. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  42193. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42195. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  42196. if !m.op.Is(OpUpdateOne) {
  42197. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  42198. }
  42199. if m.id == nil || m.oldValue == nil {
  42200. return v, errors.New("OldMemberList requires an ID field in the mutation")
  42201. }
  42202. oldValue, err := m.oldValue(ctx)
  42203. if err != nil {
  42204. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  42205. }
  42206. return oldValue.MemberList, nil
  42207. }
  42208. // AppendMemberList adds s to the "member_list" field.
  42209. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  42210. m.appendmember_list = append(m.appendmember_list, s...)
  42211. }
  42212. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  42213. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  42214. if len(m.appendmember_list) == 0 {
  42215. return nil, false
  42216. }
  42217. return m.appendmember_list, true
  42218. }
  42219. // ResetMemberList resets all changes to the "member_list" field.
  42220. func (m *WpChatroomMutation) ResetMemberList() {
  42221. m.member_list = nil
  42222. m.appendmember_list = nil
  42223. }
  42224. // Where appends a list predicates to the WpChatroomMutation builder.
  42225. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  42226. m.predicates = append(m.predicates, ps...)
  42227. }
  42228. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  42229. // users can use type-assertion to append predicates that do not depend on any generated package.
  42230. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  42231. p := make([]predicate.WpChatroom, len(ps))
  42232. for i := range ps {
  42233. p[i] = ps[i]
  42234. }
  42235. m.Where(p...)
  42236. }
  42237. // Op returns the operation name.
  42238. func (m *WpChatroomMutation) Op() Op {
  42239. return m.op
  42240. }
  42241. // SetOp allows setting the mutation operation.
  42242. func (m *WpChatroomMutation) SetOp(op Op) {
  42243. m.op = op
  42244. }
  42245. // Type returns the node type of this mutation (WpChatroom).
  42246. func (m *WpChatroomMutation) Type() string {
  42247. return m.typ
  42248. }
  42249. // Fields returns all fields that were changed during this mutation. Note that in
  42250. // order to get all numeric fields that were incremented/decremented, call
  42251. // AddedFields().
  42252. func (m *WpChatroomMutation) Fields() []string {
  42253. fields := make([]string, 0, 9)
  42254. if m.created_at != nil {
  42255. fields = append(fields, wpchatroom.FieldCreatedAt)
  42256. }
  42257. if m.updated_at != nil {
  42258. fields = append(fields, wpchatroom.FieldUpdatedAt)
  42259. }
  42260. if m.status != nil {
  42261. fields = append(fields, wpchatroom.FieldStatus)
  42262. }
  42263. if m.wx_wxid != nil {
  42264. fields = append(fields, wpchatroom.FieldWxWxid)
  42265. }
  42266. if m.chatroom_id != nil {
  42267. fields = append(fields, wpchatroom.FieldChatroomID)
  42268. }
  42269. if m.nickname != nil {
  42270. fields = append(fields, wpchatroom.FieldNickname)
  42271. }
  42272. if m.owner != nil {
  42273. fields = append(fields, wpchatroom.FieldOwner)
  42274. }
  42275. if m.avatar != nil {
  42276. fields = append(fields, wpchatroom.FieldAvatar)
  42277. }
  42278. if m.member_list != nil {
  42279. fields = append(fields, wpchatroom.FieldMemberList)
  42280. }
  42281. return fields
  42282. }
  42283. // Field returns the value of a field with the given name. The second boolean
  42284. // return value indicates that this field was not set, or was not defined in the
  42285. // schema.
  42286. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  42287. switch name {
  42288. case wpchatroom.FieldCreatedAt:
  42289. return m.CreatedAt()
  42290. case wpchatroom.FieldUpdatedAt:
  42291. return m.UpdatedAt()
  42292. case wpchatroom.FieldStatus:
  42293. return m.Status()
  42294. case wpchatroom.FieldWxWxid:
  42295. return m.WxWxid()
  42296. case wpchatroom.FieldChatroomID:
  42297. return m.ChatroomID()
  42298. case wpchatroom.FieldNickname:
  42299. return m.Nickname()
  42300. case wpchatroom.FieldOwner:
  42301. return m.Owner()
  42302. case wpchatroom.FieldAvatar:
  42303. return m.Avatar()
  42304. case wpchatroom.FieldMemberList:
  42305. return m.MemberList()
  42306. }
  42307. return nil, false
  42308. }
  42309. // OldField returns the old value of the field from the database. An error is
  42310. // returned if the mutation operation is not UpdateOne, or the query to the
  42311. // database failed.
  42312. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42313. switch name {
  42314. case wpchatroom.FieldCreatedAt:
  42315. return m.OldCreatedAt(ctx)
  42316. case wpchatroom.FieldUpdatedAt:
  42317. return m.OldUpdatedAt(ctx)
  42318. case wpchatroom.FieldStatus:
  42319. return m.OldStatus(ctx)
  42320. case wpchatroom.FieldWxWxid:
  42321. return m.OldWxWxid(ctx)
  42322. case wpchatroom.FieldChatroomID:
  42323. return m.OldChatroomID(ctx)
  42324. case wpchatroom.FieldNickname:
  42325. return m.OldNickname(ctx)
  42326. case wpchatroom.FieldOwner:
  42327. return m.OldOwner(ctx)
  42328. case wpchatroom.FieldAvatar:
  42329. return m.OldAvatar(ctx)
  42330. case wpchatroom.FieldMemberList:
  42331. return m.OldMemberList(ctx)
  42332. }
  42333. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  42334. }
  42335. // SetField sets the value of a field with the given name. It returns an error if
  42336. // the field is not defined in the schema, or if the type mismatched the field
  42337. // type.
  42338. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  42339. switch name {
  42340. case wpchatroom.FieldCreatedAt:
  42341. v, ok := value.(time.Time)
  42342. if !ok {
  42343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42344. }
  42345. m.SetCreatedAt(v)
  42346. return nil
  42347. case wpchatroom.FieldUpdatedAt:
  42348. v, ok := value.(time.Time)
  42349. if !ok {
  42350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42351. }
  42352. m.SetUpdatedAt(v)
  42353. return nil
  42354. case wpchatroom.FieldStatus:
  42355. v, ok := value.(uint8)
  42356. if !ok {
  42357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42358. }
  42359. m.SetStatus(v)
  42360. return nil
  42361. case wpchatroom.FieldWxWxid:
  42362. v, ok := value.(string)
  42363. if !ok {
  42364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42365. }
  42366. m.SetWxWxid(v)
  42367. return nil
  42368. case wpchatroom.FieldChatroomID:
  42369. v, ok := value.(string)
  42370. if !ok {
  42371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42372. }
  42373. m.SetChatroomID(v)
  42374. return nil
  42375. case wpchatroom.FieldNickname:
  42376. v, ok := value.(string)
  42377. if !ok {
  42378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42379. }
  42380. m.SetNickname(v)
  42381. return nil
  42382. case wpchatroom.FieldOwner:
  42383. v, ok := value.(string)
  42384. if !ok {
  42385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42386. }
  42387. m.SetOwner(v)
  42388. return nil
  42389. case wpchatroom.FieldAvatar:
  42390. v, ok := value.(string)
  42391. if !ok {
  42392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42393. }
  42394. m.SetAvatar(v)
  42395. return nil
  42396. case wpchatroom.FieldMemberList:
  42397. v, ok := value.([]string)
  42398. if !ok {
  42399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42400. }
  42401. m.SetMemberList(v)
  42402. return nil
  42403. }
  42404. return fmt.Errorf("unknown WpChatroom field %s", name)
  42405. }
  42406. // AddedFields returns all numeric fields that were incremented/decremented during
  42407. // this mutation.
  42408. func (m *WpChatroomMutation) AddedFields() []string {
  42409. var fields []string
  42410. if m.addstatus != nil {
  42411. fields = append(fields, wpchatroom.FieldStatus)
  42412. }
  42413. return fields
  42414. }
  42415. // AddedField returns the numeric value that was incremented/decremented on a field
  42416. // with the given name. The second boolean return value indicates that this field
  42417. // was not set, or was not defined in the schema.
  42418. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  42419. switch name {
  42420. case wpchatroom.FieldStatus:
  42421. return m.AddedStatus()
  42422. }
  42423. return nil, false
  42424. }
  42425. // AddField adds the value to the field with the given name. It returns an error if
  42426. // the field is not defined in the schema, or if the type mismatched the field
  42427. // type.
  42428. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  42429. switch name {
  42430. case wpchatroom.FieldStatus:
  42431. v, ok := value.(int8)
  42432. if !ok {
  42433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42434. }
  42435. m.AddStatus(v)
  42436. return nil
  42437. }
  42438. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  42439. }
  42440. // ClearedFields returns all nullable fields that were cleared during this
  42441. // mutation.
  42442. func (m *WpChatroomMutation) ClearedFields() []string {
  42443. var fields []string
  42444. if m.FieldCleared(wpchatroom.FieldStatus) {
  42445. fields = append(fields, wpchatroom.FieldStatus)
  42446. }
  42447. return fields
  42448. }
  42449. // FieldCleared returns a boolean indicating if a field with the given name was
  42450. // cleared in this mutation.
  42451. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  42452. _, ok := m.clearedFields[name]
  42453. return ok
  42454. }
  42455. // ClearField clears the value of the field with the given name. It returns an
  42456. // error if the field is not defined in the schema.
  42457. func (m *WpChatroomMutation) ClearField(name string) error {
  42458. switch name {
  42459. case wpchatroom.FieldStatus:
  42460. m.ClearStatus()
  42461. return nil
  42462. }
  42463. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  42464. }
  42465. // ResetField resets all changes in the mutation for the field with the given name.
  42466. // It returns an error if the field is not defined in the schema.
  42467. func (m *WpChatroomMutation) ResetField(name string) error {
  42468. switch name {
  42469. case wpchatroom.FieldCreatedAt:
  42470. m.ResetCreatedAt()
  42471. return nil
  42472. case wpchatroom.FieldUpdatedAt:
  42473. m.ResetUpdatedAt()
  42474. return nil
  42475. case wpchatroom.FieldStatus:
  42476. m.ResetStatus()
  42477. return nil
  42478. case wpchatroom.FieldWxWxid:
  42479. m.ResetWxWxid()
  42480. return nil
  42481. case wpchatroom.FieldChatroomID:
  42482. m.ResetChatroomID()
  42483. return nil
  42484. case wpchatroom.FieldNickname:
  42485. m.ResetNickname()
  42486. return nil
  42487. case wpchatroom.FieldOwner:
  42488. m.ResetOwner()
  42489. return nil
  42490. case wpchatroom.FieldAvatar:
  42491. m.ResetAvatar()
  42492. return nil
  42493. case wpchatroom.FieldMemberList:
  42494. m.ResetMemberList()
  42495. return nil
  42496. }
  42497. return fmt.Errorf("unknown WpChatroom field %s", name)
  42498. }
  42499. // AddedEdges returns all edge names that were set/added in this mutation.
  42500. func (m *WpChatroomMutation) AddedEdges() []string {
  42501. edges := make([]string, 0, 0)
  42502. return edges
  42503. }
  42504. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42505. // name in this mutation.
  42506. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  42507. return nil
  42508. }
  42509. // RemovedEdges returns all edge names that were removed in this mutation.
  42510. func (m *WpChatroomMutation) RemovedEdges() []string {
  42511. edges := make([]string, 0, 0)
  42512. return edges
  42513. }
  42514. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42515. // the given name in this mutation.
  42516. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  42517. return nil
  42518. }
  42519. // ClearedEdges returns all edge names that were cleared in this mutation.
  42520. func (m *WpChatroomMutation) ClearedEdges() []string {
  42521. edges := make([]string, 0, 0)
  42522. return edges
  42523. }
  42524. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42525. // was cleared in this mutation.
  42526. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  42527. return false
  42528. }
  42529. // ClearEdge clears the value of the edge with the given name. It returns an error
  42530. // if that edge is not defined in the schema.
  42531. func (m *WpChatroomMutation) ClearEdge(name string) error {
  42532. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  42533. }
  42534. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42535. // It returns an error if the edge is not defined in the schema.
  42536. func (m *WpChatroomMutation) ResetEdge(name string) error {
  42537. return fmt.Errorf("unknown WpChatroom edge %s", name)
  42538. }
  42539. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  42540. type WpChatroomMemberMutation struct {
  42541. config
  42542. op Op
  42543. typ string
  42544. id *uint64
  42545. created_at *time.Time
  42546. updated_at *time.Time
  42547. status *uint8
  42548. addstatus *int8
  42549. wx_wxid *string
  42550. wxid *string
  42551. nickname *string
  42552. avatar *string
  42553. clearedFields map[string]struct{}
  42554. done bool
  42555. oldValue func(context.Context) (*WpChatroomMember, error)
  42556. predicates []predicate.WpChatroomMember
  42557. }
  42558. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  42559. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  42560. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  42561. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  42562. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  42563. m := &WpChatroomMemberMutation{
  42564. config: c,
  42565. op: op,
  42566. typ: TypeWpChatroomMember,
  42567. clearedFields: make(map[string]struct{}),
  42568. }
  42569. for _, opt := range opts {
  42570. opt(m)
  42571. }
  42572. return m
  42573. }
  42574. // withWpChatroomMemberID sets the ID field of the mutation.
  42575. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  42576. return func(m *WpChatroomMemberMutation) {
  42577. var (
  42578. err error
  42579. once sync.Once
  42580. value *WpChatroomMember
  42581. )
  42582. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  42583. once.Do(func() {
  42584. if m.done {
  42585. err = errors.New("querying old values post mutation is not allowed")
  42586. } else {
  42587. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  42588. }
  42589. })
  42590. return value, err
  42591. }
  42592. m.id = &id
  42593. }
  42594. }
  42595. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  42596. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  42597. return func(m *WpChatroomMemberMutation) {
  42598. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  42599. return node, nil
  42600. }
  42601. m.id = &node.ID
  42602. }
  42603. }
  42604. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42605. // executed in a transaction (ent.Tx), a transactional client is returned.
  42606. func (m WpChatroomMemberMutation) Client() *Client {
  42607. client := &Client{config: m.config}
  42608. client.init()
  42609. return client
  42610. }
  42611. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42612. // it returns an error otherwise.
  42613. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  42614. if _, ok := m.driver.(*txDriver); !ok {
  42615. return nil, errors.New("ent: mutation is not running in a transaction")
  42616. }
  42617. tx := &Tx{config: m.config}
  42618. tx.init()
  42619. return tx, nil
  42620. }
  42621. // SetID sets the value of the id field. Note that this
  42622. // operation is only accepted on creation of WpChatroomMember entities.
  42623. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  42624. m.id = &id
  42625. }
  42626. // ID returns the ID value in the mutation. Note that the ID is only available
  42627. // if it was provided to the builder or after it was returned from the database.
  42628. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  42629. if m.id == nil {
  42630. return
  42631. }
  42632. return *m.id, true
  42633. }
  42634. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42635. // That means, if the mutation is applied within a transaction with an isolation level such
  42636. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42637. // or updated by the mutation.
  42638. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  42639. switch {
  42640. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42641. id, exists := m.ID()
  42642. if exists {
  42643. return []uint64{id}, nil
  42644. }
  42645. fallthrough
  42646. case m.op.Is(OpUpdate | OpDelete):
  42647. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  42648. default:
  42649. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42650. }
  42651. }
  42652. // SetCreatedAt sets the "created_at" field.
  42653. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  42654. m.created_at = &t
  42655. }
  42656. // CreatedAt returns the value of the "created_at" field in the mutation.
  42657. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  42658. v := m.created_at
  42659. if v == nil {
  42660. return
  42661. }
  42662. return *v, true
  42663. }
  42664. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  42665. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42667. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42668. if !m.op.Is(OpUpdateOne) {
  42669. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42670. }
  42671. if m.id == nil || m.oldValue == nil {
  42672. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42673. }
  42674. oldValue, err := m.oldValue(ctx)
  42675. if err != nil {
  42676. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42677. }
  42678. return oldValue.CreatedAt, nil
  42679. }
  42680. // ResetCreatedAt resets all changes to the "created_at" field.
  42681. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  42682. m.created_at = nil
  42683. }
  42684. // SetUpdatedAt sets the "updated_at" field.
  42685. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  42686. m.updated_at = &t
  42687. }
  42688. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42689. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  42690. v := m.updated_at
  42691. if v == nil {
  42692. return
  42693. }
  42694. return *v, true
  42695. }
  42696. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  42697. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42699. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42700. if !m.op.Is(OpUpdateOne) {
  42701. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42702. }
  42703. if m.id == nil || m.oldValue == nil {
  42704. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42705. }
  42706. oldValue, err := m.oldValue(ctx)
  42707. if err != nil {
  42708. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42709. }
  42710. return oldValue.UpdatedAt, nil
  42711. }
  42712. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42713. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  42714. m.updated_at = nil
  42715. }
  42716. // SetStatus sets the "status" field.
  42717. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  42718. m.status = &u
  42719. m.addstatus = nil
  42720. }
  42721. // Status returns the value of the "status" field in the mutation.
  42722. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  42723. v := m.status
  42724. if v == nil {
  42725. return
  42726. }
  42727. return *v, true
  42728. }
  42729. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  42730. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42732. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42733. if !m.op.Is(OpUpdateOne) {
  42734. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42735. }
  42736. if m.id == nil || m.oldValue == nil {
  42737. return v, errors.New("OldStatus requires an ID field in the mutation")
  42738. }
  42739. oldValue, err := m.oldValue(ctx)
  42740. if err != nil {
  42741. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42742. }
  42743. return oldValue.Status, nil
  42744. }
  42745. // AddStatus adds u to the "status" field.
  42746. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  42747. if m.addstatus != nil {
  42748. *m.addstatus += u
  42749. } else {
  42750. m.addstatus = &u
  42751. }
  42752. }
  42753. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42754. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  42755. v := m.addstatus
  42756. if v == nil {
  42757. return
  42758. }
  42759. return *v, true
  42760. }
  42761. // ClearStatus clears the value of the "status" field.
  42762. func (m *WpChatroomMemberMutation) ClearStatus() {
  42763. m.status = nil
  42764. m.addstatus = nil
  42765. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  42766. }
  42767. // StatusCleared returns if the "status" field was cleared in this mutation.
  42768. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  42769. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  42770. return ok
  42771. }
  42772. // ResetStatus resets all changes to the "status" field.
  42773. func (m *WpChatroomMemberMutation) ResetStatus() {
  42774. m.status = nil
  42775. m.addstatus = nil
  42776. delete(m.clearedFields, wpchatroommember.FieldStatus)
  42777. }
  42778. // SetWxWxid sets the "wx_wxid" field.
  42779. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  42780. m.wx_wxid = &s
  42781. }
  42782. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  42783. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  42784. v := m.wx_wxid
  42785. if v == nil {
  42786. return
  42787. }
  42788. return *v, true
  42789. }
  42790. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  42791. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42793. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42794. if !m.op.Is(OpUpdateOne) {
  42795. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42796. }
  42797. if m.id == nil || m.oldValue == nil {
  42798. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42799. }
  42800. oldValue, err := m.oldValue(ctx)
  42801. if err != nil {
  42802. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42803. }
  42804. return oldValue.WxWxid, nil
  42805. }
  42806. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42807. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  42808. m.wx_wxid = nil
  42809. }
  42810. // SetWxid sets the "wxid" field.
  42811. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  42812. m.wxid = &s
  42813. }
  42814. // Wxid returns the value of the "wxid" field in the mutation.
  42815. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  42816. v := m.wxid
  42817. if v == nil {
  42818. return
  42819. }
  42820. return *v, true
  42821. }
  42822. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  42823. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42825. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  42826. if !m.op.Is(OpUpdateOne) {
  42827. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42828. }
  42829. if m.id == nil || m.oldValue == nil {
  42830. return v, errors.New("OldWxid requires an ID field in the mutation")
  42831. }
  42832. oldValue, err := m.oldValue(ctx)
  42833. if err != nil {
  42834. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42835. }
  42836. return oldValue.Wxid, nil
  42837. }
  42838. // ResetWxid resets all changes to the "wxid" field.
  42839. func (m *WpChatroomMemberMutation) ResetWxid() {
  42840. m.wxid = nil
  42841. }
  42842. // SetNickname sets the "nickname" field.
  42843. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  42844. m.nickname = &s
  42845. }
  42846. // Nickname returns the value of the "nickname" field in the mutation.
  42847. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  42848. v := m.nickname
  42849. if v == nil {
  42850. return
  42851. }
  42852. return *v, true
  42853. }
  42854. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  42855. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42857. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  42858. if !m.op.Is(OpUpdateOne) {
  42859. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42860. }
  42861. if m.id == nil || m.oldValue == nil {
  42862. return v, errors.New("OldNickname requires an ID field in the mutation")
  42863. }
  42864. oldValue, err := m.oldValue(ctx)
  42865. if err != nil {
  42866. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42867. }
  42868. return oldValue.Nickname, nil
  42869. }
  42870. // ResetNickname resets all changes to the "nickname" field.
  42871. func (m *WpChatroomMemberMutation) ResetNickname() {
  42872. m.nickname = nil
  42873. }
  42874. // SetAvatar sets the "avatar" field.
  42875. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  42876. m.avatar = &s
  42877. }
  42878. // Avatar returns the value of the "avatar" field in the mutation.
  42879. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  42880. v := m.avatar
  42881. if v == nil {
  42882. return
  42883. }
  42884. return *v, true
  42885. }
  42886. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  42887. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42889. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42890. if !m.op.Is(OpUpdateOne) {
  42891. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42892. }
  42893. if m.id == nil || m.oldValue == nil {
  42894. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42895. }
  42896. oldValue, err := m.oldValue(ctx)
  42897. if err != nil {
  42898. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42899. }
  42900. return oldValue.Avatar, nil
  42901. }
  42902. // ResetAvatar resets all changes to the "avatar" field.
  42903. func (m *WpChatroomMemberMutation) ResetAvatar() {
  42904. m.avatar = nil
  42905. }
  42906. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  42907. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  42908. m.predicates = append(m.predicates, ps...)
  42909. }
  42910. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  42911. // users can use type-assertion to append predicates that do not depend on any generated package.
  42912. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  42913. p := make([]predicate.WpChatroomMember, len(ps))
  42914. for i := range ps {
  42915. p[i] = ps[i]
  42916. }
  42917. m.Where(p...)
  42918. }
  42919. // Op returns the operation name.
  42920. func (m *WpChatroomMemberMutation) Op() Op {
  42921. return m.op
  42922. }
  42923. // SetOp allows setting the mutation operation.
  42924. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  42925. m.op = op
  42926. }
  42927. // Type returns the node type of this mutation (WpChatroomMember).
  42928. func (m *WpChatroomMemberMutation) Type() string {
  42929. return m.typ
  42930. }
  42931. // Fields returns all fields that were changed during this mutation. Note that in
  42932. // order to get all numeric fields that were incremented/decremented, call
  42933. // AddedFields().
  42934. func (m *WpChatroomMemberMutation) Fields() []string {
  42935. fields := make([]string, 0, 7)
  42936. if m.created_at != nil {
  42937. fields = append(fields, wpchatroommember.FieldCreatedAt)
  42938. }
  42939. if m.updated_at != nil {
  42940. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  42941. }
  42942. if m.status != nil {
  42943. fields = append(fields, wpchatroommember.FieldStatus)
  42944. }
  42945. if m.wx_wxid != nil {
  42946. fields = append(fields, wpchatroommember.FieldWxWxid)
  42947. }
  42948. if m.wxid != nil {
  42949. fields = append(fields, wpchatroommember.FieldWxid)
  42950. }
  42951. if m.nickname != nil {
  42952. fields = append(fields, wpchatroommember.FieldNickname)
  42953. }
  42954. if m.avatar != nil {
  42955. fields = append(fields, wpchatroommember.FieldAvatar)
  42956. }
  42957. return fields
  42958. }
  42959. // Field returns the value of a field with the given name. The second boolean
  42960. // return value indicates that this field was not set, or was not defined in the
  42961. // schema.
  42962. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  42963. switch name {
  42964. case wpchatroommember.FieldCreatedAt:
  42965. return m.CreatedAt()
  42966. case wpchatroommember.FieldUpdatedAt:
  42967. return m.UpdatedAt()
  42968. case wpchatroommember.FieldStatus:
  42969. return m.Status()
  42970. case wpchatroommember.FieldWxWxid:
  42971. return m.WxWxid()
  42972. case wpchatroommember.FieldWxid:
  42973. return m.Wxid()
  42974. case wpchatroommember.FieldNickname:
  42975. return m.Nickname()
  42976. case wpchatroommember.FieldAvatar:
  42977. return m.Avatar()
  42978. }
  42979. return nil, false
  42980. }
  42981. // OldField returns the old value of the field from the database. An error is
  42982. // returned if the mutation operation is not UpdateOne, or the query to the
  42983. // database failed.
  42984. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42985. switch name {
  42986. case wpchatroommember.FieldCreatedAt:
  42987. return m.OldCreatedAt(ctx)
  42988. case wpchatroommember.FieldUpdatedAt:
  42989. return m.OldUpdatedAt(ctx)
  42990. case wpchatroommember.FieldStatus:
  42991. return m.OldStatus(ctx)
  42992. case wpchatroommember.FieldWxWxid:
  42993. return m.OldWxWxid(ctx)
  42994. case wpchatroommember.FieldWxid:
  42995. return m.OldWxid(ctx)
  42996. case wpchatroommember.FieldNickname:
  42997. return m.OldNickname(ctx)
  42998. case wpchatroommember.FieldAvatar:
  42999. return m.OldAvatar(ctx)
  43000. }
  43001. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  43002. }
  43003. // SetField sets the value of a field with the given name. It returns an error if
  43004. // the field is not defined in the schema, or if the type mismatched the field
  43005. // type.
  43006. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  43007. switch name {
  43008. case wpchatroommember.FieldCreatedAt:
  43009. v, ok := value.(time.Time)
  43010. if !ok {
  43011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43012. }
  43013. m.SetCreatedAt(v)
  43014. return nil
  43015. case wpchatroommember.FieldUpdatedAt:
  43016. v, ok := value.(time.Time)
  43017. if !ok {
  43018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43019. }
  43020. m.SetUpdatedAt(v)
  43021. return nil
  43022. case wpchatroommember.FieldStatus:
  43023. v, ok := value.(uint8)
  43024. if !ok {
  43025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43026. }
  43027. m.SetStatus(v)
  43028. return nil
  43029. case wpchatroommember.FieldWxWxid:
  43030. v, ok := value.(string)
  43031. if !ok {
  43032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43033. }
  43034. m.SetWxWxid(v)
  43035. return nil
  43036. case wpchatroommember.FieldWxid:
  43037. v, ok := value.(string)
  43038. if !ok {
  43039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43040. }
  43041. m.SetWxid(v)
  43042. return nil
  43043. case wpchatroommember.FieldNickname:
  43044. v, ok := value.(string)
  43045. if !ok {
  43046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43047. }
  43048. m.SetNickname(v)
  43049. return nil
  43050. case wpchatroommember.FieldAvatar:
  43051. v, ok := value.(string)
  43052. if !ok {
  43053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43054. }
  43055. m.SetAvatar(v)
  43056. return nil
  43057. }
  43058. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  43059. }
  43060. // AddedFields returns all numeric fields that were incremented/decremented during
  43061. // this mutation.
  43062. func (m *WpChatroomMemberMutation) AddedFields() []string {
  43063. var fields []string
  43064. if m.addstatus != nil {
  43065. fields = append(fields, wpchatroommember.FieldStatus)
  43066. }
  43067. return fields
  43068. }
  43069. // AddedField returns the numeric value that was incremented/decremented on a field
  43070. // with the given name. The second boolean return value indicates that this field
  43071. // was not set, or was not defined in the schema.
  43072. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  43073. switch name {
  43074. case wpchatroommember.FieldStatus:
  43075. return m.AddedStatus()
  43076. }
  43077. return nil, false
  43078. }
  43079. // AddField adds the value to the field with the given name. It returns an error if
  43080. // the field is not defined in the schema, or if the type mismatched the field
  43081. // type.
  43082. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  43083. switch name {
  43084. case wpchatroommember.FieldStatus:
  43085. v, ok := value.(int8)
  43086. if !ok {
  43087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43088. }
  43089. m.AddStatus(v)
  43090. return nil
  43091. }
  43092. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  43093. }
  43094. // ClearedFields returns all nullable fields that were cleared during this
  43095. // mutation.
  43096. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  43097. var fields []string
  43098. if m.FieldCleared(wpchatroommember.FieldStatus) {
  43099. fields = append(fields, wpchatroommember.FieldStatus)
  43100. }
  43101. return fields
  43102. }
  43103. // FieldCleared returns a boolean indicating if a field with the given name was
  43104. // cleared in this mutation.
  43105. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  43106. _, ok := m.clearedFields[name]
  43107. return ok
  43108. }
  43109. // ClearField clears the value of the field with the given name. It returns an
  43110. // error if the field is not defined in the schema.
  43111. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  43112. switch name {
  43113. case wpchatroommember.FieldStatus:
  43114. m.ClearStatus()
  43115. return nil
  43116. }
  43117. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  43118. }
  43119. // ResetField resets all changes in the mutation for the field with the given name.
  43120. // It returns an error if the field is not defined in the schema.
  43121. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  43122. switch name {
  43123. case wpchatroommember.FieldCreatedAt:
  43124. m.ResetCreatedAt()
  43125. return nil
  43126. case wpchatroommember.FieldUpdatedAt:
  43127. m.ResetUpdatedAt()
  43128. return nil
  43129. case wpchatroommember.FieldStatus:
  43130. m.ResetStatus()
  43131. return nil
  43132. case wpchatroommember.FieldWxWxid:
  43133. m.ResetWxWxid()
  43134. return nil
  43135. case wpchatroommember.FieldWxid:
  43136. m.ResetWxid()
  43137. return nil
  43138. case wpchatroommember.FieldNickname:
  43139. m.ResetNickname()
  43140. return nil
  43141. case wpchatroommember.FieldAvatar:
  43142. m.ResetAvatar()
  43143. return nil
  43144. }
  43145. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  43146. }
  43147. // AddedEdges returns all edge names that were set/added in this mutation.
  43148. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  43149. edges := make([]string, 0, 0)
  43150. return edges
  43151. }
  43152. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43153. // name in this mutation.
  43154. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  43155. return nil
  43156. }
  43157. // RemovedEdges returns all edge names that were removed in this mutation.
  43158. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  43159. edges := make([]string, 0, 0)
  43160. return edges
  43161. }
  43162. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43163. // the given name in this mutation.
  43164. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  43165. return nil
  43166. }
  43167. // ClearedEdges returns all edge names that were cleared in this mutation.
  43168. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  43169. edges := make([]string, 0, 0)
  43170. return edges
  43171. }
  43172. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43173. // was cleared in this mutation.
  43174. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  43175. return false
  43176. }
  43177. // ClearEdge clears the value of the edge with the given name. It returns an error
  43178. // if that edge is not defined in the schema.
  43179. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  43180. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  43181. }
  43182. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43183. // It returns an error if the edge is not defined in the schema.
  43184. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  43185. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  43186. }
  43187. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  43188. type WxMutation struct {
  43189. config
  43190. op Op
  43191. typ string
  43192. id *uint64
  43193. created_at *time.Time
  43194. updated_at *time.Time
  43195. status *uint8
  43196. addstatus *int8
  43197. deleted_at *time.Time
  43198. port *string
  43199. process_id *string
  43200. callback *string
  43201. wxid *string
  43202. account *string
  43203. nickname *string
  43204. tel *string
  43205. head_big *string
  43206. organization_id *uint64
  43207. addorganization_id *int64
  43208. api_base *string
  43209. api_key *string
  43210. allow_list *[]string
  43211. appendallow_list []string
  43212. group_allow_list *[]string
  43213. appendgroup_allow_list []string
  43214. block_list *[]string
  43215. appendblock_list []string
  43216. group_block_list *[]string
  43217. appendgroup_block_list []string
  43218. ctype *uint64
  43219. addctype *int64
  43220. clearedFields map[string]struct{}
  43221. server *uint64
  43222. clearedserver bool
  43223. agent *uint64
  43224. clearedagent bool
  43225. done bool
  43226. oldValue func(context.Context) (*Wx, error)
  43227. predicates []predicate.Wx
  43228. }
  43229. var _ ent.Mutation = (*WxMutation)(nil)
  43230. // wxOption allows management of the mutation configuration using functional options.
  43231. type wxOption func(*WxMutation)
  43232. // newWxMutation creates new mutation for the Wx entity.
  43233. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  43234. m := &WxMutation{
  43235. config: c,
  43236. op: op,
  43237. typ: TypeWx,
  43238. clearedFields: make(map[string]struct{}),
  43239. }
  43240. for _, opt := range opts {
  43241. opt(m)
  43242. }
  43243. return m
  43244. }
  43245. // withWxID sets the ID field of the mutation.
  43246. func withWxID(id uint64) wxOption {
  43247. return func(m *WxMutation) {
  43248. var (
  43249. err error
  43250. once sync.Once
  43251. value *Wx
  43252. )
  43253. m.oldValue = func(ctx context.Context) (*Wx, error) {
  43254. once.Do(func() {
  43255. if m.done {
  43256. err = errors.New("querying old values post mutation is not allowed")
  43257. } else {
  43258. value, err = m.Client().Wx.Get(ctx, id)
  43259. }
  43260. })
  43261. return value, err
  43262. }
  43263. m.id = &id
  43264. }
  43265. }
  43266. // withWx sets the old Wx of the mutation.
  43267. func withWx(node *Wx) wxOption {
  43268. return func(m *WxMutation) {
  43269. m.oldValue = func(context.Context) (*Wx, error) {
  43270. return node, nil
  43271. }
  43272. m.id = &node.ID
  43273. }
  43274. }
  43275. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43276. // executed in a transaction (ent.Tx), a transactional client is returned.
  43277. func (m WxMutation) Client() *Client {
  43278. client := &Client{config: m.config}
  43279. client.init()
  43280. return client
  43281. }
  43282. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43283. // it returns an error otherwise.
  43284. func (m WxMutation) Tx() (*Tx, error) {
  43285. if _, ok := m.driver.(*txDriver); !ok {
  43286. return nil, errors.New("ent: mutation is not running in a transaction")
  43287. }
  43288. tx := &Tx{config: m.config}
  43289. tx.init()
  43290. return tx, nil
  43291. }
  43292. // SetID sets the value of the id field. Note that this
  43293. // operation is only accepted on creation of Wx entities.
  43294. func (m *WxMutation) SetID(id uint64) {
  43295. m.id = &id
  43296. }
  43297. // ID returns the ID value in the mutation. Note that the ID is only available
  43298. // if it was provided to the builder or after it was returned from the database.
  43299. func (m *WxMutation) ID() (id uint64, exists bool) {
  43300. if m.id == nil {
  43301. return
  43302. }
  43303. return *m.id, true
  43304. }
  43305. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43306. // That means, if the mutation is applied within a transaction with an isolation level such
  43307. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43308. // or updated by the mutation.
  43309. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  43310. switch {
  43311. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43312. id, exists := m.ID()
  43313. if exists {
  43314. return []uint64{id}, nil
  43315. }
  43316. fallthrough
  43317. case m.op.Is(OpUpdate | OpDelete):
  43318. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  43319. default:
  43320. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43321. }
  43322. }
  43323. // SetCreatedAt sets the "created_at" field.
  43324. func (m *WxMutation) SetCreatedAt(t time.Time) {
  43325. m.created_at = &t
  43326. }
  43327. // CreatedAt returns the value of the "created_at" field in the mutation.
  43328. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  43329. v := m.created_at
  43330. if v == nil {
  43331. return
  43332. }
  43333. return *v, true
  43334. }
  43335. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  43336. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43338. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43339. if !m.op.Is(OpUpdateOne) {
  43340. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43341. }
  43342. if m.id == nil || m.oldValue == nil {
  43343. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43344. }
  43345. oldValue, err := m.oldValue(ctx)
  43346. if err != nil {
  43347. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43348. }
  43349. return oldValue.CreatedAt, nil
  43350. }
  43351. // ResetCreatedAt resets all changes to the "created_at" field.
  43352. func (m *WxMutation) ResetCreatedAt() {
  43353. m.created_at = nil
  43354. }
  43355. // SetUpdatedAt sets the "updated_at" field.
  43356. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  43357. m.updated_at = &t
  43358. }
  43359. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43360. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  43361. v := m.updated_at
  43362. if v == nil {
  43363. return
  43364. }
  43365. return *v, true
  43366. }
  43367. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  43368. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43370. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43371. if !m.op.Is(OpUpdateOne) {
  43372. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43373. }
  43374. if m.id == nil || m.oldValue == nil {
  43375. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43376. }
  43377. oldValue, err := m.oldValue(ctx)
  43378. if err != nil {
  43379. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43380. }
  43381. return oldValue.UpdatedAt, nil
  43382. }
  43383. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43384. func (m *WxMutation) ResetUpdatedAt() {
  43385. m.updated_at = nil
  43386. }
  43387. // SetStatus sets the "status" field.
  43388. func (m *WxMutation) SetStatus(u uint8) {
  43389. m.status = &u
  43390. m.addstatus = nil
  43391. }
  43392. // Status returns the value of the "status" field in the mutation.
  43393. func (m *WxMutation) Status() (r uint8, exists bool) {
  43394. v := m.status
  43395. if v == nil {
  43396. return
  43397. }
  43398. return *v, true
  43399. }
  43400. // OldStatus returns the old "status" field's value of the Wx entity.
  43401. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43403. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43404. if !m.op.Is(OpUpdateOne) {
  43405. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43406. }
  43407. if m.id == nil || m.oldValue == nil {
  43408. return v, errors.New("OldStatus requires an ID field in the mutation")
  43409. }
  43410. oldValue, err := m.oldValue(ctx)
  43411. if err != nil {
  43412. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43413. }
  43414. return oldValue.Status, nil
  43415. }
  43416. // AddStatus adds u to the "status" field.
  43417. func (m *WxMutation) AddStatus(u int8) {
  43418. if m.addstatus != nil {
  43419. *m.addstatus += u
  43420. } else {
  43421. m.addstatus = &u
  43422. }
  43423. }
  43424. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43425. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  43426. v := m.addstatus
  43427. if v == nil {
  43428. return
  43429. }
  43430. return *v, true
  43431. }
  43432. // ClearStatus clears the value of the "status" field.
  43433. func (m *WxMutation) ClearStatus() {
  43434. m.status = nil
  43435. m.addstatus = nil
  43436. m.clearedFields[wx.FieldStatus] = struct{}{}
  43437. }
  43438. // StatusCleared returns if the "status" field was cleared in this mutation.
  43439. func (m *WxMutation) StatusCleared() bool {
  43440. _, ok := m.clearedFields[wx.FieldStatus]
  43441. return ok
  43442. }
  43443. // ResetStatus resets all changes to the "status" field.
  43444. func (m *WxMutation) ResetStatus() {
  43445. m.status = nil
  43446. m.addstatus = nil
  43447. delete(m.clearedFields, wx.FieldStatus)
  43448. }
  43449. // SetDeletedAt sets the "deleted_at" field.
  43450. func (m *WxMutation) SetDeletedAt(t time.Time) {
  43451. m.deleted_at = &t
  43452. }
  43453. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43454. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  43455. v := m.deleted_at
  43456. if v == nil {
  43457. return
  43458. }
  43459. return *v, true
  43460. }
  43461. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  43462. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43464. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43465. if !m.op.Is(OpUpdateOne) {
  43466. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43467. }
  43468. if m.id == nil || m.oldValue == nil {
  43469. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43470. }
  43471. oldValue, err := m.oldValue(ctx)
  43472. if err != nil {
  43473. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43474. }
  43475. return oldValue.DeletedAt, nil
  43476. }
  43477. // ClearDeletedAt clears the value of the "deleted_at" field.
  43478. func (m *WxMutation) ClearDeletedAt() {
  43479. m.deleted_at = nil
  43480. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  43481. }
  43482. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43483. func (m *WxMutation) DeletedAtCleared() bool {
  43484. _, ok := m.clearedFields[wx.FieldDeletedAt]
  43485. return ok
  43486. }
  43487. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43488. func (m *WxMutation) ResetDeletedAt() {
  43489. m.deleted_at = nil
  43490. delete(m.clearedFields, wx.FieldDeletedAt)
  43491. }
  43492. // SetServerID sets the "server_id" field.
  43493. func (m *WxMutation) SetServerID(u uint64) {
  43494. m.server = &u
  43495. }
  43496. // ServerID returns the value of the "server_id" field in the mutation.
  43497. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  43498. v := m.server
  43499. if v == nil {
  43500. return
  43501. }
  43502. return *v, true
  43503. }
  43504. // OldServerID returns the old "server_id" field's value of the Wx entity.
  43505. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43507. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  43508. if !m.op.Is(OpUpdateOne) {
  43509. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  43510. }
  43511. if m.id == nil || m.oldValue == nil {
  43512. return v, errors.New("OldServerID requires an ID field in the mutation")
  43513. }
  43514. oldValue, err := m.oldValue(ctx)
  43515. if err != nil {
  43516. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  43517. }
  43518. return oldValue.ServerID, nil
  43519. }
  43520. // ClearServerID clears the value of the "server_id" field.
  43521. func (m *WxMutation) ClearServerID() {
  43522. m.server = nil
  43523. m.clearedFields[wx.FieldServerID] = struct{}{}
  43524. }
  43525. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  43526. func (m *WxMutation) ServerIDCleared() bool {
  43527. _, ok := m.clearedFields[wx.FieldServerID]
  43528. return ok
  43529. }
  43530. // ResetServerID resets all changes to the "server_id" field.
  43531. func (m *WxMutation) ResetServerID() {
  43532. m.server = nil
  43533. delete(m.clearedFields, wx.FieldServerID)
  43534. }
  43535. // SetPort sets the "port" field.
  43536. func (m *WxMutation) SetPort(s string) {
  43537. m.port = &s
  43538. }
  43539. // Port returns the value of the "port" field in the mutation.
  43540. func (m *WxMutation) Port() (r string, exists bool) {
  43541. v := m.port
  43542. if v == nil {
  43543. return
  43544. }
  43545. return *v, true
  43546. }
  43547. // OldPort returns the old "port" field's value of the Wx entity.
  43548. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43550. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  43551. if !m.op.Is(OpUpdateOne) {
  43552. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  43553. }
  43554. if m.id == nil || m.oldValue == nil {
  43555. return v, errors.New("OldPort requires an ID field in the mutation")
  43556. }
  43557. oldValue, err := m.oldValue(ctx)
  43558. if err != nil {
  43559. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  43560. }
  43561. return oldValue.Port, nil
  43562. }
  43563. // ResetPort resets all changes to the "port" field.
  43564. func (m *WxMutation) ResetPort() {
  43565. m.port = nil
  43566. }
  43567. // SetProcessID sets the "process_id" field.
  43568. func (m *WxMutation) SetProcessID(s string) {
  43569. m.process_id = &s
  43570. }
  43571. // ProcessID returns the value of the "process_id" field in the mutation.
  43572. func (m *WxMutation) ProcessID() (r string, exists bool) {
  43573. v := m.process_id
  43574. if v == nil {
  43575. return
  43576. }
  43577. return *v, true
  43578. }
  43579. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  43580. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43582. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  43583. if !m.op.Is(OpUpdateOne) {
  43584. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  43585. }
  43586. if m.id == nil || m.oldValue == nil {
  43587. return v, errors.New("OldProcessID requires an ID field in the mutation")
  43588. }
  43589. oldValue, err := m.oldValue(ctx)
  43590. if err != nil {
  43591. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  43592. }
  43593. return oldValue.ProcessID, nil
  43594. }
  43595. // ResetProcessID resets all changes to the "process_id" field.
  43596. func (m *WxMutation) ResetProcessID() {
  43597. m.process_id = nil
  43598. }
  43599. // SetCallback sets the "callback" field.
  43600. func (m *WxMutation) SetCallback(s string) {
  43601. m.callback = &s
  43602. }
  43603. // Callback returns the value of the "callback" field in the mutation.
  43604. func (m *WxMutation) Callback() (r string, exists bool) {
  43605. v := m.callback
  43606. if v == nil {
  43607. return
  43608. }
  43609. return *v, true
  43610. }
  43611. // OldCallback returns the old "callback" field's value of the Wx entity.
  43612. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43614. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  43615. if !m.op.Is(OpUpdateOne) {
  43616. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  43617. }
  43618. if m.id == nil || m.oldValue == nil {
  43619. return v, errors.New("OldCallback requires an ID field in the mutation")
  43620. }
  43621. oldValue, err := m.oldValue(ctx)
  43622. if err != nil {
  43623. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  43624. }
  43625. return oldValue.Callback, nil
  43626. }
  43627. // ResetCallback resets all changes to the "callback" field.
  43628. func (m *WxMutation) ResetCallback() {
  43629. m.callback = nil
  43630. }
  43631. // SetWxid sets the "wxid" field.
  43632. func (m *WxMutation) SetWxid(s string) {
  43633. m.wxid = &s
  43634. }
  43635. // Wxid returns the value of the "wxid" field in the mutation.
  43636. func (m *WxMutation) Wxid() (r string, exists bool) {
  43637. v := m.wxid
  43638. if v == nil {
  43639. return
  43640. }
  43641. return *v, true
  43642. }
  43643. // OldWxid returns the old "wxid" field's value of the Wx entity.
  43644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43646. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  43647. if !m.op.Is(OpUpdateOne) {
  43648. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43649. }
  43650. if m.id == nil || m.oldValue == nil {
  43651. return v, errors.New("OldWxid requires an ID field in the mutation")
  43652. }
  43653. oldValue, err := m.oldValue(ctx)
  43654. if err != nil {
  43655. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43656. }
  43657. return oldValue.Wxid, nil
  43658. }
  43659. // ResetWxid resets all changes to the "wxid" field.
  43660. func (m *WxMutation) ResetWxid() {
  43661. m.wxid = nil
  43662. }
  43663. // SetAccount sets the "account" field.
  43664. func (m *WxMutation) SetAccount(s string) {
  43665. m.account = &s
  43666. }
  43667. // Account returns the value of the "account" field in the mutation.
  43668. func (m *WxMutation) Account() (r string, exists bool) {
  43669. v := m.account
  43670. if v == nil {
  43671. return
  43672. }
  43673. return *v, true
  43674. }
  43675. // OldAccount returns the old "account" field's value of the Wx entity.
  43676. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43678. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  43679. if !m.op.Is(OpUpdateOne) {
  43680. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43681. }
  43682. if m.id == nil || m.oldValue == nil {
  43683. return v, errors.New("OldAccount requires an ID field in the mutation")
  43684. }
  43685. oldValue, err := m.oldValue(ctx)
  43686. if err != nil {
  43687. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43688. }
  43689. return oldValue.Account, nil
  43690. }
  43691. // ResetAccount resets all changes to the "account" field.
  43692. func (m *WxMutation) ResetAccount() {
  43693. m.account = nil
  43694. }
  43695. // SetNickname sets the "nickname" field.
  43696. func (m *WxMutation) SetNickname(s string) {
  43697. m.nickname = &s
  43698. }
  43699. // Nickname returns the value of the "nickname" field in the mutation.
  43700. func (m *WxMutation) Nickname() (r string, exists bool) {
  43701. v := m.nickname
  43702. if v == nil {
  43703. return
  43704. }
  43705. return *v, true
  43706. }
  43707. // OldNickname returns the old "nickname" field's value of the Wx entity.
  43708. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43710. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  43711. if !m.op.Is(OpUpdateOne) {
  43712. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43713. }
  43714. if m.id == nil || m.oldValue == nil {
  43715. return v, errors.New("OldNickname requires an ID field in the mutation")
  43716. }
  43717. oldValue, err := m.oldValue(ctx)
  43718. if err != nil {
  43719. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43720. }
  43721. return oldValue.Nickname, nil
  43722. }
  43723. // ResetNickname resets all changes to the "nickname" field.
  43724. func (m *WxMutation) ResetNickname() {
  43725. m.nickname = nil
  43726. }
  43727. // SetTel sets the "tel" field.
  43728. func (m *WxMutation) SetTel(s string) {
  43729. m.tel = &s
  43730. }
  43731. // Tel returns the value of the "tel" field in the mutation.
  43732. func (m *WxMutation) Tel() (r string, exists bool) {
  43733. v := m.tel
  43734. if v == nil {
  43735. return
  43736. }
  43737. return *v, true
  43738. }
  43739. // OldTel returns the old "tel" field's value of the Wx entity.
  43740. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43742. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  43743. if !m.op.Is(OpUpdateOne) {
  43744. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  43745. }
  43746. if m.id == nil || m.oldValue == nil {
  43747. return v, errors.New("OldTel requires an ID field in the mutation")
  43748. }
  43749. oldValue, err := m.oldValue(ctx)
  43750. if err != nil {
  43751. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  43752. }
  43753. return oldValue.Tel, nil
  43754. }
  43755. // ResetTel resets all changes to the "tel" field.
  43756. func (m *WxMutation) ResetTel() {
  43757. m.tel = nil
  43758. }
  43759. // SetHeadBig sets the "head_big" field.
  43760. func (m *WxMutation) SetHeadBig(s string) {
  43761. m.head_big = &s
  43762. }
  43763. // HeadBig returns the value of the "head_big" field in the mutation.
  43764. func (m *WxMutation) HeadBig() (r string, exists bool) {
  43765. v := m.head_big
  43766. if v == nil {
  43767. return
  43768. }
  43769. return *v, true
  43770. }
  43771. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  43772. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43774. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  43775. if !m.op.Is(OpUpdateOne) {
  43776. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  43777. }
  43778. if m.id == nil || m.oldValue == nil {
  43779. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  43780. }
  43781. oldValue, err := m.oldValue(ctx)
  43782. if err != nil {
  43783. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  43784. }
  43785. return oldValue.HeadBig, nil
  43786. }
  43787. // ResetHeadBig resets all changes to the "head_big" field.
  43788. func (m *WxMutation) ResetHeadBig() {
  43789. m.head_big = nil
  43790. }
  43791. // SetOrganizationID sets the "organization_id" field.
  43792. func (m *WxMutation) SetOrganizationID(u uint64) {
  43793. m.organization_id = &u
  43794. m.addorganization_id = nil
  43795. }
  43796. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43797. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  43798. v := m.organization_id
  43799. if v == nil {
  43800. return
  43801. }
  43802. return *v, true
  43803. }
  43804. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  43805. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43807. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43808. if !m.op.Is(OpUpdateOne) {
  43809. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43810. }
  43811. if m.id == nil || m.oldValue == nil {
  43812. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43813. }
  43814. oldValue, err := m.oldValue(ctx)
  43815. if err != nil {
  43816. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43817. }
  43818. return oldValue.OrganizationID, nil
  43819. }
  43820. // AddOrganizationID adds u to the "organization_id" field.
  43821. func (m *WxMutation) AddOrganizationID(u int64) {
  43822. if m.addorganization_id != nil {
  43823. *m.addorganization_id += u
  43824. } else {
  43825. m.addorganization_id = &u
  43826. }
  43827. }
  43828. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43829. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  43830. v := m.addorganization_id
  43831. if v == nil {
  43832. return
  43833. }
  43834. return *v, true
  43835. }
  43836. // ClearOrganizationID clears the value of the "organization_id" field.
  43837. func (m *WxMutation) ClearOrganizationID() {
  43838. m.organization_id = nil
  43839. m.addorganization_id = nil
  43840. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  43841. }
  43842. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43843. func (m *WxMutation) OrganizationIDCleared() bool {
  43844. _, ok := m.clearedFields[wx.FieldOrganizationID]
  43845. return ok
  43846. }
  43847. // ResetOrganizationID resets all changes to the "organization_id" field.
  43848. func (m *WxMutation) ResetOrganizationID() {
  43849. m.organization_id = nil
  43850. m.addorganization_id = nil
  43851. delete(m.clearedFields, wx.FieldOrganizationID)
  43852. }
  43853. // SetAgentID sets the "agent_id" field.
  43854. func (m *WxMutation) SetAgentID(u uint64) {
  43855. m.agent = &u
  43856. }
  43857. // AgentID returns the value of the "agent_id" field in the mutation.
  43858. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  43859. v := m.agent
  43860. if v == nil {
  43861. return
  43862. }
  43863. return *v, true
  43864. }
  43865. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  43866. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43868. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  43869. if !m.op.Is(OpUpdateOne) {
  43870. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  43871. }
  43872. if m.id == nil || m.oldValue == nil {
  43873. return v, errors.New("OldAgentID requires an ID field in the mutation")
  43874. }
  43875. oldValue, err := m.oldValue(ctx)
  43876. if err != nil {
  43877. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  43878. }
  43879. return oldValue.AgentID, nil
  43880. }
  43881. // ResetAgentID resets all changes to the "agent_id" field.
  43882. func (m *WxMutation) ResetAgentID() {
  43883. m.agent = nil
  43884. }
  43885. // SetAPIBase sets the "api_base" field.
  43886. func (m *WxMutation) SetAPIBase(s string) {
  43887. m.api_base = &s
  43888. }
  43889. // APIBase returns the value of the "api_base" field in the mutation.
  43890. func (m *WxMutation) APIBase() (r string, exists bool) {
  43891. v := m.api_base
  43892. if v == nil {
  43893. return
  43894. }
  43895. return *v, true
  43896. }
  43897. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  43898. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43900. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43901. if !m.op.Is(OpUpdateOne) {
  43902. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43903. }
  43904. if m.id == nil || m.oldValue == nil {
  43905. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43906. }
  43907. oldValue, err := m.oldValue(ctx)
  43908. if err != nil {
  43909. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43910. }
  43911. return oldValue.APIBase, nil
  43912. }
  43913. // ClearAPIBase clears the value of the "api_base" field.
  43914. func (m *WxMutation) ClearAPIBase() {
  43915. m.api_base = nil
  43916. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  43917. }
  43918. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43919. func (m *WxMutation) APIBaseCleared() bool {
  43920. _, ok := m.clearedFields[wx.FieldAPIBase]
  43921. return ok
  43922. }
  43923. // ResetAPIBase resets all changes to the "api_base" field.
  43924. func (m *WxMutation) ResetAPIBase() {
  43925. m.api_base = nil
  43926. delete(m.clearedFields, wx.FieldAPIBase)
  43927. }
  43928. // SetAPIKey sets the "api_key" field.
  43929. func (m *WxMutation) SetAPIKey(s string) {
  43930. m.api_key = &s
  43931. }
  43932. // APIKey returns the value of the "api_key" field in the mutation.
  43933. func (m *WxMutation) APIKey() (r string, exists bool) {
  43934. v := m.api_key
  43935. if v == nil {
  43936. return
  43937. }
  43938. return *v, true
  43939. }
  43940. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  43941. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43943. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43944. if !m.op.Is(OpUpdateOne) {
  43945. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43946. }
  43947. if m.id == nil || m.oldValue == nil {
  43948. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43949. }
  43950. oldValue, err := m.oldValue(ctx)
  43951. if err != nil {
  43952. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43953. }
  43954. return oldValue.APIKey, nil
  43955. }
  43956. // ClearAPIKey clears the value of the "api_key" field.
  43957. func (m *WxMutation) ClearAPIKey() {
  43958. m.api_key = nil
  43959. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  43960. }
  43961. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43962. func (m *WxMutation) APIKeyCleared() bool {
  43963. _, ok := m.clearedFields[wx.FieldAPIKey]
  43964. return ok
  43965. }
  43966. // ResetAPIKey resets all changes to the "api_key" field.
  43967. func (m *WxMutation) ResetAPIKey() {
  43968. m.api_key = nil
  43969. delete(m.clearedFields, wx.FieldAPIKey)
  43970. }
  43971. // SetAllowList sets the "allow_list" field.
  43972. func (m *WxMutation) SetAllowList(s []string) {
  43973. m.allow_list = &s
  43974. m.appendallow_list = nil
  43975. }
  43976. // AllowList returns the value of the "allow_list" field in the mutation.
  43977. func (m *WxMutation) AllowList() (r []string, exists bool) {
  43978. v := m.allow_list
  43979. if v == nil {
  43980. return
  43981. }
  43982. return *v, true
  43983. }
  43984. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  43985. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43987. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  43988. if !m.op.Is(OpUpdateOne) {
  43989. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  43990. }
  43991. if m.id == nil || m.oldValue == nil {
  43992. return v, errors.New("OldAllowList requires an ID field in the mutation")
  43993. }
  43994. oldValue, err := m.oldValue(ctx)
  43995. if err != nil {
  43996. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  43997. }
  43998. return oldValue.AllowList, nil
  43999. }
  44000. // AppendAllowList adds s to the "allow_list" field.
  44001. func (m *WxMutation) AppendAllowList(s []string) {
  44002. m.appendallow_list = append(m.appendallow_list, s...)
  44003. }
  44004. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  44005. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  44006. if len(m.appendallow_list) == 0 {
  44007. return nil, false
  44008. }
  44009. return m.appendallow_list, true
  44010. }
  44011. // ResetAllowList resets all changes to the "allow_list" field.
  44012. func (m *WxMutation) ResetAllowList() {
  44013. m.allow_list = nil
  44014. m.appendallow_list = nil
  44015. }
  44016. // SetGroupAllowList sets the "group_allow_list" field.
  44017. func (m *WxMutation) SetGroupAllowList(s []string) {
  44018. m.group_allow_list = &s
  44019. m.appendgroup_allow_list = nil
  44020. }
  44021. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  44022. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  44023. v := m.group_allow_list
  44024. if v == nil {
  44025. return
  44026. }
  44027. return *v, true
  44028. }
  44029. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  44030. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44032. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  44033. if !m.op.Is(OpUpdateOne) {
  44034. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  44035. }
  44036. if m.id == nil || m.oldValue == nil {
  44037. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  44038. }
  44039. oldValue, err := m.oldValue(ctx)
  44040. if err != nil {
  44041. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  44042. }
  44043. return oldValue.GroupAllowList, nil
  44044. }
  44045. // AppendGroupAllowList adds s to the "group_allow_list" field.
  44046. func (m *WxMutation) AppendGroupAllowList(s []string) {
  44047. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  44048. }
  44049. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  44050. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  44051. if len(m.appendgroup_allow_list) == 0 {
  44052. return nil, false
  44053. }
  44054. return m.appendgroup_allow_list, true
  44055. }
  44056. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  44057. func (m *WxMutation) ResetGroupAllowList() {
  44058. m.group_allow_list = nil
  44059. m.appendgroup_allow_list = nil
  44060. }
  44061. // SetBlockList sets the "block_list" field.
  44062. func (m *WxMutation) SetBlockList(s []string) {
  44063. m.block_list = &s
  44064. m.appendblock_list = nil
  44065. }
  44066. // BlockList returns the value of the "block_list" field in the mutation.
  44067. func (m *WxMutation) BlockList() (r []string, exists bool) {
  44068. v := m.block_list
  44069. if v == nil {
  44070. return
  44071. }
  44072. return *v, true
  44073. }
  44074. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  44075. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44077. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  44078. if !m.op.Is(OpUpdateOne) {
  44079. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  44080. }
  44081. if m.id == nil || m.oldValue == nil {
  44082. return v, errors.New("OldBlockList requires an ID field in the mutation")
  44083. }
  44084. oldValue, err := m.oldValue(ctx)
  44085. if err != nil {
  44086. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  44087. }
  44088. return oldValue.BlockList, nil
  44089. }
  44090. // AppendBlockList adds s to the "block_list" field.
  44091. func (m *WxMutation) AppendBlockList(s []string) {
  44092. m.appendblock_list = append(m.appendblock_list, s...)
  44093. }
  44094. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  44095. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  44096. if len(m.appendblock_list) == 0 {
  44097. return nil, false
  44098. }
  44099. return m.appendblock_list, true
  44100. }
  44101. // ResetBlockList resets all changes to the "block_list" field.
  44102. func (m *WxMutation) ResetBlockList() {
  44103. m.block_list = nil
  44104. m.appendblock_list = nil
  44105. }
  44106. // SetGroupBlockList sets the "group_block_list" field.
  44107. func (m *WxMutation) SetGroupBlockList(s []string) {
  44108. m.group_block_list = &s
  44109. m.appendgroup_block_list = nil
  44110. }
  44111. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  44112. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  44113. v := m.group_block_list
  44114. if v == nil {
  44115. return
  44116. }
  44117. return *v, true
  44118. }
  44119. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  44120. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44122. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  44123. if !m.op.Is(OpUpdateOne) {
  44124. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  44125. }
  44126. if m.id == nil || m.oldValue == nil {
  44127. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  44128. }
  44129. oldValue, err := m.oldValue(ctx)
  44130. if err != nil {
  44131. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  44132. }
  44133. return oldValue.GroupBlockList, nil
  44134. }
  44135. // AppendGroupBlockList adds s to the "group_block_list" field.
  44136. func (m *WxMutation) AppendGroupBlockList(s []string) {
  44137. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  44138. }
  44139. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  44140. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  44141. if len(m.appendgroup_block_list) == 0 {
  44142. return nil, false
  44143. }
  44144. return m.appendgroup_block_list, true
  44145. }
  44146. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  44147. func (m *WxMutation) ResetGroupBlockList() {
  44148. m.group_block_list = nil
  44149. m.appendgroup_block_list = nil
  44150. }
  44151. // SetCtype sets the "ctype" field.
  44152. func (m *WxMutation) SetCtype(u uint64) {
  44153. m.ctype = &u
  44154. m.addctype = nil
  44155. }
  44156. // Ctype returns the value of the "ctype" field in the mutation.
  44157. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  44158. v := m.ctype
  44159. if v == nil {
  44160. return
  44161. }
  44162. return *v, true
  44163. }
  44164. // OldCtype returns the old "ctype" field's value of the Wx entity.
  44165. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44167. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  44168. if !m.op.Is(OpUpdateOne) {
  44169. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  44170. }
  44171. if m.id == nil || m.oldValue == nil {
  44172. return v, errors.New("OldCtype requires an ID field in the mutation")
  44173. }
  44174. oldValue, err := m.oldValue(ctx)
  44175. if err != nil {
  44176. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  44177. }
  44178. return oldValue.Ctype, nil
  44179. }
  44180. // AddCtype adds u to the "ctype" field.
  44181. func (m *WxMutation) AddCtype(u int64) {
  44182. if m.addctype != nil {
  44183. *m.addctype += u
  44184. } else {
  44185. m.addctype = &u
  44186. }
  44187. }
  44188. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  44189. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  44190. v := m.addctype
  44191. if v == nil {
  44192. return
  44193. }
  44194. return *v, true
  44195. }
  44196. // ClearCtype clears the value of the "ctype" field.
  44197. func (m *WxMutation) ClearCtype() {
  44198. m.ctype = nil
  44199. m.addctype = nil
  44200. m.clearedFields[wx.FieldCtype] = struct{}{}
  44201. }
  44202. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  44203. func (m *WxMutation) CtypeCleared() bool {
  44204. _, ok := m.clearedFields[wx.FieldCtype]
  44205. return ok
  44206. }
  44207. // ResetCtype resets all changes to the "ctype" field.
  44208. func (m *WxMutation) ResetCtype() {
  44209. m.ctype = nil
  44210. m.addctype = nil
  44211. delete(m.clearedFields, wx.FieldCtype)
  44212. }
  44213. // ClearServer clears the "server" edge to the Server entity.
  44214. func (m *WxMutation) ClearServer() {
  44215. m.clearedserver = true
  44216. m.clearedFields[wx.FieldServerID] = struct{}{}
  44217. }
  44218. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  44219. func (m *WxMutation) ServerCleared() bool {
  44220. return m.ServerIDCleared() || m.clearedserver
  44221. }
  44222. // ServerIDs returns the "server" edge IDs in the mutation.
  44223. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44224. // ServerID instead. It exists only for internal usage by the builders.
  44225. func (m *WxMutation) ServerIDs() (ids []uint64) {
  44226. if id := m.server; id != nil {
  44227. ids = append(ids, *id)
  44228. }
  44229. return
  44230. }
  44231. // ResetServer resets all changes to the "server" edge.
  44232. func (m *WxMutation) ResetServer() {
  44233. m.server = nil
  44234. m.clearedserver = false
  44235. }
  44236. // ClearAgent clears the "agent" edge to the Agent entity.
  44237. func (m *WxMutation) ClearAgent() {
  44238. m.clearedagent = true
  44239. m.clearedFields[wx.FieldAgentID] = struct{}{}
  44240. }
  44241. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  44242. func (m *WxMutation) AgentCleared() bool {
  44243. return m.clearedagent
  44244. }
  44245. // AgentIDs returns the "agent" edge IDs in the mutation.
  44246. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44247. // AgentID instead. It exists only for internal usage by the builders.
  44248. func (m *WxMutation) AgentIDs() (ids []uint64) {
  44249. if id := m.agent; id != nil {
  44250. ids = append(ids, *id)
  44251. }
  44252. return
  44253. }
  44254. // ResetAgent resets all changes to the "agent" edge.
  44255. func (m *WxMutation) ResetAgent() {
  44256. m.agent = nil
  44257. m.clearedagent = false
  44258. }
  44259. // Where appends a list predicates to the WxMutation builder.
  44260. func (m *WxMutation) Where(ps ...predicate.Wx) {
  44261. m.predicates = append(m.predicates, ps...)
  44262. }
  44263. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  44264. // users can use type-assertion to append predicates that do not depend on any generated package.
  44265. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  44266. p := make([]predicate.Wx, len(ps))
  44267. for i := range ps {
  44268. p[i] = ps[i]
  44269. }
  44270. m.Where(p...)
  44271. }
  44272. // Op returns the operation name.
  44273. func (m *WxMutation) Op() Op {
  44274. return m.op
  44275. }
  44276. // SetOp allows setting the mutation operation.
  44277. func (m *WxMutation) SetOp(op Op) {
  44278. m.op = op
  44279. }
  44280. // Type returns the node type of this mutation (Wx).
  44281. func (m *WxMutation) Type() string {
  44282. return m.typ
  44283. }
  44284. // Fields returns all fields that were changed during this mutation. Note that in
  44285. // order to get all numeric fields that were incremented/decremented, call
  44286. // AddedFields().
  44287. func (m *WxMutation) Fields() []string {
  44288. fields := make([]string, 0, 22)
  44289. if m.created_at != nil {
  44290. fields = append(fields, wx.FieldCreatedAt)
  44291. }
  44292. if m.updated_at != nil {
  44293. fields = append(fields, wx.FieldUpdatedAt)
  44294. }
  44295. if m.status != nil {
  44296. fields = append(fields, wx.FieldStatus)
  44297. }
  44298. if m.deleted_at != nil {
  44299. fields = append(fields, wx.FieldDeletedAt)
  44300. }
  44301. if m.server != nil {
  44302. fields = append(fields, wx.FieldServerID)
  44303. }
  44304. if m.port != nil {
  44305. fields = append(fields, wx.FieldPort)
  44306. }
  44307. if m.process_id != nil {
  44308. fields = append(fields, wx.FieldProcessID)
  44309. }
  44310. if m.callback != nil {
  44311. fields = append(fields, wx.FieldCallback)
  44312. }
  44313. if m.wxid != nil {
  44314. fields = append(fields, wx.FieldWxid)
  44315. }
  44316. if m.account != nil {
  44317. fields = append(fields, wx.FieldAccount)
  44318. }
  44319. if m.nickname != nil {
  44320. fields = append(fields, wx.FieldNickname)
  44321. }
  44322. if m.tel != nil {
  44323. fields = append(fields, wx.FieldTel)
  44324. }
  44325. if m.head_big != nil {
  44326. fields = append(fields, wx.FieldHeadBig)
  44327. }
  44328. if m.organization_id != nil {
  44329. fields = append(fields, wx.FieldOrganizationID)
  44330. }
  44331. if m.agent != nil {
  44332. fields = append(fields, wx.FieldAgentID)
  44333. }
  44334. if m.api_base != nil {
  44335. fields = append(fields, wx.FieldAPIBase)
  44336. }
  44337. if m.api_key != nil {
  44338. fields = append(fields, wx.FieldAPIKey)
  44339. }
  44340. if m.allow_list != nil {
  44341. fields = append(fields, wx.FieldAllowList)
  44342. }
  44343. if m.group_allow_list != nil {
  44344. fields = append(fields, wx.FieldGroupAllowList)
  44345. }
  44346. if m.block_list != nil {
  44347. fields = append(fields, wx.FieldBlockList)
  44348. }
  44349. if m.group_block_list != nil {
  44350. fields = append(fields, wx.FieldGroupBlockList)
  44351. }
  44352. if m.ctype != nil {
  44353. fields = append(fields, wx.FieldCtype)
  44354. }
  44355. return fields
  44356. }
  44357. // Field returns the value of a field with the given name. The second boolean
  44358. // return value indicates that this field was not set, or was not defined in the
  44359. // schema.
  44360. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  44361. switch name {
  44362. case wx.FieldCreatedAt:
  44363. return m.CreatedAt()
  44364. case wx.FieldUpdatedAt:
  44365. return m.UpdatedAt()
  44366. case wx.FieldStatus:
  44367. return m.Status()
  44368. case wx.FieldDeletedAt:
  44369. return m.DeletedAt()
  44370. case wx.FieldServerID:
  44371. return m.ServerID()
  44372. case wx.FieldPort:
  44373. return m.Port()
  44374. case wx.FieldProcessID:
  44375. return m.ProcessID()
  44376. case wx.FieldCallback:
  44377. return m.Callback()
  44378. case wx.FieldWxid:
  44379. return m.Wxid()
  44380. case wx.FieldAccount:
  44381. return m.Account()
  44382. case wx.FieldNickname:
  44383. return m.Nickname()
  44384. case wx.FieldTel:
  44385. return m.Tel()
  44386. case wx.FieldHeadBig:
  44387. return m.HeadBig()
  44388. case wx.FieldOrganizationID:
  44389. return m.OrganizationID()
  44390. case wx.FieldAgentID:
  44391. return m.AgentID()
  44392. case wx.FieldAPIBase:
  44393. return m.APIBase()
  44394. case wx.FieldAPIKey:
  44395. return m.APIKey()
  44396. case wx.FieldAllowList:
  44397. return m.AllowList()
  44398. case wx.FieldGroupAllowList:
  44399. return m.GroupAllowList()
  44400. case wx.FieldBlockList:
  44401. return m.BlockList()
  44402. case wx.FieldGroupBlockList:
  44403. return m.GroupBlockList()
  44404. case wx.FieldCtype:
  44405. return m.Ctype()
  44406. }
  44407. return nil, false
  44408. }
  44409. // OldField returns the old value of the field from the database. An error is
  44410. // returned if the mutation operation is not UpdateOne, or the query to the
  44411. // database failed.
  44412. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44413. switch name {
  44414. case wx.FieldCreatedAt:
  44415. return m.OldCreatedAt(ctx)
  44416. case wx.FieldUpdatedAt:
  44417. return m.OldUpdatedAt(ctx)
  44418. case wx.FieldStatus:
  44419. return m.OldStatus(ctx)
  44420. case wx.FieldDeletedAt:
  44421. return m.OldDeletedAt(ctx)
  44422. case wx.FieldServerID:
  44423. return m.OldServerID(ctx)
  44424. case wx.FieldPort:
  44425. return m.OldPort(ctx)
  44426. case wx.FieldProcessID:
  44427. return m.OldProcessID(ctx)
  44428. case wx.FieldCallback:
  44429. return m.OldCallback(ctx)
  44430. case wx.FieldWxid:
  44431. return m.OldWxid(ctx)
  44432. case wx.FieldAccount:
  44433. return m.OldAccount(ctx)
  44434. case wx.FieldNickname:
  44435. return m.OldNickname(ctx)
  44436. case wx.FieldTel:
  44437. return m.OldTel(ctx)
  44438. case wx.FieldHeadBig:
  44439. return m.OldHeadBig(ctx)
  44440. case wx.FieldOrganizationID:
  44441. return m.OldOrganizationID(ctx)
  44442. case wx.FieldAgentID:
  44443. return m.OldAgentID(ctx)
  44444. case wx.FieldAPIBase:
  44445. return m.OldAPIBase(ctx)
  44446. case wx.FieldAPIKey:
  44447. return m.OldAPIKey(ctx)
  44448. case wx.FieldAllowList:
  44449. return m.OldAllowList(ctx)
  44450. case wx.FieldGroupAllowList:
  44451. return m.OldGroupAllowList(ctx)
  44452. case wx.FieldBlockList:
  44453. return m.OldBlockList(ctx)
  44454. case wx.FieldGroupBlockList:
  44455. return m.OldGroupBlockList(ctx)
  44456. case wx.FieldCtype:
  44457. return m.OldCtype(ctx)
  44458. }
  44459. return nil, fmt.Errorf("unknown Wx field %s", name)
  44460. }
  44461. // SetField sets the value of a field with the given name. It returns an error if
  44462. // the field is not defined in the schema, or if the type mismatched the field
  44463. // type.
  44464. func (m *WxMutation) SetField(name string, value ent.Value) error {
  44465. switch name {
  44466. case wx.FieldCreatedAt:
  44467. v, ok := value.(time.Time)
  44468. if !ok {
  44469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44470. }
  44471. m.SetCreatedAt(v)
  44472. return nil
  44473. case wx.FieldUpdatedAt:
  44474. v, ok := value.(time.Time)
  44475. if !ok {
  44476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44477. }
  44478. m.SetUpdatedAt(v)
  44479. return nil
  44480. case wx.FieldStatus:
  44481. v, ok := value.(uint8)
  44482. if !ok {
  44483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44484. }
  44485. m.SetStatus(v)
  44486. return nil
  44487. case wx.FieldDeletedAt:
  44488. v, ok := value.(time.Time)
  44489. if !ok {
  44490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44491. }
  44492. m.SetDeletedAt(v)
  44493. return nil
  44494. case wx.FieldServerID:
  44495. v, ok := value.(uint64)
  44496. if !ok {
  44497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44498. }
  44499. m.SetServerID(v)
  44500. return nil
  44501. case wx.FieldPort:
  44502. v, ok := value.(string)
  44503. if !ok {
  44504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44505. }
  44506. m.SetPort(v)
  44507. return nil
  44508. case wx.FieldProcessID:
  44509. v, ok := value.(string)
  44510. if !ok {
  44511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44512. }
  44513. m.SetProcessID(v)
  44514. return nil
  44515. case wx.FieldCallback:
  44516. v, ok := value.(string)
  44517. if !ok {
  44518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44519. }
  44520. m.SetCallback(v)
  44521. return nil
  44522. case wx.FieldWxid:
  44523. v, ok := value.(string)
  44524. if !ok {
  44525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44526. }
  44527. m.SetWxid(v)
  44528. return nil
  44529. case wx.FieldAccount:
  44530. v, ok := value.(string)
  44531. if !ok {
  44532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44533. }
  44534. m.SetAccount(v)
  44535. return nil
  44536. case wx.FieldNickname:
  44537. v, ok := value.(string)
  44538. if !ok {
  44539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44540. }
  44541. m.SetNickname(v)
  44542. return nil
  44543. case wx.FieldTel:
  44544. v, ok := value.(string)
  44545. if !ok {
  44546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44547. }
  44548. m.SetTel(v)
  44549. return nil
  44550. case wx.FieldHeadBig:
  44551. v, ok := value.(string)
  44552. if !ok {
  44553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44554. }
  44555. m.SetHeadBig(v)
  44556. return nil
  44557. case wx.FieldOrganizationID:
  44558. v, ok := value.(uint64)
  44559. if !ok {
  44560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44561. }
  44562. m.SetOrganizationID(v)
  44563. return nil
  44564. case wx.FieldAgentID:
  44565. v, ok := value.(uint64)
  44566. if !ok {
  44567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44568. }
  44569. m.SetAgentID(v)
  44570. return nil
  44571. case wx.FieldAPIBase:
  44572. v, ok := value.(string)
  44573. if !ok {
  44574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44575. }
  44576. m.SetAPIBase(v)
  44577. return nil
  44578. case wx.FieldAPIKey:
  44579. v, ok := value.(string)
  44580. if !ok {
  44581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44582. }
  44583. m.SetAPIKey(v)
  44584. return nil
  44585. case wx.FieldAllowList:
  44586. v, ok := value.([]string)
  44587. if !ok {
  44588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44589. }
  44590. m.SetAllowList(v)
  44591. return nil
  44592. case wx.FieldGroupAllowList:
  44593. v, ok := value.([]string)
  44594. if !ok {
  44595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44596. }
  44597. m.SetGroupAllowList(v)
  44598. return nil
  44599. case wx.FieldBlockList:
  44600. v, ok := value.([]string)
  44601. if !ok {
  44602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44603. }
  44604. m.SetBlockList(v)
  44605. return nil
  44606. case wx.FieldGroupBlockList:
  44607. v, ok := value.([]string)
  44608. if !ok {
  44609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44610. }
  44611. m.SetGroupBlockList(v)
  44612. return nil
  44613. case wx.FieldCtype:
  44614. v, ok := value.(uint64)
  44615. if !ok {
  44616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44617. }
  44618. m.SetCtype(v)
  44619. return nil
  44620. }
  44621. return fmt.Errorf("unknown Wx field %s", name)
  44622. }
  44623. // AddedFields returns all numeric fields that were incremented/decremented during
  44624. // this mutation.
  44625. func (m *WxMutation) AddedFields() []string {
  44626. var fields []string
  44627. if m.addstatus != nil {
  44628. fields = append(fields, wx.FieldStatus)
  44629. }
  44630. if m.addorganization_id != nil {
  44631. fields = append(fields, wx.FieldOrganizationID)
  44632. }
  44633. if m.addctype != nil {
  44634. fields = append(fields, wx.FieldCtype)
  44635. }
  44636. return fields
  44637. }
  44638. // AddedField returns the numeric value that was incremented/decremented on a field
  44639. // with the given name. The second boolean return value indicates that this field
  44640. // was not set, or was not defined in the schema.
  44641. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  44642. switch name {
  44643. case wx.FieldStatus:
  44644. return m.AddedStatus()
  44645. case wx.FieldOrganizationID:
  44646. return m.AddedOrganizationID()
  44647. case wx.FieldCtype:
  44648. return m.AddedCtype()
  44649. }
  44650. return nil, false
  44651. }
  44652. // AddField adds the value to the field with the given name. It returns an error if
  44653. // the field is not defined in the schema, or if the type mismatched the field
  44654. // type.
  44655. func (m *WxMutation) AddField(name string, value ent.Value) error {
  44656. switch name {
  44657. case wx.FieldStatus:
  44658. v, ok := value.(int8)
  44659. if !ok {
  44660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44661. }
  44662. m.AddStatus(v)
  44663. return nil
  44664. case wx.FieldOrganizationID:
  44665. v, ok := value.(int64)
  44666. if !ok {
  44667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44668. }
  44669. m.AddOrganizationID(v)
  44670. return nil
  44671. case wx.FieldCtype:
  44672. v, ok := value.(int64)
  44673. if !ok {
  44674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44675. }
  44676. m.AddCtype(v)
  44677. return nil
  44678. }
  44679. return fmt.Errorf("unknown Wx numeric field %s", name)
  44680. }
  44681. // ClearedFields returns all nullable fields that were cleared during this
  44682. // mutation.
  44683. func (m *WxMutation) ClearedFields() []string {
  44684. var fields []string
  44685. if m.FieldCleared(wx.FieldStatus) {
  44686. fields = append(fields, wx.FieldStatus)
  44687. }
  44688. if m.FieldCleared(wx.FieldDeletedAt) {
  44689. fields = append(fields, wx.FieldDeletedAt)
  44690. }
  44691. if m.FieldCleared(wx.FieldServerID) {
  44692. fields = append(fields, wx.FieldServerID)
  44693. }
  44694. if m.FieldCleared(wx.FieldOrganizationID) {
  44695. fields = append(fields, wx.FieldOrganizationID)
  44696. }
  44697. if m.FieldCleared(wx.FieldAPIBase) {
  44698. fields = append(fields, wx.FieldAPIBase)
  44699. }
  44700. if m.FieldCleared(wx.FieldAPIKey) {
  44701. fields = append(fields, wx.FieldAPIKey)
  44702. }
  44703. if m.FieldCleared(wx.FieldCtype) {
  44704. fields = append(fields, wx.FieldCtype)
  44705. }
  44706. return fields
  44707. }
  44708. // FieldCleared returns a boolean indicating if a field with the given name was
  44709. // cleared in this mutation.
  44710. func (m *WxMutation) FieldCleared(name string) bool {
  44711. _, ok := m.clearedFields[name]
  44712. return ok
  44713. }
  44714. // ClearField clears the value of the field with the given name. It returns an
  44715. // error if the field is not defined in the schema.
  44716. func (m *WxMutation) ClearField(name string) error {
  44717. switch name {
  44718. case wx.FieldStatus:
  44719. m.ClearStatus()
  44720. return nil
  44721. case wx.FieldDeletedAt:
  44722. m.ClearDeletedAt()
  44723. return nil
  44724. case wx.FieldServerID:
  44725. m.ClearServerID()
  44726. return nil
  44727. case wx.FieldOrganizationID:
  44728. m.ClearOrganizationID()
  44729. return nil
  44730. case wx.FieldAPIBase:
  44731. m.ClearAPIBase()
  44732. return nil
  44733. case wx.FieldAPIKey:
  44734. m.ClearAPIKey()
  44735. return nil
  44736. case wx.FieldCtype:
  44737. m.ClearCtype()
  44738. return nil
  44739. }
  44740. return fmt.Errorf("unknown Wx nullable field %s", name)
  44741. }
  44742. // ResetField resets all changes in the mutation for the field with the given name.
  44743. // It returns an error if the field is not defined in the schema.
  44744. func (m *WxMutation) ResetField(name string) error {
  44745. switch name {
  44746. case wx.FieldCreatedAt:
  44747. m.ResetCreatedAt()
  44748. return nil
  44749. case wx.FieldUpdatedAt:
  44750. m.ResetUpdatedAt()
  44751. return nil
  44752. case wx.FieldStatus:
  44753. m.ResetStatus()
  44754. return nil
  44755. case wx.FieldDeletedAt:
  44756. m.ResetDeletedAt()
  44757. return nil
  44758. case wx.FieldServerID:
  44759. m.ResetServerID()
  44760. return nil
  44761. case wx.FieldPort:
  44762. m.ResetPort()
  44763. return nil
  44764. case wx.FieldProcessID:
  44765. m.ResetProcessID()
  44766. return nil
  44767. case wx.FieldCallback:
  44768. m.ResetCallback()
  44769. return nil
  44770. case wx.FieldWxid:
  44771. m.ResetWxid()
  44772. return nil
  44773. case wx.FieldAccount:
  44774. m.ResetAccount()
  44775. return nil
  44776. case wx.FieldNickname:
  44777. m.ResetNickname()
  44778. return nil
  44779. case wx.FieldTel:
  44780. m.ResetTel()
  44781. return nil
  44782. case wx.FieldHeadBig:
  44783. m.ResetHeadBig()
  44784. return nil
  44785. case wx.FieldOrganizationID:
  44786. m.ResetOrganizationID()
  44787. return nil
  44788. case wx.FieldAgentID:
  44789. m.ResetAgentID()
  44790. return nil
  44791. case wx.FieldAPIBase:
  44792. m.ResetAPIBase()
  44793. return nil
  44794. case wx.FieldAPIKey:
  44795. m.ResetAPIKey()
  44796. return nil
  44797. case wx.FieldAllowList:
  44798. m.ResetAllowList()
  44799. return nil
  44800. case wx.FieldGroupAllowList:
  44801. m.ResetGroupAllowList()
  44802. return nil
  44803. case wx.FieldBlockList:
  44804. m.ResetBlockList()
  44805. return nil
  44806. case wx.FieldGroupBlockList:
  44807. m.ResetGroupBlockList()
  44808. return nil
  44809. case wx.FieldCtype:
  44810. m.ResetCtype()
  44811. return nil
  44812. }
  44813. return fmt.Errorf("unknown Wx field %s", name)
  44814. }
  44815. // AddedEdges returns all edge names that were set/added in this mutation.
  44816. func (m *WxMutation) AddedEdges() []string {
  44817. edges := make([]string, 0, 2)
  44818. if m.server != nil {
  44819. edges = append(edges, wx.EdgeServer)
  44820. }
  44821. if m.agent != nil {
  44822. edges = append(edges, wx.EdgeAgent)
  44823. }
  44824. return edges
  44825. }
  44826. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44827. // name in this mutation.
  44828. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  44829. switch name {
  44830. case wx.EdgeServer:
  44831. if id := m.server; id != nil {
  44832. return []ent.Value{*id}
  44833. }
  44834. case wx.EdgeAgent:
  44835. if id := m.agent; id != nil {
  44836. return []ent.Value{*id}
  44837. }
  44838. }
  44839. return nil
  44840. }
  44841. // RemovedEdges returns all edge names that were removed in this mutation.
  44842. func (m *WxMutation) RemovedEdges() []string {
  44843. edges := make([]string, 0, 2)
  44844. return edges
  44845. }
  44846. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44847. // the given name in this mutation.
  44848. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  44849. return nil
  44850. }
  44851. // ClearedEdges returns all edge names that were cleared in this mutation.
  44852. func (m *WxMutation) ClearedEdges() []string {
  44853. edges := make([]string, 0, 2)
  44854. if m.clearedserver {
  44855. edges = append(edges, wx.EdgeServer)
  44856. }
  44857. if m.clearedagent {
  44858. edges = append(edges, wx.EdgeAgent)
  44859. }
  44860. return edges
  44861. }
  44862. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44863. // was cleared in this mutation.
  44864. func (m *WxMutation) EdgeCleared(name string) bool {
  44865. switch name {
  44866. case wx.EdgeServer:
  44867. return m.clearedserver
  44868. case wx.EdgeAgent:
  44869. return m.clearedagent
  44870. }
  44871. return false
  44872. }
  44873. // ClearEdge clears the value of the edge with the given name. It returns an error
  44874. // if that edge is not defined in the schema.
  44875. func (m *WxMutation) ClearEdge(name string) error {
  44876. switch name {
  44877. case wx.EdgeServer:
  44878. m.ClearServer()
  44879. return nil
  44880. case wx.EdgeAgent:
  44881. m.ClearAgent()
  44882. return nil
  44883. }
  44884. return fmt.Errorf("unknown Wx unique edge %s", name)
  44885. }
  44886. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44887. // It returns an error if the edge is not defined in the schema.
  44888. func (m *WxMutation) ResetEdge(name string) error {
  44889. switch name {
  44890. case wx.EdgeServer:
  44891. m.ResetServer()
  44892. return nil
  44893. case wx.EdgeAgent:
  44894. m.ResetAgent()
  44895. return nil
  44896. }
  44897. return fmt.Errorf("unknown Wx edge %s", name)
  44898. }
  44899. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  44900. type WxCardMutation struct {
  44901. config
  44902. op Op
  44903. typ string
  44904. id *uint64
  44905. created_at *time.Time
  44906. updated_at *time.Time
  44907. deleted_at *time.Time
  44908. user_id *uint64
  44909. adduser_id *int64
  44910. wx_user_id *uint64
  44911. addwx_user_id *int64
  44912. avatar *string
  44913. logo *string
  44914. name *string
  44915. company *string
  44916. address *string
  44917. phone *string
  44918. official_account *string
  44919. wechat_account *string
  44920. email *string
  44921. api_base *string
  44922. api_key *string
  44923. ai_info *string
  44924. intro *string
  44925. clearedFields map[string]struct{}
  44926. done bool
  44927. oldValue func(context.Context) (*WxCard, error)
  44928. predicates []predicate.WxCard
  44929. }
  44930. var _ ent.Mutation = (*WxCardMutation)(nil)
  44931. // wxcardOption allows management of the mutation configuration using functional options.
  44932. type wxcardOption func(*WxCardMutation)
  44933. // newWxCardMutation creates new mutation for the WxCard entity.
  44934. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  44935. m := &WxCardMutation{
  44936. config: c,
  44937. op: op,
  44938. typ: TypeWxCard,
  44939. clearedFields: make(map[string]struct{}),
  44940. }
  44941. for _, opt := range opts {
  44942. opt(m)
  44943. }
  44944. return m
  44945. }
  44946. // withWxCardID sets the ID field of the mutation.
  44947. func withWxCardID(id uint64) wxcardOption {
  44948. return func(m *WxCardMutation) {
  44949. var (
  44950. err error
  44951. once sync.Once
  44952. value *WxCard
  44953. )
  44954. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  44955. once.Do(func() {
  44956. if m.done {
  44957. err = errors.New("querying old values post mutation is not allowed")
  44958. } else {
  44959. value, err = m.Client().WxCard.Get(ctx, id)
  44960. }
  44961. })
  44962. return value, err
  44963. }
  44964. m.id = &id
  44965. }
  44966. }
  44967. // withWxCard sets the old WxCard of the mutation.
  44968. func withWxCard(node *WxCard) wxcardOption {
  44969. return func(m *WxCardMutation) {
  44970. m.oldValue = func(context.Context) (*WxCard, error) {
  44971. return node, nil
  44972. }
  44973. m.id = &node.ID
  44974. }
  44975. }
  44976. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44977. // executed in a transaction (ent.Tx), a transactional client is returned.
  44978. func (m WxCardMutation) Client() *Client {
  44979. client := &Client{config: m.config}
  44980. client.init()
  44981. return client
  44982. }
  44983. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44984. // it returns an error otherwise.
  44985. func (m WxCardMutation) Tx() (*Tx, error) {
  44986. if _, ok := m.driver.(*txDriver); !ok {
  44987. return nil, errors.New("ent: mutation is not running in a transaction")
  44988. }
  44989. tx := &Tx{config: m.config}
  44990. tx.init()
  44991. return tx, nil
  44992. }
  44993. // SetID sets the value of the id field. Note that this
  44994. // operation is only accepted on creation of WxCard entities.
  44995. func (m *WxCardMutation) SetID(id uint64) {
  44996. m.id = &id
  44997. }
  44998. // ID returns the ID value in the mutation. Note that the ID is only available
  44999. // if it was provided to the builder or after it was returned from the database.
  45000. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  45001. if m.id == nil {
  45002. return
  45003. }
  45004. return *m.id, true
  45005. }
  45006. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45007. // That means, if the mutation is applied within a transaction with an isolation level such
  45008. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45009. // or updated by the mutation.
  45010. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  45011. switch {
  45012. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45013. id, exists := m.ID()
  45014. if exists {
  45015. return []uint64{id}, nil
  45016. }
  45017. fallthrough
  45018. case m.op.Is(OpUpdate | OpDelete):
  45019. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  45020. default:
  45021. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45022. }
  45023. }
  45024. // SetCreatedAt sets the "created_at" field.
  45025. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  45026. m.created_at = &t
  45027. }
  45028. // CreatedAt returns the value of the "created_at" field in the mutation.
  45029. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  45030. v := m.created_at
  45031. if v == nil {
  45032. return
  45033. }
  45034. return *v, true
  45035. }
  45036. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  45037. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45039. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45040. if !m.op.Is(OpUpdateOne) {
  45041. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45042. }
  45043. if m.id == nil || m.oldValue == nil {
  45044. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45045. }
  45046. oldValue, err := m.oldValue(ctx)
  45047. if err != nil {
  45048. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45049. }
  45050. return oldValue.CreatedAt, nil
  45051. }
  45052. // ResetCreatedAt resets all changes to the "created_at" field.
  45053. func (m *WxCardMutation) ResetCreatedAt() {
  45054. m.created_at = nil
  45055. }
  45056. // SetUpdatedAt sets the "updated_at" field.
  45057. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  45058. m.updated_at = &t
  45059. }
  45060. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45061. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  45062. v := m.updated_at
  45063. if v == nil {
  45064. return
  45065. }
  45066. return *v, true
  45067. }
  45068. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  45069. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45071. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45072. if !m.op.Is(OpUpdateOne) {
  45073. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45074. }
  45075. if m.id == nil || m.oldValue == nil {
  45076. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45077. }
  45078. oldValue, err := m.oldValue(ctx)
  45079. if err != nil {
  45080. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45081. }
  45082. return oldValue.UpdatedAt, nil
  45083. }
  45084. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45085. func (m *WxCardMutation) ResetUpdatedAt() {
  45086. m.updated_at = nil
  45087. }
  45088. // SetDeletedAt sets the "deleted_at" field.
  45089. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  45090. m.deleted_at = &t
  45091. }
  45092. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45093. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  45094. v := m.deleted_at
  45095. if v == nil {
  45096. return
  45097. }
  45098. return *v, true
  45099. }
  45100. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  45101. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45103. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45104. if !m.op.Is(OpUpdateOne) {
  45105. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45106. }
  45107. if m.id == nil || m.oldValue == nil {
  45108. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45109. }
  45110. oldValue, err := m.oldValue(ctx)
  45111. if err != nil {
  45112. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45113. }
  45114. return oldValue.DeletedAt, nil
  45115. }
  45116. // ClearDeletedAt clears the value of the "deleted_at" field.
  45117. func (m *WxCardMutation) ClearDeletedAt() {
  45118. m.deleted_at = nil
  45119. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  45120. }
  45121. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45122. func (m *WxCardMutation) DeletedAtCleared() bool {
  45123. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  45124. return ok
  45125. }
  45126. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45127. func (m *WxCardMutation) ResetDeletedAt() {
  45128. m.deleted_at = nil
  45129. delete(m.clearedFields, wxcard.FieldDeletedAt)
  45130. }
  45131. // SetUserID sets the "user_id" field.
  45132. func (m *WxCardMutation) SetUserID(u uint64) {
  45133. m.user_id = &u
  45134. m.adduser_id = nil
  45135. }
  45136. // UserID returns the value of the "user_id" field in the mutation.
  45137. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  45138. v := m.user_id
  45139. if v == nil {
  45140. return
  45141. }
  45142. return *v, true
  45143. }
  45144. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  45145. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45147. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45148. if !m.op.Is(OpUpdateOne) {
  45149. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45150. }
  45151. if m.id == nil || m.oldValue == nil {
  45152. return v, errors.New("OldUserID requires an ID field in the mutation")
  45153. }
  45154. oldValue, err := m.oldValue(ctx)
  45155. if err != nil {
  45156. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45157. }
  45158. return oldValue.UserID, nil
  45159. }
  45160. // AddUserID adds u to the "user_id" field.
  45161. func (m *WxCardMutation) AddUserID(u int64) {
  45162. if m.adduser_id != nil {
  45163. *m.adduser_id += u
  45164. } else {
  45165. m.adduser_id = &u
  45166. }
  45167. }
  45168. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45169. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  45170. v := m.adduser_id
  45171. if v == nil {
  45172. return
  45173. }
  45174. return *v, true
  45175. }
  45176. // ClearUserID clears the value of the "user_id" field.
  45177. func (m *WxCardMutation) ClearUserID() {
  45178. m.user_id = nil
  45179. m.adduser_id = nil
  45180. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  45181. }
  45182. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45183. func (m *WxCardMutation) UserIDCleared() bool {
  45184. _, ok := m.clearedFields[wxcard.FieldUserID]
  45185. return ok
  45186. }
  45187. // ResetUserID resets all changes to the "user_id" field.
  45188. func (m *WxCardMutation) ResetUserID() {
  45189. m.user_id = nil
  45190. m.adduser_id = nil
  45191. delete(m.clearedFields, wxcard.FieldUserID)
  45192. }
  45193. // SetWxUserID sets the "wx_user_id" field.
  45194. func (m *WxCardMutation) SetWxUserID(u uint64) {
  45195. m.wx_user_id = &u
  45196. m.addwx_user_id = nil
  45197. }
  45198. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  45199. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  45200. v := m.wx_user_id
  45201. if v == nil {
  45202. return
  45203. }
  45204. return *v, true
  45205. }
  45206. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  45207. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45209. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  45210. if !m.op.Is(OpUpdateOne) {
  45211. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  45212. }
  45213. if m.id == nil || m.oldValue == nil {
  45214. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  45215. }
  45216. oldValue, err := m.oldValue(ctx)
  45217. if err != nil {
  45218. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  45219. }
  45220. return oldValue.WxUserID, nil
  45221. }
  45222. // AddWxUserID adds u to the "wx_user_id" field.
  45223. func (m *WxCardMutation) AddWxUserID(u int64) {
  45224. if m.addwx_user_id != nil {
  45225. *m.addwx_user_id += u
  45226. } else {
  45227. m.addwx_user_id = &u
  45228. }
  45229. }
  45230. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  45231. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  45232. v := m.addwx_user_id
  45233. if v == nil {
  45234. return
  45235. }
  45236. return *v, true
  45237. }
  45238. // ClearWxUserID clears the value of the "wx_user_id" field.
  45239. func (m *WxCardMutation) ClearWxUserID() {
  45240. m.wx_user_id = nil
  45241. m.addwx_user_id = nil
  45242. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  45243. }
  45244. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  45245. func (m *WxCardMutation) WxUserIDCleared() bool {
  45246. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  45247. return ok
  45248. }
  45249. // ResetWxUserID resets all changes to the "wx_user_id" field.
  45250. func (m *WxCardMutation) ResetWxUserID() {
  45251. m.wx_user_id = nil
  45252. m.addwx_user_id = nil
  45253. delete(m.clearedFields, wxcard.FieldWxUserID)
  45254. }
  45255. // SetAvatar sets the "avatar" field.
  45256. func (m *WxCardMutation) SetAvatar(s string) {
  45257. m.avatar = &s
  45258. }
  45259. // Avatar returns the value of the "avatar" field in the mutation.
  45260. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  45261. v := m.avatar
  45262. if v == nil {
  45263. return
  45264. }
  45265. return *v, true
  45266. }
  45267. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  45268. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45270. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45271. if !m.op.Is(OpUpdateOne) {
  45272. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45273. }
  45274. if m.id == nil || m.oldValue == nil {
  45275. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45276. }
  45277. oldValue, err := m.oldValue(ctx)
  45278. if err != nil {
  45279. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45280. }
  45281. return oldValue.Avatar, nil
  45282. }
  45283. // ResetAvatar resets all changes to the "avatar" field.
  45284. func (m *WxCardMutation) ResetAvatar() {
  45285. m.avatar = nil
  45286. }
  45287. // SetLogo sets the "logo" field.
  45288. func (m *WxCardMutation) SetLogo(s string) {
  45289. m.logo = &s
  45290. }
  45291. // Logo returns the value of the "logo" field in the mutation.
  45292. func (m *WxCardMutation) Logo() (r string, exists bool) {
  45293. v := m.logo
  45294. if v == nil {
  45295. return
  45296. }
  45297. return *v, true
  45298. }
  45299. // OldLogo returns the old "logo" field's value of the WxCard entity.
  45300. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45302. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  45303. if !m.op.Is(OpUpdateOne) {
  45304. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  45305. }
  45306. if m.id == nil || m.oldValue == nil {
  45307. return v, errors.New("OldLogo requires an ID field in the mutation")
  45308. }
  45309. oldValue, err := m.oldValue(ctx)
  45310. if err != nil {
  45311. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  45312. }
  45313. return oldValue.Logo, nil
  45314. }
  45315. // ResetLogo resets all changes to the "logo" field.
  45316. func (m *WxCardMutation) ResetLogo() {
  45317. m.logo = nil
  45318. }
  45319. // SetName sets the "name" field.
  45320. func (m *WxCardMutation) SetName(s string) {
  45321. m.name = &s
  45322. }
  45323. // Name returns the value of the "name" field in the mutation.
  45324. func (m *WxCardMutation) Name() (r string, exists bool) {
  45325. v := m.name
  45326. if v == nil {
  45327. return
  45328. }
  45329. return *v, true
  45330. }
  45331. // OldName returns the old "name" field's value of the WxCard entity.
  45332. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45334. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  45335. if !m.op.Is(OpUpdateOne) {
  45336. return v, errors.New("OldName is only allowed on UpdateOne operations")
  45337. }
  45338. if m.id == nil || m.oldValue == nil {
  45339. return v, errors.New("OldName requires an ID field in the mutation")
  45340. }
  45341. oldValue, err := m.oldValue(ctx)
  45342. if err != nil {
  45343. return v, fmt.Errorf("querying old value for OldName: %w", err)
  45344. }
  45345. return oldValue.Name, nil
  45346. }
  45347. // ResetName resets all changes to the "name" field.
  45348. func (m *WxCardMutation) ResetName() {
  45349. m.name = nil
  45350. }
  45351. // SetCompany sets the "company" field.
  45352. func (m *WxCardMutation) SetCompany(s string) {
  45353. m.company = &s
  45354. }
  45355. // Company returns the value of the "company" field in the mutation.
  45356. func (m *WxCardMutation) Company() (r string, exists bool) {
  45357. v := m.company
  45358. if v == nil {
  45359. return
  45360. }
  45361. return *v, true
  45362. }
  45363. // OldCompany returns the old "company" field's value of the WxCard entity.
  45364. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45366. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  45367. if !m.op.Is(OpUpdateOne) {
  45368. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  45369. }
  45370. if m.id == nil || m.oldValue == nil {
  45371. return v, errors.New("OldCompany requires an ID field in the mutation")
  45372. }
  45373. oldValue, err := m.oldValue(ctx)
  45374. if err != nil {
  45375. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  45376. }
  45377. return oldValue.Company, nil
  45378. }
  45379. // ResetCompany resets all changes to the "company" field.
  45380. func (m *WxCardMutation) ResetCompany() {
  45381. m.company = nil
  45382. }
  45383. // SetAddress sets the "address" field.
  45384. func (m *WxCardMutation) SetAddress(s string) {
  45385. m.address = &s
  45386. }
  45387. // Address returns the value of the "address" field in the mutation.
  45388. func (m *WxCardMutation) Address() (r string, exists bool) {
  45389. v := m.address
  45390. if v == nil {
  45391. return
  45392. }
  45393. return *v, true
  45394. }
  45395. // OldAddress returns the old "address" field's value of the WxCard entity.
  45396. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45398. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  45399. if !m.op.Is(OpUpdateOne) {
  45400. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  45401. }
  45402. if m.id == nil || m.oldValue == nil {
  45403. return v, errors.New("OldAddress requires an ID field in the mutation")
  45404. }
  45405. oldValue, err := m.oldValue(ctx)
  45406. if err != nil {
  45407. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  45408. }
  45409. return oldValue.Address, nil
  45410. }
  45411. // ResetAddress resets all changes to the "address" field.
  45412. func (m *WxCardMutation) ResetAddress() {
  45413. m.address = nil
  45414. }
  45415. // SetPhone sets the "phone" field.
  45416. func (m *WxCardMutation) SetPhone(s string) {
  45417. m.phone = &s
  45418. }
  45419. // Phone returns the value of the "phone" field in the mutation.
  45420. func (m *WxCardMutation) Phone() (r string, exists bool) {
  45421. v := m.phone
  45422. if v == nil {
  45423. return
  45424. }
  45425. return *v, true
  45426. }
  45427. // OldPhone returns the old "phone" field's value of the WxCard entity.
  45428. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45430. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  45431. if !m.op.Is(OpUpdateOne) {
  45432. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  45433. }
  45434. if m.id == nil || m.oldValue == nil {
  45435. return v, errors.New("OldPhone requires an ID field in the mutation")
  45436. }
  45437. oldValue, err := m.oldValue(ctx)
  45438. if err != nil {
  45439. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  45440. }
  45441. return oldValue.Phone, nil
  45442. }
  45443. // ResetPhone resets all changes to the "phone" field.
  45444. func (m *WxCardMutation) ResetPhone() {
  45445. m.phone = nil
  45446. }
  45447. // SetOfficialAccount sets the "official_account" field.
  45448. func (m *WxCardMutation) SetOfficialAccount(s string) {
  45449. m.official_account = &s
  45450. }
  45451. // OfficialAccount returns the value of the "official_account" field in the mutation.
  45452. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  45453. v := m.official_account
  45454. if v == nil {
  45455. return
  45456. }
  45457. return *v, true
  45458. }
  45459. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  45460. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45462. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  45463. if !m.op.Is(OpUpdateOne) {
  45464. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  45465. }
  45466. if m.id == nil || m.oldValue == nil {
  45467. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  45468. }
  45469. oldValue, err := m.oldValue(ctx)
  45470. if err != nil {
  45471. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  45472. }
  45473. return oldValue.OfficialAccount, nil
  45474. }
  45475. // ResetOfficialAccount resets all changes to the "official_account" field.
  45476. func (m *WxCardMutation) ResetOfficialAccount() {
  45477. m.official_account = nil
  45478. }
  45479. // SetWechatAccount sets the "wechat_account" field.
  45480. func (m *WxCardMutation) SetWechatAccount(s string) {
  45481. m.wechat_account = &s
  45482. }
  45483. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  45484. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  45485. v := m.wechat_account
  45486. if v == nil {
  45487. return
  45488. }
  45489. return *v, true
  45490. }
  45491. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  45492. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45494. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  45495. if !m.op.Is(OpUpdateOne) {
  45496. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  45497. }
  45498. if m.id == nil || m.oldValue == nil {
  45499. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  45500. }
  45501. oldValue, err := m.oldValue(ctx)
  45502. if err != nil {
  45503. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  45504. }
  45505. return oldValue.WechatAccount, nil
  45506. }
  45507. // ResetWechatAccount resets all changes to the "wechat_account" field.
  45508. func (m *WxCardMutation) ResetWechatAccount() {
  45509. m.wechat_account = nil
  45510. }
  45511. // SetEmail sets the "email" field.
  45512. func (m *WxCardMutation) SetEmail(s string) {
  45513. m.email = &s
  45514. }
  45515. // Email returns the value of the "email" field in the mutation.
  45516. func (m *WxCardMutation) Email() (r string, exists bool) {
  45517. v := m.email
  45518. if v == nil {
  45519. return
  45520. }
  45521. return *v, true
  45522. }
  45523. // OldEmail returns the old "email" field's value of the WxCard entity.
  45524. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45526. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  45527. if !m.op.Is(OpUpdateOne) {
  45528. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  45529. }
  45530. if m.id == nil || m.oldValue == nil {
  45531. return v, errors.New("OldEmail requires an ID field in the mutation")
  45532. }
  45533. oldValue, err := m.oldValue(ctx)
  45534. if err != nil {
  45535. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  45536. }
  45537. return oldValue.Email, nil
  45538. }
  45539. // ClearEmail clears the value of the "email" field.
  45540. func (m *WxCardMutation) ClearEmail() {
  45541. m.email = nil
  45542. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  45543. }
  45544. // EmailCleared returns if the "email" field was cleared in this mutation.
  45545. func (m *WxCardMutation) EmailCleared() bool {
  45546. _, ok := m.clearedFields[wxcard.FieldEmail]
  45547. return ok
  45548. }
  45549. // ResetEmail resets all changes to the "email" field.
  45550. func (m *WxCardMutation) ResetEmail() {
  45551. m.email = nil
  45552. delete(m.clearedFields, wxcard.FieldEmail)
  45553. }
  45554. // SetAPIBase sets the "api_base" field.
  45555. func (m *WxCardMutation) SetAPIBase(s string) {
  45556. m.api_base = &s
  45557. }
  45558. // APIBase returns the value of the "api_base" field in the mutation.
  45559. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  45560. v := m.api_base
  45561. if v == nil {
  45562. return
  45563. }
  45564. return *v, true
  45565. }
  45566. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  45567. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45569. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45570. if !m.op.Is(OpUpdateOne) {
  45571. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45572. }
  45573. if m.id == nil || m.oldValue == nil {
  45574. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45575. }
  45576. oldValue, err := m.oldValue(ctx)
  45577. if err != nil {
  45578. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45579. }
  45580. return oldValue.APIBase, nil
  45581. }
  45582. // ClearAPIBase clears the value of the "api_base" field.
  45583. func (m *WxCardMutation) ClearAPIBase() {
  45584. m.api_base = nil
  45585. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  45586. }
  45587. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45588. func (m *WxCardMutation) APIBaseCleared() bool {
  45589. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  45590. return ok
  45591. }
  45592. // ResetAPIBase resets all changes to the "api_base" field.
  45593. func (m *WxCardMutation) ResetAPIBase() {
  45594. m.api_base = nil
  45595. delete(m.clearedFields, wxcard.FieldAPIBase)
  45596. }
  45597. // SetAPIKey sets the "api_key" field.
  45598. func (m *WxCardMutation) SetAPIKey(s string) {
  45599. m.api_key = &s
  45600. }
  45601. // APIKey returns the value of the "api_key" field in the mutation.
  45602. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  45603. v := m.api_key
  45604. if v == nil {
  45605. return
  45606. }
  45607. return *v, true
  45608. }
  45609. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  45610. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45612. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45613. if !m.op.Is(OpUpdateOne) {
  45614. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45615. }
  45616. if m.id == nil || m.oldValue == nil {
  45617. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45618. }
  45619. oldValue, err := m.oldValue(ctx)
  45620. if err != nil {
  45621. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45622. }
  45623. return oldValue.APIKey, nil
  45624. }
  45625. // ClearAPIKey clears the value of the "api_key" field.
  45626. func (m *WxCardMutation) ClearAPIKey() {
  45627. m.api_key = nil
  45628. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  45629. }
  45630. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45631. func (m *WxCardMutation) APIKeyCleared() bool {
  45632. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  45633. return ok
  45634. }
  45635. // ResetAPIKey resets all changes to the "api_key" field.
  45636. func (m *WxCardMutation) ResetAPIKey() {
  45637. m.api_key = nil
  45638. delete(m.clearedFields, wxcard.FieldAPIKey)
  45639. }
  45640. // SetAiInfo sets the "ai_info" field.
  45641. func (m *WxCardMutation) SetAiInfo(s string) {
  45642. m.ai_info = &s
  45643. }
  45644. // AiInfo returns the value of the "ai_info" field in the mutation.
  45645. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  45646. v := m.ai_info
  45647. if v == nil {
  45648. return
  45649. }
  45650. return *v, true
  45651. }
  45652. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  45653. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45655. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  45656. if !m.op.Is(OpUpdateOne) {
  45657. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  45658. }
  45659. if m.id == nil || m.oldValue == nil {
  45660. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  45661. }
  45662. oldValue, err := m.oldValue(ctx)
  45663. if err != nil {
  45664. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  45665. }
  45666. return oldValue.AiInfo, nil
  45667. }
  45668. // ClearAiInfo clears the value of the "ai_info" field.
  45669. func (m *WxCardMutation) ClearAiInfo() {
  45670. m.ai_info = nil
  45671. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  45672. }
  45673. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  45674. func (m *WxCardMutation) AiInfoCleared() bool {
  45675. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  45676. return ok
  45677. }
  45678. // ResetAiInfo resets all changes to the "ai_info" field.
  45679. func (m *WxCardMutation) ResetAiInfo() {
  45680. m.ai_info = nil
  45681. delete(m.clearedFields, wxcard.FieldAiInfo)
  45682. }
  45683. // SetIntro sets the "intro" field.
  45684. func (m *WxCardMutation) SetIntro(s string) {
  45685. m.intro = &s
  45686. }
  45687. // Intro returns the value of the "intro" field in the mutation.
  45688. func (m *WxCardMutation) Intro() (r string, exists bool) {
  45689. v := m.intro
  45690. if v == nil {
  45691. return
  45692. }
  45693. return *v, true
  45694. }
  45695. // OldIntro returns the old "intro" field's value of the WxCard entity.
  45696. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45698. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  45699. if !m.op.Is(OpUpdateOne) {
  45700. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  45701. }
  45702. if m.id == nil || m.oldValue == nil {
  45703. return v, errors.New("OldIntro requires an ID field in the mutation")
  45704. }
  45705. oldValue, err := m.oldValue(ctx)
  45706. if err != nil {
  45707. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  45708. }
  45709. return oldValue.Intro, nil
  45710. }
  45711. // ClearIntro clears the value of the "intro" field.
  45712. func (m *WxCardMutation) ClearIntro() {
  45713. m.intro = nil
  45714. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  45715. }
  45716. // IntroCleared returns if the "intro" field was cleared in this mutation.
  45717. func (m *WxCardMutation) IntroCleared() bool {
  45718. _, ok := m.clearedFields[wxcard.FieldIntro]
  45719. return ok
  45720. }
  45721. // ResetIntro resets all changes to the "intro" field.
  45722. func (m *WxCardMutation) ResetIntro() {
  45723. m.intro = nil
  45724. delete(m.clearedFields, wxcard.FieldIntro)
  45725. }
  45726. // Where appends a list predicates to the WxCardMutation builder.
  45727. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  45728. m.predicates = append(m.predicates, ps...)
  45729. }
  45730. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  45731. // users can use type-assertion to append predicates that do not depend on any generated package.
  45732. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  45733. p := make([]predicate.WxCard, len(ps))
  45734. for i := range ps {
  45735. p[i] = ps[i]
  45736. }
  45737. m.Where(p...)
  45738. }
  45739. // Op returns the operation name.
  45740. func (m *WxCardMutation) Op() Op {
  45741. return m.op
  45742. }
  45743. // SetOp allows setting the mutation operation.
  45744. func (m *WxCardMutation) SetOp(op Op) {
  45745. m.op = op
  45746. }
  45747. // Type returns the node type of this mutation (WxCard).
  45748. func (m *WxCardMutation) Type() string {
  45749. return m.typ
  45750. }
  45751. // Fields returns all fields that were changed during this mutation. Note that in
  45752. // order to get all numeric fields that were incremented/decremented, call
  45753. // AddedFields().
  45754. func (m *WxCardMutation) Fields() []string {
  45755. fields := make([]string, 0, 18)
  45756. if m.created_at != nil {
  45757. fields = append(fields, wxcard.FieldCreatedAt)
  45758. }
  45759. if m.updated_at != nil {
  45760. fields = append(fields, wxcard.FieldUpdatedAt)
  45761. }
  45762. if m.deleted_at != nil {
  45763. fields = append(fields, wxcard.FieldDeletedAt)
  45764. }
  45765. if m.user_id != nil {
  45766. fields = append(fields, wxcard.FieldUserID)
  45767. }
  45768. if m.wx_user_id != nil {
  45769. fields = append(fields, wxcard.FieldWxUserID)
  45770. }
  45771. if m.avatar != nil {
  45772. fields = append(fields, wxcard.FieldAvatar)
  45773. }
  45774. if m.logo != nil {
  45775. fields = append(fields, wxcard.FieldLogo)
  45776. }
  45777. if m.name != nil {
  45778. fields = append(fields, wxcard.FieldName)
  45779. }
  45780. if m.company != nil {
  45781. fields = append(fields, wxcard.FieldCompany)
  45782. }
  45783. if m.address != nil {
  45784. fields = append(fields, wxcard.FieldAddress)
  45785. }
  45786. if m.phone != nil {
  45787. fields = append(fields, wxcard.FieldPhone)
  45788. }
  45789. if m.official_account != nil {
  45790. fields = append(fields, wxcard.FieldOfficialAccount)
  45791. }
  45792. if m.wechat_account != nil {
  45793. fields = append(fields, wxcard.FieldWechatAccount)
  45794. }
  45795. if m.email != nil {
  45796. fields = append(fields, wxcard.FieldEmail)
  45797. }
  45798. if m.api_base != nil {
  45799. fields = append(fields, wxcard.FieldAPIBase)
  45800. }
  45801. if m.api_key != nil {
  45802. fields = append(fields, wxcard.FieldAPIKey)
  45803. }
  45804. if m.ai_info != nil {
  45805. fields = append(fields, wxcard.FieldAiInfo)
  45806. }
  45807. if m.intro != nil {
  45808. fields = append(fields, wxcard.FieldIntro)
  45809. }
  45810. return fields
  45811. }
  45812. // Field returns the value of a field with the given name. The second boolean
  45813. // return value indicates that this field was not set, or was not defined in the
  45814. // schema.
  45815. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  45816. switch name {
  45817. case wxcard.FieldCreatedAt:
  45818. return m.CreatedAt()
  45819. case wxcard.FieldUpdatedAt:
  45820. return m.UpdatedAt()
  45821. case wxcard.FieldDeletedAt:
  45822. return m.DeletedAt()
  45823. case wxcard.FieldUserID:
  45824. return m.UserID()
  45825. case wxcard.FieldWxUserID:
  45826. return m.WxUserID()
  45827. case wxcard.FieldAvatar:
  45828. return m.Avatar()
  45829. case wxcard.FieldLogo:
  45830. return m.Logo()
  45831. case wxcard.FieldName:
  45832. return m.Name()
  45833. case wxcard.FieldCompany:
  45834. return m.Company()
  45835. case wxcard.FieldAddress:
  45836. return m.Address()
  45837. case wxcard.FieldPhone:
  45838. return m.Phone()
  45839. case wxcard.FieldOfficialAccount:
  45840. return m.OfficialAccount()
  45841. case wxcard.FieldWechatAccount:
  45842. return m.WechatAccount()
  45843. case wxcard.FieldEmail:
  45844. return m.Email()
  45845. case wxcard.FieldAPIBase:
  45846. return m.APIBase()
  45847. case wxcard.FieldAPIKey:
  45848. return m.APIKey()
  45849. case wxcard.FieldAiInfo:
  45850. return m.AiInfo()
  45851. case wxcard.FieldIntro:
  45852. return m.Intro()
  45853. }
  45854. return nil, false
  45855. }
  45856. // OldField returns the old value of the field from the database. An error is
  45857. // returned if the mutation operation is not UpdateOne, or the query to the
  45858. // database failed.
  45859. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45860. switch name {
  45861. case wxcard.FieldCreatedAt:
  45862. return m.OldCreatedAt(ctx)
  45863. case wxcard.FieldUpdatedAt:
  45864. return m.OldUpdatedAt(ctx)
  45865. case wxcard.FieldDeletedAt:
  45866. return m.OldDeletedAt(ctx)
  45867. case wxcard.FieldUserID:
  45868. return m.OldUserID(ctx)
  45869. case wxcard.FieldWxUserID:
  45870. return m.OldWxUserID(ctx)
  45871. case wxcard.FieldAvatar:
  45872. return m.OldAvatar(ctx)
  45873. case wxcard.FieldLogo:
  45874. return m.OldLogo(ctx)
  45875. case wxcard.FieldName:
  45876. return m.OldName(ctx)
  45877. case wxcard.FieldCompany:
  45878. return m.OldCompany(ctx)
  45879. case wxcard.FieldAddress:
  45880. return m.OldAddress(ctx)
  45881. case wxcard.FieldPhone:
  45882. return m.OldPhone(ctx)
  45883. case wxcard.FieldOfficialAccount:
  45884. return m.OldOfficialAccount(ctx)
  45885. case wxcard.FieldWechatAccount:
  45886. return m.OldWechatAccount(ctx)
  45887. case wxcard.FieldEmail:
  45888. return m.OldEmail(ctx)
  45889. case wxcard.FieldAPIBase:
  45890. return m.OldAPIBase(ctx)
  45891. case wxcard.FieldAPIKey:
  45892. return m.OldAPIKey(ctx)
  45893. case wxcard.FieldAiInfo:
  45894. return m.OldAiInfo(ctx)
  45895. case wxcard.FieldIntro:
  45896. return m.OldIntro(ctx)
  45897. }
  45898. return nil, fmt.Errorf("unknown WxCard field %s", name)
  45899. }
  45900. // SetField sets the value of a field with the given name. It returns an error if
  45901. // the field is not defined in the schema, or if the type mismatched the field
  45902. // type.
  45903. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  45904. switch name {
  45905. case wxcard.FieldCreatedAt:
  45906. v, ok := value.(time.Time)
  45907. if !ok {
  45908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45909. }
  45910. m.SetCreatedAt(v)
  45911. return nil
  45912. case wxcard.FieldUpdatedAt:
  45913. v, ok := value.(time.Time)
  45914. if !ok {
  45915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45916. }
  45917. m.SetUpdatedAt(v)
  45918. return nil
  45919. case wxcard.FieldDeletedAt:
  45920. v, ok := value.(time.Time)
  45921. if !ok {
  45922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45923. }
  45924. m.SetDeletedAt(v)
  45925. return nil
  45926. case wxcard.FieldUserID:
  45927. v, ok := value.(uint64)
  45928. if !ok {
  45929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45930. }
  45931. m.SetUserID(v)
  45932. return nil
  45933. case wxcard.FieldWxUserID:
  45934. v, ok := value.(uint64)
  45935. if !ok {
  45936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45937. }
  45938. m.SetWxUserID(v)
  45939. return nil
  45940. case wxcard.FieldAvatar:
  45941. v, ok := value.(string)
  45942. if !ok {
  45943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45944. }
  45945. m.SetAvatar(v)
  45946. return nil
  45947. case wxcard.FieldLogo:
  45948. v, ok := value.(string)
  45949. if !ok {
  45950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45951. }
  45952. m.SetLogo(v)
  45953. return nil
  45954. case wxcard.FieldName:
  45955. v, ok := value.(string)
  45956. if !ok {
  45957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45958. }
  45959. m.SetName(v)
  45960. return nil
  45961. case wxcard.FieldCompany:
  45962. v, ok := value.(string)
  45963. if !ok {
  45964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45965. }
  45966. m.SetCompany(v)
  45967. return nil
  45968. case wxcard.FieldAddress:
  45969. v, ok := value.(string)
  45970. if !ok {
  45971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45972. }
  45973. m.SetAddress(v)
  45974. return nil
  45975. case wxcard.FieldPhone:
  45976. v, ok := value.(string)
  45977. if !ok {
  45978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45979. }
  45980. m.SetPhone(v)
  45981. return nil
  45982. case wxcard.FieldOfficialAccount:
  45983. v, ok := value.(string)
  45984. if !ok {
  45985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45986. }
  45987. m.SetOfficialAccount(v)
  45988. return nil
  45989. case wxcard.FieldWechatAccount:
  45990. v, ok := value.(string)
  45991. if !ok {
  45992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45993. }
  45994. m.SetWechatAccount(v)
  45995. return nil
  45996. case wxcard.FieldEmail:
  45997. v, ok := value.(string)
  45998. if !ok {
  45999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46000. }
  46001. m.SetEmail(v)
  46002. return nil
  46003. case wxcard.FieldAPIBase:
  46004. v, ok := value.(string)
  46005. if !ok {
  46006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46007. }
  46008. m.SetAPIBase(v)
  46009. return nil
  46010. case wxcard.FieldAPIKey:
  46011. v, ok := value.(string)
  46012. if !ok {
  46013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46014. }
  46015. m.SetAPIKey(v)
  46016. return nil
  46017. case wxcard.FieldAiInfo:
  46018. v, ok := value.(string)
  46019. if !ok {
  46020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46021. }
  46022. m.SetAiInfo(v)
  46023. return nil
  46024. case wxcard.FieldIntro:
  46025. v, ok := value.(string)
  46026. if !ok {
  46027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46028. }
  46029. m.SetIntro(v)
  46030. return nil
  46031. }
  46032. return fmt.Errorf("unknown WxCard field %s", name)
  46033. }
  46034. // AddedFields returns all numeric fields that were incremented/decremented during
  46035. // this mutation.
  46036. func (m *WxCardMutation) AddedFields() []string {
  46037. var fields []string
  46038. if m.adduser_id != nil {
  46039. fields = append(fields, wxcard.FieldUserID)
  46040. }
  46041. if m.addwx_user_id != nil {
  46042. fields = append(fields, wxcard.FieldWxUserID)
  46043. }
  46044. return fields
  46045. }
  46046. // AddedField returns the numeric value that was incremented/decremented on a field
  46047. // with the given name. The second boolean return value indicates that this field
  46048. // was not set, or was not defined in the schema.
  46049. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  46050. switch name {
  46051. case wxcard.FieldUserID:
  46052. return m.AddedUserID()
  46053. case wxcard.FieldWxUserID:
  46054. return m.AddedWxUserID()
  46055. }
  46056. return nil, false
  46057. }
  46058. // AddField adds the value to the field with the given name. It returns an error if
  46059. // the field is not defined in the schema, or if the type mismatched the field
  46060. // type.
  46061. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  46062. switch name {
  46063. case wxcard.FieldUserID:
  46064. v, ok := value.(int64)
  46065. if !ok {
  46066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46067. }
  46068. m.AddUserID(v)
  46069. return nil
  46070. case wxcard.FieldWxUserID:
  46071. v, ok := value.(int64)
  46072. if !ok {
  46073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46074. }
  46075. m.AddWxUserID(v)
  46076. return nil
  46077. }
  46078. return fmt.Errorf("unknown WxCard numeric field %s", name)
  46079. }
  46080. // ClearedFields returns all nullable fields that were cleared during this
  46081. // mutation.
  46082. func (m *WxCardMutation) ClearedFields() []string {
  46083. var fields []string
  46084. if m.FieldCleared(wxcard.FieldDeletedAt) {
  46085. fields = append(fields, wxcard.FieldDeletedAt)
  46086. }
  46087. if m.FieldCleared(wxcard.FieldUserID) {
  46088. fields = append(fields, wxcard.FieldUserID)
  46089. }
  46090. if m.FieldCleared(wxcard.FieldWxUserID) {
  46091. fields = append(fields, wxcard.FieldWxUserID)
  46092. }
  46093. if m.FieldCleared(wxcard.FieldEmail) {
  46094. fields = append(fields, wxcard.FieldEmail)
  46095. }
  46096. if m.FieldCleared(wxcard.FieldAPIBase) {
  46097. fields = append(fields, wxcard.FieldAPIBase)
  46098. }
  46099. if m.FieldCleared(wxcard.FieldAPIKey) {
  46100. fields = append(fields, wxcard.FieldAPIKey)
  46101. }
  46102. if m.FieldCleared(wxcard.FieldAiInfo) {
  46103. fields = append(fields, wxcard.FieldAiInfo)
  46104. }
  46105. if m.FieldCleared(wxcard.FieldIntro) {
  46106. fields = append(fields, wxcard.FieldIntro)
  46107. }
  46108. return fields
  46109. }
  46110. // FieldCleared returns a boolean indicating if a field with the given name was
  46111. // cleared in this mutation.
  46112. func (m *WxCardMutation) FieldCleared(name string) bool {
  46113. _, ok := m.clearedFields[name]
  46114. return ok
  46115. }
  46116. // ClearField clears the value of the field with the given name. It returns an
  46117. // error if the field is not defined in the schema.
  46118. func (m *WxCardMutation) ClearField(name string) error {
  46119. switch name {
  46120. case wxcard.FieldDeletedAt:
  46121. m.ClearDeletedAt()
  46122. return nil
  46123. case wxcard.FieldUserID:
  46124. m.ClearUserID()
  46125. return nil
  46126. case wxcard.FieldWxUserID:
  46127. m.ClearWxUserID()
  46128. return nil
  46129. case wxcard.FieldEmail:
  46130. m.ClearEmail()
  46131. return nil
  46132. case wxcard.FieldAPIBase:
  46133. m.ClearAPIBase()
  46134. return nil
  46135. case wxcard.FieldAPIKey:
  46136. m.ClearAPIKey()
  46137. return nil
  46138. case wxcard.FieldAiInfo:
  46139. m.ClearAiInfo()
  46140. return nil
  46141. case wxcard.FieldIntro:
  46142. m.ClearIntro()
  46143. return nil
  46144. }
  46145. return fmt.Errorf("unknown WxCard nullable field %s", name)
  46146. }
  46147. // ResetField resets all changes in the mutation for the field with the given name.
  46148. // It returns an error if the field is not defined in the schema.
  46149. func (m *WxCardMutation) ResetField(name string) error {
  46150. switch name {
  46151. case wxcard.FieldCreatedAt:
  46152. m.ResetCreatedAt()
  46153. return nil
  46154. case wxcard.FieldUpdatedAt:
  46155. m.ResetUpdatedAt()
  46156. return nil
  46157. case wxcard.FieldDeletedAt:
  46158. m.ResetDeletedAt()
  46159. return nil
  46160. case wxcard.FieldUserID:
  46161. m.ResetUserID()
  46162. return nil
  46163. case wxcard.FieldWxUserID:
  46164. m.ResetWxUserID()
  46165. return nil
  46166. case wxcard.FieldAvatar:
  46167. m.ResetAvatar()
  46168. return nil
  46169. case wxcard.FieldLogo:
  46170. m.ResetLogo()
  46171. return nil
  46172. case wxcard.FieldName:
  46173. m.ResetName()
  46174. return nil
  46175. case wxcard.FieldCompany:
  46176. m.ResetCompany()
  46177. return nil
  46178. case wxcard.FieldAddress:
  46179. m.ResetAddress()
  46180. return nil
  46181. case wxcard.FieldPhone:
  46182. m.ResetPhone()
  46183. return nil
  46184. case wxcard.FieldOfficialAccount:
  46185. m.ResetOfficialAccount()
  46186. return nil
  46187. case wxcard.FieldWechatAccount:
  46188. m.ResetWechatAccount()
  46189. return nil
  46190. case wxcard.FieldEmail:
  46191. m.ResetEmail()
  46192. return nil
  46193. case wxcard.FieldAPIBase:
  46194. m.ResetAPIBase()
  46195. return nil
  46196. case wxcard.FieldAPIKey:
  46197. m.ResetAPIKey()
  46198. return nil
  46199. case wxcard.FieldAiInfo:
  46200. m.ResetAiInfo()
  46201. return nil
  46202. case wxcard.FieldIntro:
  46203. m.ResetIntro()
  46204. return nil
  46205. }
  46206. return fmt.Errorf("unknown WxCard field %s", name)
  46207. }
  46208. // AddedEdges returns all edge names that were set/added in this mutation.
  46209. func (m *WxCardMutation) AddedEdges() []string {
  46210. edges := make([]string, 0, 0)
  46211. return edges
  46212. }
  46213. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46214. // name in this mutation.
  46215. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  46216. return nil
  46217. }
  46218. // RemovedEdges returns all edge names that were removed in this mutation.
  46219. func (m *WxCardMutation) RemovedEdges() []string {
  46220. edges := make([]string, 0, 0)
  46221. return edges
  46222. }
  46223. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46224. // the given name in this mutation.
  46225. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  46226. return nil
  46227. }
  46228. // ClearedEdges returns all edge names that were cleared in this mutation.
  46229. func (m *WxCardMutation) ClearedEdges() []string {
  46230. edges := make([]string, 0, 0)
  46231. return edges
  46232. }
  46233. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46234. // was cleared in this mutation.
  46235. func (m *WxCardMutation) EdgeCleared(name string) bool {
  46236. return false
  46237. }
  46238. // ClearEdge clears the value of the edge with the given name. It returns an error
  46239. // if that edge is not defined in the schema.
  46240. func (m *WxCardMutation) ClearEdge(name string) error {
  46241. return fmt.Errorf("unknown WxCard unique edge %s", name)
  46242. }
  46243. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46244. // It returns an error if the edge is not defined in the schema.
  46245. func (m *WxCardMutation) ResetEdge(name string) error {
  46246. return fmt.Errorf("unknown WxCard edge %s", name)
  46247. }
  46248. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  46249. type WxCardUserMutation struct {
  46250. config
  46251. op Op
  46252. typ string
  46253. id *uint64
  46254. created_at *time.Time
  46255. updated_at *time.Time
  46256. deleted_at *time.Time
  46257. wxid *string
  46258. account *string
  46259. avatar *string
  46260. nickname *string
  46261. remark *string
  46262. phone *string
  46263. open_id *string
  46264. union_id *string
  46265. session_key *string
  46266. is_vip *int
  46267. addis_vip *int
  46268. clearedFields map[string]struct{}
  46269. done bool
  46270. oldValue func(context.Context) (*WxCardUser, error)
  46271. predicates []predicate.WxCardUser
  46272. }
  46273. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  46274. // wxcarduserOption allows management of the mutation configuration using functional options.
  46275. type wxcarduserOption func(*WxCardUserMutation)
  46276. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  46277. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  46278. m := &WxCardUserMutation{
  46279. config: c,
  46280. op: op,
  46281. typ: TypeWxCardUser,
  46282. clearedFields: make(map[string]struct{}),
  46283. }
  46284. for _, opt := range opts {
  46285. opt(m)
  46286. }
  46287. return m
  46288. }
  46289. // withWxCardUserID sets the ID field of the mutation.
  46290. func withWxCardUserID(id uint64) wxcarduserOption {
  46291. return func(m *WxCardUserMutation) {
  46292. var (
  46293. err error
  46294. once sync.Once
  46295. value *WxCardUser
  46296. )
  46297. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  46298. once.Do(func() {
  46299. if m.done {
  46300. err = errors.New("querying old values post mutation is not allowed")
  46301. } else {
  46302. value, err = m.Client().WxCardUser.Get(ctx, id)
  46303. }
  46304. })
  46305. return value, err
  46306. }
  46307. m.id = &id
  46308. }
  46309. }
  46310. // withWxCardUser sets the old WxCardUser of the mutation.
  46311. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  46312. return func(m *WxCardUserMutation) {
  46313. m.oldValue = func(context.Context) (*WxCardUser, error) {
  46314. return node, nil
  46315. }
  46316. m.id = &node.ID
  46317. }
  46318. }
  46319. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46320. // executed in a transaction (ent.Tx), a transactional client is returned.
  46321. func (m WxCardUserMutation) Client() *Client {
  46322. client := &Client{config: m.config}
  46323. client.init()
  46324. return client
  46325. }
  46326. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46327. // it returns an error otherwise.
  46328. func (m WxCardUserMutation) Tx() (*Tx, error) {
  46329. if _, ok := m.driver.(*txDriver); !ok {
  46330. return nil, errors.New("ent: mutation is not running in a transaction")
  46331. }
  46332. tx := &Tx{config: m.config}
  46333. tx.init()
  46334. return tx, nil
  46335. }
  46336. // SetID sets the value of the id field. Note that this
  46337. // operation is only accepted on creation of WxCardUser entities.
  46338. func (m *WxCardUserMutation) SetID(id uint64) {
  46339. m.id = &id
  46340. }
  46341. // ID returns the ID value in the mutation. Note that the ID is only available
  46342. // if it was provided to the builder or after it was returned from the database.
  46343. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  46344. if m.id == nil {
  46345. return
  46346. }
  46347. return *m.id, true
  46348. }
  46349. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46350. // That means, if the mutation is applied within a transaction with an isolation level such
  46351. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46352. // or updated by the mutation.
  46353. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  46354. switch {
  46355. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46356. id, exists := m.ID()
  46357. if exists {
  46358. return []uint64{id}, nil
  46359. }
  46360. fallthrough
  46361. case m.op.Is(OpUpdate | OpDelete):
  46362. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  46363. default:
  46364. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46365. }
  46366. }
  46367. // SetCreatedAt sets the "created_at" field.
  46368. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  46369. m.created_at = &t
  46370. }
  46371. // CreatedAt returns the value of the "created_at" field in the mutation.
  46372. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  46373. v := m.created_at
  46374. if v == nil {
  46375. return
  46376. }
  46377. return *v, true
  46378. }
  46379. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  46380. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46382. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46383. if !m.op.Is(OpUpdateOne) {
  46384. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46385. }
  46386. if m.id == nil || m.oldValue == nil {
  46387. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46388. }
  46389. oldValue, err := m.oldValue(ctx)
  46390. if err != nil {
  46391. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46392. }
  46393. return oldValue.CreatedAt, nil
  46394. }
  46395. // ResetCreatedAt resets all changes to the "created_at" field.
  46396. func (m *WxCardUserMutation) ResetCreatedAt() {
  46397. m.created_at = nil
  46398. }
  46399. // SetUpdatedAt sets the "updated_at" field.
  46400. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  46401. m.updated_at = &t
  46402. }
  46403. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46404. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  46405. v := m.updated_at
  46406. if v == nil {
  46407. return
  46408. }
  46409. return *v, true
  46410. }
  46411. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  46412. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46414. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46415. if !m.op.Is(OpUpdateOne) {
  46416. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46417. }
  46418. if m.id == nil || m.oldValue == nil {
  46419. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46420. }
  46421. oldValue, err := m.oldValue(ctx)
  46422. if err != nil {
  46423. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46424. }
  46425. return oldValue.UpdatedAt, nil
  46426. }
  46427. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46428. func (m *WxCardUserMutation) ResetUpdatedAt() {
  46429. m.updated_at = nil
  46430. }
  46431. // SetDeletedAt sets the "deleted_at" field.
  46432. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  46433. m.deleted_at = &t
  46434. }
  46435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46436. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  46437. v := m.deleted_at
  46438. if v == nil {
  46439. return
  46440. }
  46441. return *v, true
  46442. }
  46443. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  46444. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46446. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46447. if !m.op.Is(OpUpdateOne) {
  46448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46449. }
  46450. if m.id == nil || m.oldValue == nil {
  46451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46452. }
  46453. oldValue, err := m.oldValue(ctx)
  46454. if err != nil {
  46455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46456. }
  46457. return oldValue.DeletedAt, nil
  46458. }
  46459. // ClearDeletedAt clears the value of the "deleted_at" field.
  46460. func (m *WxCardUserMutation) ClearDeletedAt() {
  46461. m.deleted_at = nil
  46462. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  46463. }
  46464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46465. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  46466. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  46467. return ok
  46468. }
  46469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46470. func (m *WxCardUserMutation) ResetDeletedAt() {
  46471. m.deleted_at = nil
  46472. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  46473. }
  46474. // SetWxid sets the "wxid" field.
  46475. func (m *WxCardUserMutation) SetWxid(s string) {
  46476. m.wxid = &s
  46477. }
  46478. // Wxid returns the value of the "wxid" field in the mutation.
  46479. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  46480. v := m.wxid
  46481. if v == nil {
  46482. return
  46483. }
  46484. return *v, true
  46485. }
  46486. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  46487. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46489. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  46490. if !m.op.Is(OpUpdateOne) {
  46491. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46492. }
  46493. if m.id == nil || m.oldValue == nil {
  46494. return v, errors.New("OldWxid requires an ID field in the mutation")
  46495. }
  46496. oldValue, err := m.oldValue(ctx)
  46497. if err != nil {
  46498. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46499. }
  46500. return oldValue.Wxid, nil
  46501. }
  46502. // ResetWxid resets all changes to the "wxid" field.
  46503. func (m *WxCardUserMutation) ResetWxid() {
  46504. m.wxid = nil
  46505. }
  46506. // SetAccount sets the "account" field.
  46507. func (m *WxCardUserMutation) SetAccount(s string) {
  46508. m.account = &s
  46509. }
  46510. // Account returns the value of the "account" field in the mutation.
  46511. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  46512. v := m.account
  46513. if v == nil {
  46514. return
  46515. }
  46516. return *v, true
  46517. }
  46518. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  46519. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46521. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  46522. if !m.op.Is(OpUpdateOne) {
  46523. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  46524. }
  46525. if m.id == nil || m.oldValue == nil {
  46526. return v, errors.New("OldAccount requires an ID field in the mutation")
  46527. }
  46528. oldValue, err := m.oldValue(ctx)
  46529. if err != nil {
  46530. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  46531. }
  46532. return oldValue.Account, nil
  46533. }
  46534. // ResetAccount resets all changes to the "account" field.
  46535. func (m *WxCardUserMutation) ResetAccount() {
  46536. m.account = nil
  46537. }
  46538. // SetAvatar sets the "avatar" field.
  46539. func (m *WxCardUserMutation) SetAvatar(s string) {
  46540. m.avatar = &s
  46541. }
  46542. // Avatar returns the value of the "avatar" field in the mutation.
  46543. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  46544. v := m.avatar
  46545. if v == nil {
  46546. return
  46547. }
  46548. return *v, true
  46549. }
  46550. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  46551. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46553. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46554. if !m.op.Is(OpUpdateOne) {
  46555. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46556. }
  46557. if m.id == nil || m.oldValue == nil {
  46558. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46559. }
  46560. oldValue, err := m.oldValue(ctx)
  46561. if err != nil {
  46562. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46563. }
  46564. return oldValue.Avatar, nil
  46565. }
  46566. // ResetAvatar resets all changes to the "avatar" field.
  46567. func (m *WxCardUserMutation) ResetAvatar() {
  46568. m.avatar = nil
  46569. }
  46570. // SetNickname sets the "nickname" field.
  46571. func (m *WxCardUserMutation) SetNickname(s string) {
  46572. m.nickname = &s
  46573. }
  46574. // Nickname returns the value of the "nickname" field in the mutation.
  46575. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  46576. v := m.nickname
  46577. if v == nil {
  46578. return
  46579. }
  46580. return *v, true
  46581. }
  46582. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  46583. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46585. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  46586. if !m.op.Is(OpUpdateOne) {
  46587. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46588. }
  46589. if m.id == nil || m.oldValue == nil {
  46590. return v, errors.New("OldNickname requires an ID field in the mutation")
  46591. }
  46592. oldValue, err := m.oldValue(ctx)
  46593. if err != nil {
  46594. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46595. }
  46596. return oldValue.Nickname, nil
  46597. }
  46598. // ResetNickname resets all changes to the "nickname" field.
  46599. func (m *WxCardUserMutation) ResetNickname() {
  46600. m.nickname = nil
  46601. }
  46602. // SetRemark sets the "remark" field.
  46603. func (m *WxCardUserMutation) SetRemark(s string) {
  46604. m.remark = &s
  46605. }
  46606. // Remark returns the value of the "remark" field in the mutation.
  46607. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  46608. v := m.remark
  46609. if v == nil {
  46610. return
  46611. }
  46612. return *v, true
  46613. }
  46614. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  46615. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46617. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  46618. if !m.op.Is(OpUpdateOne) {
  46619. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  46620. }
  46621. if m.id == nil || m.oldValue == nil {
  46622. return v, errors.New("OldRemark requires an ID field in the mutation")
  46623. }
  46624. oldValue, err := m.oldValue(ctx)
  46625. if err != nil {
  46626. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  46627. }
  46628. return oldValue.Remark, nil
  46629. }
  46630. // ResetRemark resets all changes to the "remark" field.
  46631. func (m *WxCardUserMutation) ResetRemark() {
  46632. m.remark = nil
  46633. }
  46634. // SetPhone sets the "phone" field.
  46635. func (m *WxCardUserMutation) SetPhone(s string) {
  46636. m.phone = &s
  46637. }
  46638. // Phone returns the value of the "phone" field in the mutation.
  46639. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  46640. v := m.phone
  46641. if v == nil {
  46642. return
  46643. }
  46644. return *v, true
  46645. }
  46646. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  46647. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46649. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  46650. if !m.op.Is(OpUpdateOne) {
  46651. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46652. }
  46653. if m.id == nil || m.oldValue == nil {
  46654. return v, errors.New("OldPhone requires an ID field in the mutation")
  46655. }
  46656. oldValue, err := m.oldValue(ctx)
  46657. if err != nil {
  46658. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  46659. }
  46660. return oldValue.Phone, nil
  46661. }
  46662. // ResetPhone resets all changes to the "phone" field.
  46663. func (m *WxCardUserMutation) ResetPhone() {
  46664. m.phone = nil
  46665. }
  46666. // SetOpenID sets the "open_id" field.
  46667. func (m *WxCardUserMutation) SetOpenID(s string) {
  46668. m.open_id = &s
  46669. }
  46670. // OpenID returns the value of the "open_id" field in the mutation.
  46671. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  46672. v := m.open_id
  46673. if v == nil {
  46674. return
  46675. }
  46676. return *v, true
  46677. }
  46678. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  46679. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46681. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  46682. if !m.op.Is(OpUpdateOne) {
  46683. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  46684. }
  46685. if m.id == nil || m.oldValue == nil {
  46686. return v, errors.New("OldOpenID requires an ID field in the mutation")
  46687. }
  46688. oldValue, err := m.oldValue(ctx)
  46689. if err != nil {
  46690. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  46691. }
  46692. return oldValue.OpenID, nil
  46693. }
  46694. // ResetOpenID resets all changes to the "open_id" field.
  46695. func (m *WxCardUserMutation) ResetOpenID() {
  46696. m.open_id = nil
  46697. }
  46698. // SetUnionID sets the "union_id" field.
  46699. func (m *WxCardUserMutation) SetUnionID(s string) {
  46700. m.union_id = &s
  46701. }
  46702. // UnionID returns the value of the "union_id" field in the mutation.
  46703. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  46704. v := m.union_id
  46705. if v == nil {
  46706. return
  46707. }
  46708. return *v, true
  46709. }
  46710. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  46711. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46713. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  46714. if !m.op.Is(OpUpdateOne) {
  46715. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  46716. }
  46717. if m.id == nil || m.oldValue == nil {
  46718. return v, errors.New("OldUnionID requires an ID field in the mutation")
  46719. }
  46720. oldValue, err := m.oldValue(ctx)
  46721. if err != nil {
  46722. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  46723. }
  46724. return oldValue.UnionID, nil
  46725. }
  46726. // ResetUnionID resets all changes to the "union_id" field.
  46727. func (m *WxCardUserMutation) ResetUnionID() {
  46728. m.union_id = nil
  46729. }
  46730. // SetSessionKey sets the "session_key" field.
  46731. func (m *WxCardUserMutation) SetSessionKey(s string) {
  46732. m.session_key = &s
  46733. }
  46734. // SessionKey returns the value of the "session_key" field in the mutation.
  46735. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  46736. v := m.session_key
  46737. if v == nil {
  46738. return
  46739. }
  46740. return *v, true
  46741. }
  46742. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  46743. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46745. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  46746. if !m.op.Is(OpUpdateOne) {
  46747. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  46748. }
  46749. if m.id == nil || m.oldValue == nil {
  46750. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  46751. }
  46752. oldValue, err := m.oldValue(ctx)
  46753. if err != nil {
  46754. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  46755. }
  46756. return oldValue.SessionKey, nil
  46757. }
  46758. // ResetSessionKey resets all changes to the "session_key" field.
  46759. func (m *WxCardUserMutation) ResetSessionKey() {
  46760. m.session_key = nil
  46761. }
  46762. // SetIsVip sets the "is_vip" field.
  46763. func (m *WxCardUserMutation) SetIsVip(i int) {
  46764. m.is_vip = &i
  46765. m.addis_vip = nil
  46766. }
  46767. // IsVip returns the value of the "is_vip" field in the mutation.
  46768. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  46769. v := m.is_vip
  46770. if v == nil {
  46771. return
  46772. }
  46773. return *v, true
  46774. }
  46775. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  46776. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46778. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  46779. if !m.op.Is(OpUpdateOne) {
  46780. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  46781. }
  46782. if m.id == nil || m.oldValue == nil {
  46783. return v, errors.New("OldIsVip requires an ID field in the mutation")
  46784. }
  46785. oldValue, err := m.oldValue(ctx)
  46786. if err != nil {
  46787. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  46788. }
  46789. return oldValue.IsVip, nil
  46790. }
  46791. // AddIsVip adds i to the "is_vip" field.
  46792. func (m *WxCardUserMutation) AddIsVip(i int) {
  46793. if m.addis_vip != nil {
  46794. *m.addis_vip += i
  46795. } else {
  46796. m.addis_vip = &i
  46797. }
  46798. }
  46799. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  46800. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  46801. v := m.addis_vip
  46802. if v == nil {
  46803. return
  46804. }
  46805. return *v, true
  46806. }
  46807. // ResetIsVip resets all changes to the "is_vip" field.
  46808. func (m *WxCardUserMutation) ResetIsVip() {
  46809. m.is_vip = nil
  46810. m.addis_vip = nil
  46811. }
  46812. // Where appends a list predicates to the WxCardUserMutation builder.
  46813. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  46814. m.predicates = append(m.predicates, ps...)
  46815. }
  46816. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  46817. // users can use type-assertion to append predicates that do not depend on any generated package.
  46818. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  46819. p := make([]predicate.WxCardUser, len(ps))
  46820. for i := range ps {
  46821. p[i] = ps[i]
  46822. }
  46823. m.Where(p...)
  46824. }
  46825. // Op returns the operation name.
  46826. func (m *WxCardUserMutation) Op() Op {
  46827. return m.op
  46828. }
  46829. // SetOp allows setting the mutation operation.
  46830. func (m *WxCardUserMutation) SetOp(op Op) {
  46831. m.op = op
  46832. }
  46833. // Type returns the node type of this mutation (WxCardUser).
  46834. func (m *WxCardUserMutation) Type() string {
  46835. return m.typ
  46836. }
  46837. // Fields returns all fields that were changed during this mutation. Note that in
  46838. // order to get all numeric fields that were incremented/decremented, call
  46839. // AddedFields().
  46840. func (m *WxCardUserMutation) Fields() []string {
  46841. fields := make([]string, 0, 13)
  46842. if m.created_at != nil {
  46843. fields = append(fields, wxcarduser.FieldCreatedAt)
  46844. }
  46845. if m.updated_at != nil {
  46846. fields = append(fields, wxcarduser.FieldUpdatedAt)
  46847. }
  46848. if m.deleted_at != nil {
  46849. fields = append(fields, wxcarduser.FieldDeletedAt)
  46850. }
  46851. if m.wxid != nil {
  46852. fields = append(fields, wxcarduser.FieldWxid)
  46853. }
  46854. if m.account != nil {
  46855. fields = append(fields, wxcarduser.FieldAccount)
  46856. }
  46857. if m.avatar != nil {
  46858. fields = append(fields, wxcarduser.FieldAvatar)
  46859. }
  46860. if m.nickname != nil {
  46861. fields = append(fields, wxcarduser.FieldNickname)
  46862. }
  46863. if m.remark != nil {
  46864. fields = append(fields, wxcarduser.FieldRemark)
  46865. }
  46866. if m.phone != nil {
  46867. fields = append(fields, wxcarduser.FieldPhone)
  46868. }
  46869. if m.open_id != nil {
  46870. fields = append(fields, wxcarduser.FieldOpenID)
  46871. }
  46872. if m.union_id != nil {
  46873. fields = append(fields, wxcarduser.FieldUnionID)
  46874. }
  46875. if m.session_key != nil {
  46876. fields = append(fields, wxcarduser.FieldSessionKey)
  46877. }
  46878. if m.is_vip != nil {
  46879. fields = append(fields, wxcarduser.FieldIsVip)
  46880. }
  46881. return fields
  46882. }
  46883. // Field returns the value of a field with the given name. The second boolean
  46884. // return value indicates that this field was not set, or was not defined in the
  46885. // schema.
  46886. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  46887. switch name {
  46888. case wxcarduser.FieldCreatedAt:
  46889. return m.CreatedAt()
  46890. case wxcarduser.FieldUpdatedAt:
  46891. return m.UpdatedAt()
  46892. case wxcarduser.FieldDeletedAt:
  46893. return m.DeletedAt()
  46894. case wxcarduser.FieldWxid:
  46895. return m.Wxid()
  46896. case wxcarduser.FieldAccount:
  46897. return m.Account()
  46898. case wxcarduser.FieldAvatar:
  46899. return m.Avatar()
  46900. case wxcarduser.FieldNickname:
  46901. return m.Nickname()
  46902. case wxcarduser.FieldRemark:
  46903. return m.Remark()
  46904. case wxcarduser.FieldPhone:
  46905. return m.Phone()
  46906. case wxcarduser.FieldOpenID:
  46907. return m.OpenID()
  46908. case wxcarduser.FieldUnionID:
  46909. return m.UnionID()
  46910. case wxcarduser.FieldSessionKey:
  46911. return m.SessionKey()
  46912. case wxcarduser.FieldIsVip:
  46913. return m.IsVip()
  46914. }
  46915. return nil, false
  46916. }
  46917. // OldField returns the old value of the field from the database. An error is
  46918. // returned if the mutation operation is not UpdateOne, or the query to the
  46919. // database failed.
  46920. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46921. switch name {
  46922. case wxcarduser.FieldCreatedAt:
  46923. return m.OldCreatedAt(ctx)
  46924. case wxcarduser.FieldUpdatedAt:
  46925. return m.OldUpdatedAt(ctx)
  46926. case wxcarduser.FieldDeletedAt:
  46927. return m.OldDeletedAt(ctx)
  46928. case wxcarduser.FieldWxid:
  46929. return m.OldWxid(ctx)
  46930. case wxcarduser.FieldAccount:
  46931. return m.OldAccount(ctx)
  46932. case wxcarduser.FieldAvatar:
  46933. return m.OldAvatar(ctx)
  46934. case wxcarduser.FieldNickname:
  46935. return m.OldNickname(ctx)
  46936. case wxcarduser.FieldRemark:
  46937. return m.OldRemark(ctx)
  46938. case wxcarduser.FieldPhone:
  46939. return m.OldPhone(ctx)
  46940. case wxcarduser.FieldOpenID:
  46941. return m.OldOpenID(ctx)
  46942. case wxcarduser.FieldUnionID:
  46943. return m.OldUnionID(ctx)
  46944. case wxcarduser.FieldSessionKey:
  46945. return m.OldSessionKey(ctx)
  46946. case wxcarduser.FieldIsVip:
  46947. return m.OldIsVip(ctx)
  46948. }
  46949. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  46950. }
  46951. // SetField sets the value of a field with the given name. It returns an error if
  46952. // the field is not defined in the schema, or if the type mismatched the field
  46953. // type.
  46954. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  46955. switch name {
  46956. case wxcarduser.FieldCreatedAt:
  46957. v, ok := value.(time.Time)
  46958. if !ok {
  46959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46960. }
  46961. m.SetCreatedAt(v)
  46962. return nil
  46963. case wxcarduser.FieldUpdatedAt:
  46964. v, ok := value.(time.Time)
  46965. if !ok {
  46966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46967. }
  46968. m.SetUpdatedAt(v)
  46969. return nil
  46970. case wxcarduser.FieldDeletedAt:
  46971. v, ok := value.(time.Time)
  46972. if !ok {
  46973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46974. }
  46975. m.SetDeletedAt(v)
  46976. return nil
  46977. case wxcarduser.FieldWxid:
  46978. v, ok := value.(string)
  46979. if !ok {
  46980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46981. }
  46982. m.SetWxid(v)
  46983. return nil
  46984. case wxcarduser.FieldAccount:
  46985. v, ok := value.(string)
  46986. if !ok {
  46987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46988. }
  46989. m.SetAccount(v)
  46990. return nil
  46991. case wxcarduser.FieldAvatar:
  46992. v, ok := value.(string)
  46993. if !ok {
  46994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46995. }
  46996. m.SetAvatar(v)
  46997. return nil
  46998. case wxcarduser.FieldNickname:
  46999. v, ok := value.(string)
  47000. if !ok {
  47001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47002. }
  47003. m.SetNickname(v)
  47004. return nil
  47005. case wxcarduser.FieldRemark:
  47006. v, ok := value.(string)
  47007. if !ok {
  47008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47009. }
  47010. m.SetRemark(v)
  47011. return nil
  47012. case wxcarduser.FieldPhone:
  47013. v, ok := value.(string)
  47014. if !ok {
  47015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47016. }
  47017. m.SetPhone(v)
  47018. return nil
  47019. case wxcarduser.FieldOpenID:
  47020. v, ok := value.(string)
  47021. if !ok {
  47022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47023. }
  47024. m.SetOpenID(v)
  47025. return nil
  47026. case wxcarduser.FieldUnionID:
  47027. v, ok := value.(string)
  47028. if !ok {
  47029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47030. }
  47031. m.SetUnionID(v)
  47032. return nil
  47033. case wxcarduser.FieldSessionKey:
  47034. v, ok := value.(string)
  47035. if !ok {
  47036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47037. }
  47038. m.SetSessionKey(v)
  47039. return nil
  47040. case wxcarduser.FieldIsVip:
  47041. v, ok := value.(int)
  47042. if !ok {
  47043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47044. }
  47045. m.SetIsVip(v)
  47046. return nil
  47047. }
  47048. return fmt.Errorf("unknown WxCardUser field %s", name)
  47049. }
  47050. // AddedFields returns all numeric fields that were incremented/decremented during
  47051. // this mutation.
  47052. func (m *WxCardUserMutation) AddedFields() []string {
  47053. var fields []string
  47054. if m.addis_vip != nil {
  47055. fields = append(fields, wxcarduser.FieldIsVip)
  47056. }
  47057. return fields
  47058. }
  47059. // AddedField returns the numeric value that was incremented/decremented on a field
  47060. // with the given name. The second boolean return value indicates that this field
  47061. // was not set, or was not defined in the schema.
  47062. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  47063. switch name {
  47064. case wxcarduser.FieldIsVip:
  47065. return m.AddedIsVip()
  47066. }
  47067. return nil, false
  47068. }
  47069. // AddField adds the value to the field with the given name. It returns an error if
  47070. // the field is not defined in the schema, or if the type mismatched the field
  47071. // type.
  47072. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  47073. switch name {
  47074. case wxcarduser.FieldIsVip:
  47075. v, ok := value.(int)
  47076. if !ok {
  47077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47078. }
  47079. m.AddIsVip(v)
  47080. return nil
  47081. }
  47082. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  47083. }
  47084. // ClearedFields returns all nullable fields that were cleared during this
  47085. // mutation.
  47086. func (m *WxCardUserMutation) ClearedFields() []string {
  47087. var fields []string
  47088. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  47089. fields = append(fields, wxcarduser.FieldDeletedAt)
  47090. }
  47091. return fields
  47092. }
  47093. // FieldCleared returns a boolean indicating if a field with the given name was
  47094. // cleared in this mutation.
  47095. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  47096. _, ok := m.clearedFields[name]
  47097. return ok
  47098. }
  47099. // ClearField clears the value of the field with the given name. It returns an
  47100. // error if the field is not defined in the schema.
  47101. func (m *WxCardUserMutation) ClearField(name string) error {
  47102. switch name {
  47103. case wxcarduser.FieldDeletedAt:
  47104. m.ClearDeletedAt()
  47105. return nil
  47106. }
  47107. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  47108. }
  47109. // ResetField resets all changes in the mutation for the field with the given name.
  47110. // It returns an error if the field is not defined in the schema.
  47111. func (m *WxCardUserMutation) ResetField(name string) error {
  47112. switch name {
  47113. case wxcarduser.FieldCreatedAt:
  47114. m.ResetCreatedAt()
  47115. return nil
  47116. case wxcarduser.FieldUpdatedAt:
  47117. m.ResetUpdatedAt()
  47118. return nil
  47119. case wxcarduser.FieldDeletedAt:
  47120. m.ResetDeletedAt()
  47121. return nil
  47122. case wxcarduser.FieldWxid:
  47123. m.ResetWxid()
  47124. return nil
  47125. case wxcarduser.FieldAccount:
  47126. m.ResetAccount()
  47127. return nil
  47128. case wxcarduser.FieldAvatar:
  47129. m.ResetAvatar()
  47130. return nil
  47131. case wxcarduser.FieldNickname:
  47132. m.ResetNickname()
  47133. return nil
  47134. case wxcarduser.FieldRemark:
  47135. m.ResetRemark()
  47136. return nil
  47137. case wxcarduser.FieldPhone:
  47138. m.ResetPhone()
  47139. return nil
  47140. case wxcarduser.FieldOpenID:
  47141. m.ResetOpenID()
  47142. return nil
  47143. case wxcarduser.FieldUnionID:
  47144. m.ResetUnionID()
  47145. return nil
  47146. case wxcarduser.FieldSessionKey:
  47147. m.ResetSessionKey()
  47148. return nil
  47149. case wxcarduser.FieldIsVip:
  47150. m.ResetIsVip()
  47151. return nil
  47152. }
  47153. return fmt.Errorf("unknown WxCardUser field %s", name)
  47154. }
  47155. // AddedEdges returns all edge names that were set/added in this mutation.
  47156. func (m *WxCardUserMutation) AddedEdges() []string {
  47157. edges := make([]string, 0, 0)
  47158. return edges
  47159. }
  47160. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47161. // name in this mutation.
  47162. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  47163. return nil
  47164. }
  47165. // RemovedEdges returns all edge names that were removed in this mutation.
  47166. func (m *WxCardUserMutation) RemovedEdges() []string {
  47167. edges := make([]string, 0, 0)
  47168. return edges
  47169. }
  47170. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47171. // the given name in this mutation.
  47172. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  47173. return nil
  47174. }
  47175. // ClearedEdges returns all edge names that were cleared in this mutation.
  47176. func (m *WxCardUserMutation) ClearedEdges() []string {
  47177. edges := make([]string, 0, 0)
  47178. return edges
  47179. }
  47180. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47181. // was cleared in this mutation.
  47182. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  47183. return false
  47184. }
  47185. // ClearEdge clears the value of the edge with the given name. It returns an error
  47186. // if that edge is not defined in the schema.
  47187. func (m *WxCardUserMutation) ClearEdge(name string) error {
  47188. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  47189. }
  47190. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47191. // It returns an error if the edge is not defined in the schema.
  47192. func (m *WxCardUserMutation) ResetEdge(name string) error {
  47193. return fmt.Errorf("unknown WxCardUser edge %s", name)
  47194. }
  47195. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  47196. type WxCardVisitMutation struct {
  47197. config
  47198. op Op
  47199. typ string
  47200. id *uint64
  47201. created_at *time.Time
  47202. updated_at *time.Time
  47203. deleted_at *time.Time
  47204. user_id *uint64
  47205. adduser_id *int64
  47206. bot_id *uint64
  47207. addbot_id *int64
  47208. bot_type *uint8
  47209. addbot_type *int8
  47210. clearedFields map[string]struct{}
  47211. done bool
  47212. oldValue func(context.Context) (*WxCardVisit, error)
  47213. predicates []predicate.WxCardVisit
  47214. }
  47215. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  47216. // wxcardvisitOption allows management of the mutation configuration using functional options.
  47217. type wxcardvisitOption func(*WxCardVisitMutation)
  47218. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  47219. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  47220. m := &WxCardVisitMutation{
  47221. config: c,
  47222. op: op,
  47223. typ: TypeWxCardVisit,
  47224. clearedFields: make(map[string]struct{}),
  47225. }
  47226. for _, opt := range opts {
  47227. opt(m)
  47228. }
  47229. return m
  47230. }
  47231. // withWxCardVisitID sets the ID field of the mutation.
  47232. func withWxCardVisitID(id uint64) wxcardvisitOption {
  47233. return func(m *WxCardVisitMutation) {
  47234. var (
  47235. err error
  47236. once sync.Once
  47237. value *WxCardVisit
  47238. )
  47239. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  47240. once.Do(func() {
  47241. if m.done {
  47242. err = errors.New("querying old values post mutation is not allowed")
  47243. } else {
  47244. value, err = m.Client().WxCardVisit.Get(ctx, id)
  47245. }
  47246. })
  47247. return value, err
  47248. }
  47249. m.id = &id
  47250. }
  47251. }
  47252. // withWxCardVisit sets the old WxCardVisit of the mutation.
  47253. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  47254. return func(m *WxCardVisitMutation) {
  47255. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  47256. return node, nil
  47257. }
  47258. m.id = &node.ID
  47259. }
  47260. }
  47261. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47262. // executed in a transaction (ent.Tx), a transactional client is returned.
  47263. func (m WxCardVisitMutation) Client() *Client {
  47264. client := &Client{config: m.config}
  47265. client.init()
  47266. return client
  47267. }
  47268. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47269. // it returns an error otherwise.
  47270. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  47271. if _, ok := m.driver.(*txDriver); !ok {
  47272. return nil, errors.New("ent: mutation is not running in a transaction")
  47273. }
  47274. tx := &Tx{config: m.config}
  47275. tx.init()
  47276. return tx, nil
  47277. }
  47278. // SetID sets the value of the id field. Note that this
  47279. // operation is only accepted on creation of WxCardVisit entities.
  47280. func (m *WxCardVisitMutation) SetID(id uint64) {
  47281. m.id = &id
  47282. }
  47283. // ID returns the ID value in the mutation. Note that the ID is only available
  47284. // if it was provided to the builder or after it was returned from the database.
  47285. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  47286. if m.id == nil {
  47287. return
  47288. }
  47289. return *m.id, true
  47290. }
  47291. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47292. // That means, if the mutation is applied within a transaction with an isolation level such
  47293. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47294. // or updated by the mutation.
  47295. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  47296. switch {
  47297. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47298. id, exists := m.ID()
  47299. if exists {
  47300. return []uint64{id}, nil
  47301. }
  47302. fallthrough
  47303. case m.op.Is(OpUpdate | OpDelete):
  47304. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  47305. default:
  47306. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47307. }
  47308. }
  47309. // SetCreatedAt sets the "created_at" field.
  47310. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  47311. m.created_at = &t
  47312. }
  47313. // CreatedAt returns the value of the "created_at" field in the mutation.
  47314. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  47315. v := m.created_at
  47316. if v == nil {
  47317. return
  47318. }
  47319. return *v, true
  47320. }
  47321. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  47322. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47324. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47325. if !m.op.Is(OpUpdateOne) {
  47326. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47327. }
  47328. if m.id == nil || m.oldValue == nil {
  47329. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47330. }
  47331. oldValue, err := m.oldValue(ctx)
  47332. if err != nil {
  47333. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47334. }
  47335. return oldValue.CreatedAt, nil
  47336. }
  47337. // ResetCreatedAt resets all changes to the "created_at" field.
  47338. func (m *WxCardVisitMutation) ResetCreatedAt() {
  47339. m.created_at = nil
  47340. }
  47341. // SetUpdatedAt sets the "updated_at" field.
  47342. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  47343. m.updated_at = &t
  47344. }
  47345. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47346. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  47347. v := m.updated_at
  47348. if v == nil {
  47349. return
  47350. }
  47351. return *v, true
  47352. }
  47353. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  47354. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47356. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47357. if !m.op.Is(OpUpdateOne) {
  47358. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47359. }
  47360. if m.id == nil || m.oldValue == nil {
  47361. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47362. }
  47363. oldValue, err := m.oldValue(ctx)
  47364. if err != nil {
  47365. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47366. }
  47367. return oldValue.UpdatedAt, nil
  47368. }
  47369. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47370. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  47371. m.updated_at = nil
  47372. }
  47373. // SetDeletedAt sets the "deleted_at" field.
  47374. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  47375. m.deleted_at = &t
  47376. }
  47377. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47378. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  47379. v := m.deleted_at
  47380. if v == nil {
  47381. return
  47382. }
  47383. return *v, true
  47384. }
  47385. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  47386. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47388. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47389. if !m.op.Is(OpUpdateOne) {
  47390. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47391. }
  47392. if m.id == nil || m.oldValue == nil {
  47393. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47394. }
  47395. oldValue, err := m.oldValue(ctx)
  47396. if err != nil {
  47397. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47398. }
  47399. return oldValue.DeletedAt, nil
  47400. }
  47401. // ClearDeletedAt clears the value of the "deleted_at" field.
  47402. func (m *WxCardVisitMutation) ClearDeletedAt() {
  47403. m.deleted_at = nil
  47404. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  47405. }
  47406. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47407. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  47408. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  47409. return ok
  47410. }
  47411. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47412. func (m *WxCardVisitMutation) ResetDeletedAt() {
  47413. m.deleted_at = nil
  47414. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  47415. }
  47416. // SetUserID sets the "user_id" field.
  47417. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  47418. m.user_id = &u
  47419. m.adduser_id = nil
  47420. }
  47421. // UserID returns the value of the "user_id" field in the mutation.
  47422. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  47423. v := m.user_id
  47424. if v == nil {
  47425. return
  47426. }
  47427. return *v, true
  47428. }
  47429. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  47430. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47432. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  47433. if !m.op.Is(OpUpdateOne) {
  47434. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  47435. }
  47436. if m.id == nil || m.oldValue == nil {
  47437. return v, errors.New("OldUserID requires an ID field in the mutation")
  47438. }
  47439. oldValue, err := m.oldValue(ctx)
  47440. if err != nil {
  47441. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  47442. }
  47443. return oldValue.UserID, nil
  47444. }
  47445. // AddUserID adds u to the "user_id" field.
  47446. func (m *WxCardVisitMutation) AddUserID(u int64) {
  47447. if m.adduser_id != nil {
  47448. *m.adduser_id += u
  47449. } else {
  47450. m.adduser_id = &u
  47451. }
  47452. }
  47453. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  47454. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  47455. v := m.adduser_id
  47456. if v == nil {
  47457. return
  47458. }
  47459. return *v, true
  47460. }
  47461. // ClearUserID clears the value of the "user_id" field.
  47462. func (m *WxCardVisitMutation) ClearUserID() {
  47463. m.user_id = nil
  47464. m.adduser_id = nil
  47465. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  47466. }
  47467. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  47468. func (m *WxCardVisitMutation) UserIDCleared() bool {
  47469. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  47470. return ok
  47471. }
  47472. // ResetUserID resets all changes to the "user_id" field.
  47473. func (m *WxCardVisitMutation) ResetUserID() {
  47474. m.user_id = nil
  47475. m.adduser_id = nil
  47476. delete(m.clearedFields, wxcardvisit.FieldUserID)
  47477. }
  47478. // SetBotID sets the "bot_id" field.
  47479. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  47480. m.bot_id = &u
  47481. m.addbot_id = nil
  47482. }
  47483. // BotID returns the value of the "bot_id" field in the mutation.
  47484. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  47485. v := m.bot_id
  47486. if v == nil {
  47487. return
  47488. }
  47489. return *v, true
  47490. }
  47491. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  47492. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47494. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  47495. if !m.op.Is(OpUpdateOne) {
  47496. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  47497. }
  47498. if m.id == nil || m.oldValue == nil {
  47499. return v, errors.New("OldBotID requires an ID field in the mutation")
  47500. }
  47501. oldValue, err := m.oldValue(ctx)
  47502. if err != nil {
  47503. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  47504. }
  47505. return oldValue.BotID, nil
  47506. }
  47507. // AddBotID adds u to the "bot_id" field.
  47508. func (m *WxCardVisitMutation) AddBotID(u int64) {
  47509. if m.addbot_id != nil {
  47510. *m.addbot_id += u
  47511. } else {
  47512. m.addbot_id = &u
  47513. }
  47514. }
  47515. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  47516. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  47517. v := m.addbot_id
  47518. if v == nil {
  47519. return
  47520. }
  47521. return *v, true
  47522. }
  47523. // ResetBotID resets all changes to the "bot_id" field.
  47524. func (m *WxCardVisitMutation) ResetBotID() {
  47525. m.bot_id = nil
  47526. m.addbot_id = nil
  47527. }
  47528. // SetBotType sets the "bot_type" field.
  47529. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  47530. m.bot_type = &u
  47531. m.addbot_type = nil
  47532. }
  47533. // BotType returns the value of the "bot_type" field in the mutation.
  47534. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  47535. v := m.bot_type
  47536. if v == nil {
  47537. return
  47538. }
  47539. return *v, true
  47540. }
  47541. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  47542. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47544. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  47545. if !m.op.Is(OpUpdateOne) {
  47546. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  47547. }
  47548. if m.id == nil || m.oldValue == nil {
  47549. return v, errors.New("OldBotType requires an ID field in the mutation")
  47550. }
  47551. oldValue, err := m.oldValue(ctx)
  47552. if err != nil {
  47553. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  47554. }
  47555. return oldValue.BotType, nil
  47556. }
  47557. // AddBotType adds u to the "bot_type" field.
  47558. func (m *WxCardVisitMutation) AddBotType(u int8) {
  47559. if m.addbot_type != nil {
  47560. *m.addbot_type += u
  47561. } else {
  47562. m.addbot_type = &u
  47563. }
  47564. }
  47565. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  47566. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  47567. v := m.addbot_type
  47568. if v == nil {
  47569. return
  47570. }
  47571. return *v, true
  47572. }
  47573. // ResetBotType resets all changes to the "bot_type" field.
  47574. func (m *WxCardVisitMutation) ResetBotType() {
  47575. m.bot_type = nil
  47576. m.addbot_type = nil
  47577. }
  47578. // Where appends a list predicates to the WxCardVisitMutation builder.
  47579. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  47580. m.predicates = append(m.predicates, ps...)
  47581. }
  47582. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  47583. // users can use type-assertion to append predicates that do not depend on any generated package.
  47584. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  47585. p := make([]predicate.WxCardVisit, len(ps))
  47586. for i := range ps {
  47587. p[i] = ps[i]
  47588. }
  47589. m.Where(p...)
  47590. }
  47591. // Op returns the operation name.
  47592. func (m *WxCardVisitMutation) Op() Op {
  47593. return m.op
  47594. }
  47595. // SetOp allows setting the mutation operation.
  47596. func (m *WxCardVisitMutation) SetOp(op Op) {
  47597. m.op = op
  47598. }
  47599. // Type returns the node type of this mutation (WxCardVisit).
  47600. func (m *WxCardVisitMutation) Type() string {
  47601. return m.typ
  47602. }
  47603. // Fields returns all fields that were changed during this mutation. Note that in
  47604. // order to get all numeric fields that were incremented/decremented, call
  47605. // AddedFields().
  47606. func (m *WxCardVisitMutation) Fields() []string {
  47607. fields := make([]string, 0, 6)
  47608. if m.created_at != nil {
  47609. fields = append(fields, wxcardvisit.FieldCreatedAt)
  47610. }
  47611. if m.updated_at != nil {
  47612. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  47613. }
  47614. if m.deleted_at != nil {
  47615. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47616. }
  47617. if m.user_id != nil {
  47618. fields = append(fields, wxcardvisit.FieldUserID)
  47619. }
  47620. if m.bot_id != nil {
  47621. fields = append(fields, wxcardvisit.FieldBotID)
  47622. }
  47623. if m.bot_type != nil {
  47624. fields = append(fields, wxcardvisit.FieldBotType)
  47625. }
  47626. return fields
  47627. }
  47628. // Field returns the value of a field with the given name. The second boolean
  47629. // return value indicates that this field was not set, or was not defined in the
  47630. // schema.
  47631. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  47632. switch name {
  47633. case wxcardvisit.FieldCreatedAt:
  47634. return m.CreatedAt()
  47635. case wxcardvisit.FieldUpdatedAt:
  47636. return m.UpdatedAt()
  47637. case wxcardvisit.FieldDeletedAt:
  47638. return m.DeletedAt()
  47639. case wxcardvisit.FieldUserID:
  47640. return m.UserID()
  47641. case wxcardvisit.FieldBotID:
  47642. return m.BotID()
  47643. case wxcardvisit.FieldBotType:
  47644. return m.BotType()
  47645. }
  47646. return nil, false
  47647. }
  47648. // OldField returns the old value of the field from the database. An error is
  47649. // returned if the mutation operation is not UpdateOne, or the query to the
  47650. // database failed.
  47651. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47652. switch name {
  47653. case wxcardvisit.FieldCreatedAt:
  47654. return m.OldCreatedAt(ctx)
  47655. case wxcardvisit.FieldUpdatedAt:
  47656. return m.OldUpdatedAt(ctx)
  47657. case wxcardvisit.FieldDeletedAt:
  47658. return m.OldDeletedAt(ctx)
  47659. case wxcardvisit.FieldUserID:
  47660. return m.OldUserID(ctx)
  47661. case wxcardvisit.FieldBotID:
  47662. return m.OldBotID(ctx)
  47663. case wxcardvisit.FieldBotType:
  47664. return m.OldBotType(ctx)
  47665. }
  47666. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  47667. }
  47668. // SetField sets the value of a field with the given name. It returns an error if
  47669. // the field is not defined in the schema, or if the type mismatched the field
  47670. // type.
  47671. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  47672. switch name {
  47673. case wxcardvisit.FieldCreatedAt:
  47674. v, ok := value.(time.Time)
  47675. if !ok {
  47676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47677. }
  47678. m.SetCreatedAt(v)
  47679. return nil
  47680. case wxcardvisit.FieldUpdatedAt:
  47681. v, ok := value.(time.Time)
  47682. if !ok {
  47683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47684. }
  47685. m.SetUpdatedAt(v)
  47686. return nil
  47687. case wxcardvisit.FieldDeletedAt:
  47688. v, ok := value.(time.Time)
  47689. if !ok {
  47690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47691. }
  47692. m.SetDeletedAt(v)
  47693. return nil
  47694. case wxcardvisit.FieldUserID:
  47695. v, ok := value.(uint64)
  47696. if !ok {
  47697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47698. }
  47699. m.SetUserID(v)
  47700. return nil
  47701. case wxcardvisit.FieldBotID:
  47702. v, ok := value.(uint64)
  47703. if !ok {
  47704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47705. }
  47706. m.SetBotID(v)
  47707. return nil
  47708. case wxcardvisit.FieldBotType:
  47709. v, ok := value.(uint8)
  47710. if !ok {
  47711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47712. }
  47713. m.SetBotType(v)
  47714. return nil
  47715. }
  47716. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47717. }
  47718. // AddedFields returns all numeric fields that were incremented/decremented during
  47719. // this mutation.
  47720. func (m *WxCardVisitMutation) AddedFields() []string {
  47721. var fields []string
  47722. if m.adduser_id != nil {
  47723. fields = append(fields, wxcardvisit.FieldUserID)
  47724. }
  47725. if m.addbot_id != nil {
  47726. fields = append(fields, wxcardvisit.FieldBotID)
  47727. }
  47728. if m.addbot_type != nil {
  47729. fields = append(fields, wxcardvisit.FieldBotType)
  47730. }
  47731. return fields
  47732. }
  47733. // AddedField returns the numeric value that was incremented/decremented on a field
  47734. // with the given name. The second boolean return value indicates that this field
  47735. // was not set, or was not defined in the schema.
  47736. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  47737. switch name {
  47738. case wxcardvisit.FieldUserID:
  47739. return m.AddedUserID()
  47740. case wxcardvisit.FieldBotID:
  47741. return m.AddedBotID()
  47742. case wxcardvisit.FieldBotType:
  47743. return m.AddedBotType()
  47744. }
  47745. return nil, false
  47746. }
  47747. // AddField adds the value to the field with the given name. It returns an error if
  47748. // the field is not defined in the schema, or if the type mismatched the field
  47749. // type.
  47750. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  47751. switch name {
  47752. case wxcardvisit.FieldUserID:
  47753. v, ok := value.(int64)
  47754. if !ok {
  47755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47756. }
  47757. m.AddUserID(v)
  47758. return nil
  47759. case wxcardvisit.FieldBotID:
  47760. v, ok := value.(int64)
  47761. if !ok {
  47762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47763. }
  47764. m.AddBotID(v)
  47765. return nil
  47766. case wxcardvisit.FieldBotType:
  47767. v, ok := value.(int8)
  47768. if !ok {
  47769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47770. }
  47771. m.AddBotType(v)
  47772. return nil
  47773. }
  47774. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  47775. }
  47776. // ClearedFields returns all nullable fields that were cleared during this
  47777. // mutation.
  47778. func (m *WxCardVisitMutation) ClearedFields() []string {
  47779. var fields []string
  47780. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  47781. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47782. }
  47783. if m.FieldCleared(wxcardvisit.FieldUserID) {
  47784. fields = append(fields, wxcardvisit.FieldUserID)
  47785. }
  47786. return fields
  47787. }
  47788. // FieldCleared returns a boolean indicating if a field with the given name was
  47789. // cleared in this mutation.
  47790. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  47791. _, ok := m.clearedFields[name]
  47792. return ok
  47793. }
  47794. // ClearField clears the value of the field with the given name. It returns an
  47795. // error if the field is not defined in the schema.
  47796. func (m *WxCardVisitMutation) ClearField(name string) error {
  47797. switch name {
  47798. case wxcardvisit.FieldDeletedAt:
  47799. m.ClearDeletedAt()
  47800. return nil
  47801. case wxcardvisit.FieldUserID:
  47802. m.ClearUserID()
  47803. return nil
  47804. }
  47805. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  47806. }
  47807. // ResetField resets all changes in the mutation for the field with the given name.
  47808. // It returns an error if the field is not defined in the schema.
  47809. func (m *WxCardVisitMutation) ResetField(name string) error {
  47810. switch name {
  47811. case wxcardvisit.FieldCreatedAt:
  47812. m.ResetCreatedAt()
  47813. return nil
  47814. case wxcardvisit.FieldUpdatedAt:
  47815. m.ResetUpdatedAt()
  47816. return nil
  47817. case wxcardvisit.FieldDeletedAt:
  47818. m.ResetDeletedAt()
  47819. return nil
  47820. case wxcardvisit.FieldUserID:
  47821. m.ResetUserID()
  47822. return nil
  47823. case wxcardvisit.FieldBotID:
  47824. m.ResetBotID()
  47825. return nil
  47826. case wxcardvisit.FieldBotType:
  47827. m.ResetBotType()
  47828. return nil
  47829. }
  47830. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47831. }
  47832. // AddedEdges returns all edge names that were set/added in this mutation.
  47833. func (m *WxCardVisitMutation) AddedEdges() []string {
  47834. edges := make([]string, 0, 0)
  47835. return edges
  47836. }
  47837. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47838. // name in this mutation.
  47839. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  47840. return nil
  47841. }
  47842. // RemovedEdges returns all edge names that were removed in this mutation.
  47843. func (m *WxCardVisitMutation) RemovedEdges() []string {
  47844. edges := make([]string, 0, 0)
  47845. return edges
  47846. }
  47847. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47848. // the given name in this mutation.
  47849. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  47850. return nil
  47851. }
  47852. // ClearedEdges returns all edge names that were cleared in this mutation.
  47853. func (m *WxCardVisitMutation) ClearedEdges() []string {
  47854. edges := make([]string, 0, 0)
  47855. return edges
  47856. }
  47857. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47858. // was cleared in this mutation.
  47859. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  47860. return false
  47861. }
  47862. // ClearEdge clears the value of the edge with the given name. It returns an error
  47863. // if that edge is not defined in the schema.
  47864. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  47865. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  47866. }
  47867. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47868. // It returns an error if the edge is not defined in the schema.
  47869. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  47870. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  47871. }
  47872. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  47873. type XunjiMutation struct {
  47874. config
  47875. op Op
  47876. typ string
  47877. id *uint64
  47878. created_at *time.Time
  47879. updated_at *time.Time
  47880. status *uint8
  47881. addstatus *int8
  47882. deleted_at *time.Time
  47883. app_key *string
  47884. app_secret *string
  47885. token *string
  47886. encoding_key *string
  47887. organization_id *uint64
  47888. addorganization_id *int64
  47889. clearedFields map[string]struct{}
  47890. done bool
  47891. oldValue func(context.Context) (*Xunji, error)
  47892. predicates []predicate.Xunji
  47893. }
  47894. var _ ent.Mutation = (*XunjiMutation)(nil)
  47895. // xunjiOption allows management of the mutation configuration using functional options.
  47896. type xunjiOption func(*XunjiMutation)
  47897. // newXunjiMutation creates new mutation for the Xunji entity.
  47898. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  47899. m := &XunjiMutation{
  47900. config: c,
  47901. op: op,
  47902. typ: TypeXunji,
  47903. clearedFields: make(map[string]struct{}),
  47904. }
  47905. for _, opt := range opts {
  47906. opt(m)
  47907. }
  47908. return m
  47909. }
  47910. // withXunjiID sets the ID field of the mutation.
  47911. func withXunjiID(id uint64) xunjiOption {
  47912. return func(m *XunjiMutation) {
  47913. var (
  47914. err error
  47915. once sync.Once
  47916. value *Xunji
  47917. )
  47918. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  47919. once.Do(func() {
  47920. if m.done {
  47921. err = errors.New("querying old values post mutation is not allowed")
  47922. } else {
  47923. value, err = m.Client().Xunji.Get(ctx, id)
  47924. }
  47925. })
  47926. return value, err
  47927. }
  47928. m.id = &id
  47929. }
  47930. }
  47931. // withXunji sets the old Xunji of the mutation.
  47932. func withXunji(node *Xunji) xunjiOption {
  47933. return func(m *XunjiMutation) {
  47934. m.oldValue = func(context.Context) (*Xunji, error) {
  47935. return node, nil
  47936. }
  47937. m.id = &node.ID
  47938. }
  47939. }
  47940. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47941. // executed in a transaction (ent.Tx), a transactional client is returned.
  47942. func (m XunjiMutation) Client() *Client {
  47943. client := &Client{config: m.config}
  47944. client.init()
  47945. return client
  47946. }
  47947. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47948. // it returns an error otherwise.
  47949. func (m XunjiMutation) Tx() (*Tx, error) {
  47950. if _, ok := m.driver.(*txDriver); !ok {
  47951. return nil, errors.New("ent: mutation is not running in a transaction")
  47952. }
  47953. tx := &Tx{config: m.config}
  47954. tx.init()
  47955. return tx, nil
  47956. }
  47957. // SetID sets the value of the id field. Note that this
  47958. // operation is only accepted on creation of Xunji entities.
  47959. func (m *XunjiMutation) SetID(id uint64) {
  47960. m.id = &id
  47961. }
  47962. // ID returns the ID value in the mutation. Note that the ID is only available
  47963. // if it was provided to the builder or after it was returned from the database.
  47964. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  47965. if m.id == nil {
  47966. return
  47967. }
  47968. return *m.id, true
  47969. }
  47970. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47971. // That means, if the mutation is applied within a transaction with an isolation level such
  47972. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47973. // or updated by the mutation.
  47974. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  47975. switch {
  47976. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47977. id, exists := m.ID()
  47978. if exists {
  47979. return []uint64{id}, nil
  47980. }
  47981. fallthrough
  47982. case m.op.Is(OpUpdate | OpDelete):
  47983. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  47984. default:
  47985. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47986. }
  47987. }
  47988. // SetCreatedAt sets the "created_at" field.
  47989. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  47990. m.created_at = &t
  47991. }
  47992. // CreatedAt returns the value of the "created_at" field in the mutation.
  47993. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  47994. v := m.created_at
  47995. if v == nil {
  47996. return
  47997. }
  47998. return *v, true
  47999. }
  48000. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  48001. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48003. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48004. if !m.op.Is(OpUpdateOne) {
  48005. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48006. }
  48007. if m.id == nil || m.oldValue == nil {
  48008. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48009. }
  48010. oldValue, err := m.oldValue(ctx)
  48011. if err != nil {
  48012. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48013. }
  48014. return oldValue.CreatedAt, nil
  48015. }
  48016. // ResetCreatedAt resets all changes to the "created_at" field.
  48017. func (m *XunjiMutation) ResetCreatedAt() {
  48018. m.created_at = nil
  48019. }
  48020. // SetUpdatedAt sets the "updated_at" field.
  48021. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  48022. m.updated_at = &t
  48023. }
  48024. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48025. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  48026. v := m.updated_at
  48027. if v == nil {
  48028. return
  48029. }
  48030. return *v, true
  48031. }
  48032. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  48033. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48035. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48036. if !m.op.Is(OpUpdateOne) {
  48037. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48038. }
  48039. if m.id == nil || m.oldValue == nil {
  48040. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48041. }
  48042. oldValue, err := m.oldValue(ctx)
  48043. if err != nil {
  48044. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48045. }
  48046. return oldValue.UpdatedAt, nil
  48047. }
  48048. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48049. func (m *XunjiMutation) ResetUpdatedAt() {
  48050. m.updated_at = nil
  48051. }
  48052. // SetStatus sets the "status" field.
  48053. func (m *XunjiMutation) SetStatus(u uint8) {
  48054. m.status = &u
  48055. m.addstatus = nil
  48056. }
  48057. // Status returns the value of the "status" field in the mutation.
  48058. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  48059. v := m.status
  48060. if v == nil {
  48061. return
  48062. }
  48063. return *v, true
  48064. }
  48065. // OldStatus returns the old "status" field's value of the Xunji entity.
  48066. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48068. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  48069. if !m.op.Is(OpUpdateOne) {
  48070. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  48071. }
  48072. if m.id == nil || m.oldValue == nil {
  48073. return v, errors.New("OldStatus requires an ID field in the mutation")
  48074. }
  48075. oldValue, err := m.oldValue(ctx)
  48076. if err != nil {
  48077. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  48078. }
  48079. return oldValue.Status, nil
  48080. }
  48081. // AddStatus adds u to the "status" field.
  48082. func (m *XunjiMutation) AddStatus(u int8) {
  48083. if m.addstatus != nil {
  48084. *m.addstatus += u
  48085. } else {
  48086. m.addstatus = &u
  48087. }
  48088. }
  48089. // AddedStatus returns the value that was added to the "status" field in this mutation.
  48090. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  48091. v := m.addstatus
  48092. if v == nil {
  48093. return
  48094. }
  48095. return *v, true
  48096. }
  48097. // ClearStatus clears the value of the "status" field.
  48098. func (m *XunjiMutation) ClearStatus() {
  48099. m.status = nil
  48100. m.addstatus = nil
  48101. m.clearedFields[xunji.FieldStatus] = struct{}{}
  48102. }
  48103. // StatusCleared returns if the "status" field was cleared in this mutation.
  48104. func (m *XunjiMutation) StatusCleared() bool {
  48105. _, ok := m.clearedFields[xunji.FieldStatus]
  48106. return ok
  48107. }
  48108. // ResetStatus resets all changes to the "status" field.
  48109. func (m *XunjiMutation) ResetStatus() {
  48110. m.status = nil
  48111. m.addstatus = nil
  48112. delete(m.clearedFields, xunji.FieldStatus)
  48113. }
  48114. // SetDeletedAt sets the "deleted_at" field.
  48115. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  48116. m.deleted_at = &t
  48117. }
  48118. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48119. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  48120. v := m.deleted_at
  48121. if v == nil {
  48122. return
  48123. }
  48124. return *v, true
  48125. }
  48126. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  48127. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48129. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48130. if !m.op.Is(OpUpdateOne) {
  48131. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48132. }
  48133. if m.id == nil || m.oldValue == nil {
  48134. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48135. }
  48136. oldValue, err := m.oldValue(ctx)
  48137. if err != nil {
  48138. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48139. }
  48140. return oldValue.DeletedAt, nil
  48141. }
  48142. // ClearDeletedAt clears the value of the "deleted_at" field.
  48143. func (m *XunjiMutation) ClearDeletedAt() {
  48144. m.deleted_at = nil
  48145. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  48146. }
  48147. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48148. func (m *XunjiMutation) DeletedAtCleared() bool {
  48149. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  48150. return ok
  48151. }
  48152. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48153. func (m *XunjiMutation) ResetDeletedAt() {
  48154. m.deleted_at = nil
  48155. delete(m.clearedFields, xunji.FieldDeletedAt)
  48156. }
  48157. // SetAppKey sets the "app_key" field.
  48158. func (m *XunjiMutation) SetAppKey(s string) {
  48159. m.app_key = &s
  48160. }
  48161. // AppKey returns the value of the "app_key" field in the mutation.
  48162. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  48163. v := m.app_key
  48164. if v == nil {
  48165. return
  48166. }
  48167. return *v, true
  48168. }
  48169. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  48170. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48172. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  48173. if !m.op.Is(OpUpdateOne) {
  48174. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  48175. }
  48176. if m.id == nil || m.oldValue == nil {
  48177. return v, errors.New("OldAppKey requires an ID field in the mutation")
  48178. }
  48179. oldValue, err := m.oldValue(ctx)
  48180. if err != nil {
  48181. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  48182. }
  48183. return oldValue.AppKey, nil
  48184. }
  48185. // ClearAppKey clears the value of the "app_key" field.
  48186. func (m *XunjiMutation) ClearAppKey() {
  48187. m.app_key = nil
  48188. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  48189. }
  48190. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  48191. func (m *XunjiMutation) AppKeyCleared() bool {
  48192. _, ok := m.clearedFields[xunji.FieldAppKey]
  48193. return ok
  48194. }
  48195. // ResetAppKey resets all changes to the "app_key" field.
  48196. func (m *XunjiMutation) ResetAppKey() {
  48197. m.app_key = nil
  48198. delete(m.clearedFields, xunji.FieldAppKey)
  48199. }
  48200. // SetAppSecret sets the "app_secret" field.
  48201. func (m *XunjiMutation) SetAppSecret(s string) {
  48202. m.app_secret = &s
  48203. }
  48204. // AppSecret returns the value of the "app_secret" field in the mutation.
  48205. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  48206. v := m.app_secret
  48207. if v == nil {
  48208. return
  48209. }
  48210. return *v, true
  48211. }
  48212. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  48213. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48215. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  48216. if !m.op.Is(OpUpdateOne) {
  48217. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  48218. }
  48219. if m.id == nil || m.oldValue == nil {
  48220. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  48221. }
  48222. oldValue, err := m.oldValue(ctx)
  48223. if err != nil {
  48224. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  48225. }
  48226. return oldValue.AppSecret, nil
  48227. }
  48228. // ClearAppSecret clears the value of the "app_secret" field.
  48229. func (m *XunjiMutation) ClearAppSecret() {
  48230. m.app_secret = nil
  48231. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  48232. }
  48233. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  48234. func (m *XunjiMutation) AppSecretCleared() bool {
  48235. _, ok := m.clearedFields[xunji.FieldAppSecret]
  48236. return ok
  48237. }
  48238. // ResetAppSecret resets all changes to the "app_secret" field.
  48239. func (m *XunjiMutation) ResetAppSecret() {
  48240. m.app_secret = nil
  48241. delete(m.clearedFields, xunji.FieldAppSecret)
  48242. }
  48243. // SetToken sets the "token" field.
  48244. func (m *XunjiMutation) SetToken(s string) {
  48245. m.token = &s
  48246. }
  48247. // Token returns the value of the "token" field in the mutation.
  48248. func (m *XunjiMutation) Token() (r string, exists bool) {
  48249. v := m.token
  48250. if v == nil {
  48251. return
  48252. }
  48253. return *v, true
  48254. }
  48255. // OldToken returns the old "token" field's value of the Xunji entity.
  48256. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48258. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  48259. if !m.op.Is(OpUpdateOne) {
  48260. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  48261. }
  48262. if m.id == nil || m.oldValue == nil {
  48263. return v, errors.New("OldToken requires an ID field in the mutation")
  48264. }
  48265. oldValue, err := m.oldValue(ctx)
  48266. if err != nil {
  48267. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  48268. }
  48269. return oldValue.Token, nil
  48270. }
  48271. // ClearToken clears the value of the "token" field.
  48272. func (m *XunjiMutation) ClearToken() {
  48273. m.token = nil
  48274. m.clearedFields[xunji.FieldToken] = struct{}{}
  48275. }
  48276. // TokenCleared returns if the "token" field was cleared in this mutation.
  48277. func (m *XunjiMutation) TokenCleared() bool {
  48278. _, ok := m.clearedFields[xunji.FieldToken]
  48279. return ok
  48280. }
  48281. // ResetToken resets all changes to the "token" field.
  48282. func (m *XunjiMutation) ResetToken() {
  48283. m.token = nil
  48284. delete(m.clearedFields, xunji.FieldToken)
  48285. }
  48286. // SetEncodingKey sets the "encoding_key" field.
  48287. func (m *XunjiMutation) SetEncodingKey(s string) {
  48288. m.encoding_key = &s
  48289. }
  48290. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  48291. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  48292. v := m.encoding_key
  48293. if v == nil {
  48294. return
  48295. }
  48296. return *v, true
  48297. }
  48298. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  48299. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48301. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  48302. if !m.op.Is(OpUpdateOne) {
  48303. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  48304. }
  48305. if m.id == nil || m.oldValue == nil {
  48306. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  48307. }
  48308. oldValue, err := m.oldValue(ctx)
  48309. if err != nil {
  48310. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  48311. }
  48312. return oldValue.EncodingKey, nil
  48313. }
  48314. // ClearEncodingKey clears the value of the "encoding_key" field.
  48315. func (m *XunjiMutation) ClearEncodingKey() {
  48316. m.encoding_key = nil
  48317. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  48318. }
  48319. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  48320. func (m *XunjiMutation) EncodingKeyCleared() bool {
  48321. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  48322. return ok
  48323. }
  48324. // ResetEncodingKey resets all changes to the "encoding_key" field.
  48325. func (m *XunjiMutation) ResetEncodingKey() {
  48326. m.encoding_key = nil
  48327. delete(m.clearedFields, xunji.FieldEncodingKey)
  48328. }
  48329. // SetOrganizationID sets the "organization_id" field.
  48330. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  48331. m.organization_id = &u
  48332. m.addorganization_id = nil
  48333. }
  48334. // OrganizationID returns the value of the "organization_id" field in the mutation.
  48335. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  48336. v := m.organization_id
  48337. if v == nil {
  48338. return
  48339. }
  48340. return *v, true
  48341. }
  48342. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  48343. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48345. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  48346. if !m.op.Is(OpUpdateOne) {
  48347. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  48348. }
  48349. if m.id == nil || m.oldValue == nil {
  48350. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  48351. }
  48352. oldValue, err := m.oldValue(ctx)
  48353. if err != nil {
  48354. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  48355. }
  48356. return oldValue.OrganizationID, nil
  48357. }
  48358. // AddOrganizationID adds u to the "organization_id" field.
  48359. func (m *XunjiMutation) AddOrganizationID(u int64) {
  48360. if m.addorganization_id != nil {
  48361. *m.addorganization_id += u
  48362. } else {
  48363. m.addorganization_id = &u
  48364. }
  48365. }
  48366. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  48367. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  48368. v := m.addorganization_id
  48369. if v == nil {
  48370. return
  48371. }
  48372. return *v, true
  48373. }
  48374. // ResetOrganizationID resets all changes to the "organization_id" field.
  48375. func (m *XunjiMutation) ResetOrganizationID() {
  48376. m.organization_id = nil
  48377. m.addorganization_id = nil
  48378. }
  48379. // Where appends a list predicates to the XunjiMutation builder.
  48380. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  48381. m.predicates = append(m.predicates, ps...)
  48382. }
  48383. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  48384. // users can use type-assertion to append predicates that do not depend on any generated package.
  48385. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  48386. p := make([]predicate.Xunji, len(ps))
  48387. for i := range ps {
  48388. p[i] = ps[i]
  48389. }
  48390. m.Where(p...)
  48391. }
  48392. // Op returns the operation name.
  48393. func (m *XunjiMutation) Op() Op {
  48394. return m.op
  48395. }
  48396. // SetOp allows setting the mutation operation.
  48397. func (m *XunjiMutation) SetOp(op Op) {
  48398. m.op = op
  48399. }
  48400. // Type returns the node type of this mutation (Xunji).
  48401. func (m *XunjiMutation) Type() string {
  48402. return m.typ
  48403. }
  48404. // Fields returns all fields that were changed during this mutation. Note that in
  48405. // order to get all numeric fields that were incremented/decremented, call
  48406. // AddedFields().
  48407. func (m *XunjiMutation) Fields() []string {
  48408. fields := make([]string, 0, 9)
  48409. if m.created_at != nil {
  48410. fields = append(fields, xunji.FieldCreatedAt)
  48411. }
  48412. if m.updated_at != nil {
  48413. fields = append(fields, xunji.FieldUpdatedAt)
  48414. }
  48415. if m.status != nil {
  48416. fields = append(fields, xunji.FieldStatus)
  48417. }
  48418. if m.deleted_at != nil {
  48419. fields = append(fields, xunji.FieldDeletedAt)
  48420. }
  48421. if m.app_key != nil {
  48422. fields = append(fields, xunji.FieldAppKey)
  48423. }
  48424. if m.app_secret != nil {
  48425. fields = append(fields, xunji.FieldAppSecret)
  48426. }
  48427. if m.token != nil {
  48428. fields = append(fields, xunji.FieldToken)
  48429. }
  48430. if m.encoding_key != nil {
  48431. fields = append(fields, xunji.FieldEncodingKey)
  48432. }
  48433. if m.organization_id != nil {
  48434. fields = append(fields, xunji.FieldOrganizationID)
  48435. }
  48436. return fields
  48437. }
  48438. // Field returns the value of a field with the given name. The second boolean
  48439. // return value indicates that this field was not set, or was not defined in the
  48440. // schema.
  48441. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  48442. switch name {
  48443. case xunji.FieldCreatedAt:
  48444. return m.CreatedAt()
  48445. case xunji.FieldUpdatedAt:
  48446. return m.UpdatedAt()
  48447. case xunji.FieldStatus:
  48448. return m.Status()
  48449. case xunji.FieldDeletedAt:
  48450. return m.DeletedAt()
  48451. case xunji.FieldAppKey:
  48452. return m.AppKey()
  48453. case xunji.FieldAppSecret:
  48454. return m.AppSecret()
  48455. case xunji.FieldToken:
  48456. return m.Token()
  48457. case xunji.FieldEncodingKey:
  48458. return m.EncodingKey()
  48459. case xunji.FieldOrganizationID:
  48460. return m.OrganizationID()
  48461. }
  48462. return nil, false
  48463. }
  48464. // OldField returns the old value of the field from the database. An error is
  48465. // returned if the mutation operation is not UpdateOne, or the query to the
  48466. // database failed.
  48467. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48468. switch name {
  48469. case xunji.FieldCreatedAt:
  48470. return m.OldCreatedAt(ctx)
  48471. case xunji.FieldUpdatedAt:
  48472. return m.OldUpdatedAt(ctx)
  48473. case xunji.FieldStatus:
  48474. return m.OldStatus(ctx)
  48475. case xunji.FieldDeletedAt:
  48476. return m.OldDeletedAt(ctx)
  48477. case xunji.FieldAppKey:
  48478. return m.OldAppKey(ctx)
  48479. case xunji.FieldAppSecret:
  48480. return m.OldAppSecret(ctx)
  48481. case xunji.FieldToken:
  48482. return m.OldToken(ctx)
  48483. case xunji.FieldEncodingKey:
  48484. return m.OldEncodingKey(ctx)
  48485. case xunji.FieldOrganizationID:
  48486. return m.OldOrganizationID(ctx)
  48487. }
  48488. return nil, fmt.Errorf("unknown Xunji field %s", name)
  48489. }
  48490. // SetField sets the value of a field with the given name. It returns an error if
  48491. // the field is not defined in the schema, or if the type mismatched the field
  48492. // type.
  48493. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  48494. switch name {
  48495. case xunji.FieldCreatedAt:
  48496. v, ok := value.(time.Time)
  48497. if !ok {
  48498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48499. }
  48500. m.SetCreatedAt(v)
  48501. return nil
  48502. case xunji.FieldUpdatedAt:
  48503. v, ok := value.(time.Time)
  48504. if !ok {
  48505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48506. }
  48507. m.SetUpdatedAt(v)
  48508. return nil
  48509. case xunji.FieldStatus:
  48510. v, ok := value.(uint8)
  48511. if !ok {
  48512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48513. }
  48514. m.SetStatus(v)
  48515. return nil
  48516. case xunji.FieldDeletedAt:
  48517. v, ok := value.(time.Time)
  48518. if !ok {
  48519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48520. }
  48521. m.SetDeletedAt(v)
  48522. return nil
  48523. case xunji.FieldAppKey:
  48524. v, ok := value.(string)
  48525. if !ok {
  48526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48527. }
  48528. m.SetAppKey(v)
  48529. return nil
  48530. case xunji.FieldAppSecret:
  48531. v, ok := value.(string)
  48532. if !ok {
  48533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48534. }
  48535. m.SetAppSecret(v)
  48536. return nil
  48537. case xunji.FieldToken:
  48538. v, ok := value.(string)
  48539. if !ok {
  48540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48541. }
  48542. m.SetToken(v)
  48543. return nil
  48544. case xunji.FieldEncodingKey:
  48545. v, ok := value.(string)
  48546. if !ok {
  48547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48548. }
  48549. m.SetEncodingKey(v)
  48550. return nil
  48551. case xunji.FieldOrganizationID:
  48552. v, ok := value.(uint64)
  48553. if !ok {
  48554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48555. }
  48556. m.SetOrganizationID(v)
  48557. return nil
  48558. }
  48559. return fmt.Errorf("unknown Xunji field %s", name)
  48560. }
  48561. // AddedFields returns all numeric fields that were incremented/decremented during
  48562. // this mutation.
  48563. func (m *XunjiMutation) AddedFields() []string {
  48564. var fields []string
  48565. if m.addstatus != nil {
  48566. fields = append(fields, xunji.FieldStatus)
  48567. }
  48568. if m.addorganization_id != nil {
  48569. fields = append(fields, xunji.FieldOrganizationID)
  48570. }
  48571. return fields
  48572. }
  48573. // AddedField returns the numeric value that was incremented/decremented on a field
  48574. // with the given name. The second boolean return value indicates that this field
  48575. // was not set, or was not defined in the schema.
  48576. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  48577. switch name {
  48578. case xunji.FieldStatus:
  48579. return m.AddedStatus()
  48580. case xunji.FieldOrganizationID:
  48581. return m.AddedOrganizationID()
  48582. }
  48583. return nil, false
  48584. }
  48585. // AddField adds the value to the field with the given name. It returns an error if
  48586. // the field is not defined in the schema, or if the type mismatched the field
  48587. // type.
  48588. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  48589. switch name {
  48590. case xunji.FieldStatus:
  48591. v, ok := value.(int8)
  48592. if !ok {
  48593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48594. }
  48595. m.AddStatus(v)
  48596. return nil
  48597. case xunji.FieldOrganizationID:
  48598. v, ok := value.(int64)
  48599. if !ok {
  48600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48601. }
  48602. m.AddOrganizationID(v)
  48603. return nil
  48604. }
  48605. return fmt.Errorf("unknown Xunji numeric field %s", name)
  48606. }
  48607. // ClearedFields returns all nullable fields that were cleared during this
  48608. // mutation.
  48609. func (m *XunjiMutation) ClearedFields() []string {
  48610. var fields []string
  48611. if m.FieldCleared(xunji.FieldStatus) {
  48612. fields = append(fields, xunji.FieldStatus)
  48613. }
  48614. if m.FieldCleared(xunji.FieldDeletedAt) {
  48615. fields = append(fields, xunji.FieldDeletedAt)
  48616. }
  48617. if m.FieldCleared(xunji.FieldAppKey) {
  48618. fields = append(fields, xunji.FieldAppKey)
  48619. }
  48620. if m.FieldCleared(xunji.FieldAppSecret) {
  48621. fields = append(fields, xunji.FieldAppSecret)
  48622. }
  48623. if m.FieldCleared(xunji.FieldToken) {
  48624. fields = append(fields, xunji.FieldToken)
  48625. }
  48626. if m.FieldCleared(xunji.FieldEncodingKey) {
  48627. fields = append(fields, xunji.FieldEncodingKey)
  48628. }
  48629. return fields
  48630. }
  48631. // FieldCleared returns a boolean indicating if a field with the given name was
  48632. // cleared in this mutation.
  48633. func (m *XunjiMutation) FieldCleared(name string) bool {
  48634. _, ok := m.clearedFields[name]
  48635. return ok
  48636. }
  48637. // ClearField clears the value of the field with the given name. It returns an
  48638. // error if the field is not defined in the schema.
  48639. func (m *XunjiMutation) ClearField(name string) error {
  48640. switch name {
  48641. case xunji.FieldStatus:
  48642. m.ClearStatus()
  48643. return nil
  48644. case xunji.FieldDeletedAt:
  48645. m.ClearDeletedAt()
  48646. return nil
  48647. case xunji.FieldAppKey:
  48648. m.ClearAppKey()
  48649. return nil
  48650. case xunji.FieldAppSecret:
  48651. m.ClearAppSecret()
  48652. return nil
  48653. case xunji.FieldToken:
  48654. m.ClearToken()
  48655. return nil
  48656. case xunji.FieldEncodingKey:
  48657. m.ClearEncodingKey()
  48658. return nil
  48659. }
  48660. return fmt.Errorf("unknown Xunji nullable field %s", name)
  48661. }
  48662. // ResetField resets all changes in the mutation for the field with the given name.
  48663. // It returns an error if the field is not defined in the schema.
  48664. func (m *XunjiMutation) ResetField(name string) error {
  48665. switch name {
  48666. case xunji.FieldCreatedAt:
  48667. m.ResetCreatedAt()
  48668. return nil
  48669. case xunji.FieldUpdatedAt:
  48670. m.ResetUpdatedAt()
  48671. return nil
  48672. case xunji.FieldStatus:
  48673. m.ResetStatus()
  48674. return nil
  48675. case xunji.FieldDeletedAt:
  48676. m.ResetDeletedAt()
  48677. return nil
  48678. case xunji.FieldAppKey:
  48679. m.ResetAppKey()
  48680. return nil
  48681. case xunji.FieldAppSecret:
  48682. m.ResetAppSecret()
  48683. return nil
  48684. case xunji.FieldToken:
  48685. m.ResetToken()
  48686. return nil
  48687. case xunji.FieldEncodingKey:
  48688. m.ResetEncodingKey()
  48689. return nil
  48690. case xunji.FieldOrganizationID:
  48691. m.ResetOrganizationID()
  48692. return nil
  48693. }
  48694. return fmt.Errorf("unknown Xunji field %s", name)
  48695. }
  48696. // AddedEdges returns all edge names that were set/added in this mutation.
  48697. func (m *XunjiMutation) AddedEdges() []string {
  48698. edges := make([]string, 0, 0)
  48699. return edges
  48700. }
  48701. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48702. // name in this mutation.
  48703. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  48704. return nil
  48705. }
  48706. // RemovedEdges returns all edge names that were removed in this mutation.
  48707. func (m *XunjiMutation) RemovedEdges() []string {
  48708. edges := make([]string, 0, 0)
  48709. return edges
  48710. }
  48711. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48712. // the given name in this mutation.
  48713. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  48714. return nil
  48715. }
  48716. // ClearedEdges returns all edge names that were cleared in this mutation.
  48717. func (m *XunjiMutation) ClearedEdges() []string {
  48718. edges := make([]string, 0, 0)
  48719. return edges
  48720. }
  48721. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48722. // was cleared in this mutation.
  48723. func (m *XunjiMutation) EdgeCleared(name string) bool {
  48724. return false
  48725. }
  48726. // ClearEdge clears the value of the edge with the given name. It returns an error
  48727. // if that edge is not defined in the schema.
  48728. func (m *XunjiMutation) ClearEdge(name string) error {
  48729. return fmt.Errorf("unknown Xunji unique edge %s", name)
  48730. }
  48731. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48732. // It returns an error if the edge is not defined in the schema.
  48733. func (m *XunjiMutation) ResetEdge(name string) error {
  48734. return fmt.Errorf("unknown Xunji edge %s", name)
  48735. }
  48736. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  48737. type XunjiServiceMutation struct {
  48738. config
  48739. op Op
  48740. typ string
  48741. id *uint64
  48742. created_at *time.Time
  48743. updated_at *time.Time
  48744. status *uint8
  48745. addstatus *int8
  48746. deleted_at *time.Time
  48747. xunji_id *uint64
  48748. addxunji_id *int64
  48749. organization_id *uint64
  48750. addorganization_id *int64
  48751. wxid *string
  48752. api_base *string
  48753. api_key *string
  48754. clearedFields map[string]struct{}
  48755. agent *uint64
  48756. clearedagent bool
  48757. done bool
  48758. oldValue func(context.Context) (*XunjiService, error)
  48759. predicates []predicate.XunjiService
  48760. }
  48761. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  48762. // xunjiserviceOption allows management of the mutation configuration using functional options.
  48763. type xunjiserviceOption func(*XunjiServiceMutation)
  48764. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  48765. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  48766. m := &XunjiServiceMutation{
  48767. config: c,
  48768. op: op,
  48769. typ: TypeXunjiService,
  48770. clearedFields: make(map[string]struct{}),
  48771. }
  48772. for _, opt := range opts {
  48773. opt(m)
  48774. }
  48775. return m
  48776. }
  48777. // withXunjiServiceID sets the ID field of the mutation.
  48778. func withXunjiServiceID(id uint64) xunjiserviceOption {
  48779. return func(m *XunjiServiceMutation) {
  48780. var (
  48781. err error
  48782. once sync.Once
  48783. value *XunjiService
  48784. )
  48785. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  48786. once.Do(func() {
  48787. if m.done {
  48788. err = errors.New("querying old values post mutation is not allowed")
  48789. } else {
  48790. value, err = m.Client().XunjiService.Get(ctx, id)
  48791. }
  48792. })
  48793. return value, err
  48794. }
  48795. m.id = &id
  48796. }
  48797. }
  48798. // withXunjiService sets the old XunjiService of the mutation.
  48799. func withXunjiService(node *XunjiService) xunjiserviceOption {
  48800. return func(m *XunjiServiceMutation) {
  48801. m.oldValue = func(context.Context) (*XunjiService, error) {
  48802. return node, nil
  48803. }
  48804. m.id = &node.ID
  48805. }
  48806. }
  48807. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48808. // executed in a transaction (ent.Tx), a transactional client is returned.
  48809. func (m XunjiServiceMutation) Client() *Client {
  48810. client := &Client{config: m.config}
  48811. client.init()
  48812. return client
  48813. }
  48814. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48815. // it returns an error otherwise.
  48816. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  48817. if _, ok := m.driver.(*txDriver); !ok {
  48818. return nil, errors.New("ent: mutation is not running in a transaction")
  48819. }
  48820. tx := &Tx{config: m.config}
  48821. tx.init()
  48822. return tx, nil
  48823. }
  48824. // SetID sets the value of the id field. Note that this
  48825. // operation is only accepted on creation of XunjiService entities.
  48826. func (m *XunjiServiceMutation) SetID(id uint64) {
  48827. m.id = &id
  48828. }
  48829. // ID returns the ID value in the mutation. Note that the ID is only available
  48830. // if it was provided to the builder or after it was returned from the database.
  48831. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  48832. if m.id == nil {
  48833. return
  48834. }
  48835. return *m.id, true
  48836. }
  48837. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48838. // That means, if the mutation is applied within a transaction with an isolation level such
  48839. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48840. // or updated by the mutation.
  48841. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  48842. switch {
  48843. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48844. id, exists := m.ID()
  48845. if exists {
  48846. return []uint64{id}, nil
  48847. }
  48848. fallthrough
  48849. case m.op.Is(OpUpdate | OpDelete):
  48850. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  48851. default:
  48852. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48853. }
  48854. }
  48855. // SetCreatedAt sets the "created_at" field.
  48856. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  48857. m.created_at = &t
  48858. }
  48859. // CreatedAt returns the value of the "created_at" field in the mutation.
  48860. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  48861. v := m.created_at
  48862. if v == nil {
  48863. return
  48864. }
  48865. return *v, true
  48866. }
  48867. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  48868. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48870. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48871. if !m.op.Is(OpUpdateOne) {
  48872. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48873. }
  48874. if m.id == nil || m.oldValue == nil {
  48875. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48876. }
  48877. oldValue, err := m.oldValue(ctx)
  48878. if err != nil {
  48879. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48880. }
  48881. return oldValue.CreatedAt, nil
  48882. }
  48883. // ResetCreatedAt resets all changes to the "created_at" field.
  48884. func (m *XunjiServiceMutation) ResetCreatedAt() {
  48885. m.created_at = nil
  48886. }
  48887. // SetUpdatedAt sets the "updated_at" field.
  48888. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  48889. m.updated_at = &t
  48890. }
  48891. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48892. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  48893. v := m.updated_at
  48894. if v == nil {
  48895. return
  48896. }
  48897. return *v, true
  48898. }
  48899. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  48900. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48902. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48903. if !m.op.Is(OpUpdateOne) {
  48904. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48905. }
  48906. if m.id == nil || m.oldValue == nil {
  48907. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48908. }
  48909. oldValue, err := m.oldValue(ctx)
  48910. if err != nil {
  48911. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48912. }
  48913. return oldValue.UpdatedAt, nil
  48914. }
  48915. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48916. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  48917. m.updated_at = nil
  48918. }
  48919. // SetStatus sets the "status" field.
  48920. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  48921. m.status = &u
  48922. m.addstatus = nil
  48923. }
  48924. // Status returns the value of the "status" field in the mutation.
  48925. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  48926. v := m.status
  48927. if v == nil {
  48928. return
  48929. }
  48930. return *v, true
  48931. }
  48932. // OldStatus returns the old "status" field's value of the XunjiService entity.
  48933. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48935. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  48936. if !m.op.Is(OpUpdateOne) {
  48937. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  48938. }
  48939. if m.id == nil || m.oldValue == nil {
  48940. return v, errors.New("OldStatus requires an ID field in the mutation")
  48941. }
  48942. oldValue, err := m.oldValue(ctx)
  48943. if err != nil {
  48944. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  48945. }
  48946. return oldValue.Status, nil
  48947. }
  48948. // AddStatus adds u to the "status" field.
  48949. func (m *XunjiServiceMutation) AddStatus(u int8) {
  48950. if m.addstatus != nil {
  48951. *m.addstatus += u
  48952. } else {
  48953. m.addstatus = &u
  48954. }
  48955. }
  48956. // AddedStatus returns the value that was added to the "status" field in this mutation.
  48957. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  48958. v := m.addstatus
  48959. if v == nil {
  48960. return
  48961. }
  48962. return *v, true
  48963. }
  48964. // ClearStatus clears the value of the "status" field.
  48965. func (m *XunjiServiceMutation) ClearStatus() {
  48966. m.status = nil
  48967. m.addstatus = nil
  48968. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  48969. }
  48970. // StatusCleared returns if the "status" field was cleared in this mutation.
  48971. func (m *XunjiServiceMutation) StatusCleared() bool {
  48972. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  48973. return ok
  48974. }
  48975. // ResetStatus resets all changes to the "status" field.
  48976. func (m *XunjiServiceMutation) ResetStatus() {
  48977. m.status = nil
  48978. m.addstatus = nil
  48979. delete(m.clearedFields, xunjiservice.FieldStatus)
  48980. }
  48981. // SetDeletedAt sets the "deleted_at" field.
  48982. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  48983. m.deleted_at = &t
  48984. }
  48985. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48986. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  48987. v := m.deleted_at
  48988. if v == nil {
  48989. return
  48990. }
  48991. return *v, true
  48992. }
  48993. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  48994. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48996. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48997. if !m.op.Is(OpUpdateOne) {
  48998. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48999. }
  49000. if m.id == nil || m.oldValue == nil {
  49001. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49002. }
  49003. oldValue, err := m.oldValue(ctx)
  49004. if err != nil {
  49005. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49006. }
  49007. return oldValue.DeletedAt, nil
  49008. }
  49009. // ClearDeletedAt clears the value of the "deleted_at" field.
  49010. func (m *XunjiServiceMutation) ClearDeletedAt() {
  49011. m.deleted_at = nil
  49012. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  49013. }
  49014. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49015. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  49016. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  49017. return ok
  49018. }
  49019. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49020. func (m *XunjiServiceMutation) ResetDeletedAt() {
  49021. m.deleted_at = nil
  49022. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  49023. }
  49024. // SetXunjiID sets the "xunji_id" field.
  49025. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  49026. m.xunji_id = &u
  49027. m.addxunji_id = nil
  49028. }
  49029. // XunjiID returns the value of the "xunji_id" field in the mutation.
  49030. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  49031. v := m.xunji_id
  49032. if v == nil {
  49033. return
  49034. }
  49035. return *v, true
  49036. }
  49037. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  49038. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49040. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  49041. if !m.op.Is(OpUpdateOne) {
  49042. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  49043. }
  49044. if m.id == nil || m.oldValue == nil {
  49045. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  49046. }
  49047. oldValue, err := m.oldValue(ctx)
  49048. if err != nil {
  49049. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  49050. }
  49051. return oldValue.XunjiID, nil
  49052. }
  49053. // AddXunjiID adds u to the "xunji_id" field.
  49054. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  49055. if m.addxunji_id != nil {
  49056. *m.addxunji_id += u
  49057. } else {
  49058. m.addxunji_id = &u
  49059. }
  49060. }
  49061. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  49062. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  49063. v := m.addxunji_id
  49064. if v == nil {
  49065. return
  49066. }
  49067. return *v, true
  49068. }
  49069. // ResetXunjiID resets all changes to the "xunji_id" field.
  49070. func (m *XunjiServiceMutation) ResetXunjiID() {
  49071. m.xunji_id = nil
  49072. m.addxunji_id = nil
  49073. }
  49074. // SetAgentID sets the "agent_id" field.
  49075. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  49076. m.agent = &u
  49077. }
  49078. // AgentID returns the value of the "agent_id" field in the mutation.
  49079. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  49080. v := m.agent
  49081. if v == nil {
  49082. return
  49083. }
  49084. return *v, true
  49085. }
  49086. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  49087. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49089. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  49090. if !m.op.Is(OpUpdateOne) {
  49091. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  49092. }
  49093. if m.id == nil || m.oldValue == nil {
  49094. return v, errors.New("OldAgentID requires an ID field in the mutation")
  49095. }
  49096. oldValue, err := m.oldValue(ctx)
  49097. if err != nil {
  49098. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  49099. }
  49100. return oldValue.AgentID, nil
  49101. }
  49102. // ResetAgentID resets all changes to the "agent_id" field.
  49103. func (m *XunjiServiceMutation) ResetAgentID() {
  49104. m.agent = nil
  49105. }
  49106. // SetOrganizationID sets the "organization_id" field.
  49107. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  49108. m.organization_id = &u
  49109. m.addorganization_id = nil
  49110. }
  49111. // OrganizationID returns the value of the "organization_id" field in the mutation.
  49112. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  49113. v := m.organization_id
  49114. if v == nil {
  49115. return
  49116. }
  49117. return *v, true
  49118. }
  49119. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  49120. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49122. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  49123. if !m.op.Is(OpUpdateOne) {
  49124. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  49125. }
  49126. if m.id == nil || m.oldValue == nil {
  49127. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  49128. }
  49129. oldValue, err := m.oldValue(ctx)
  49130. if err != nil {
  49131. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  49132. }
  49133. return oldValue.OrganizationID, nil
  49134. }
  49135. // AddOrganizationID adds u to the "organization_id" field.
  49136. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  49137. if m.addorganization_id != nil {
  49138. *m.addorganization_id += u
  49139. } else {
  49140. m.addorganization_id = &u
  49141. }
  49142. }
  49143. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  49144. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  49145. v := m.addorganization_id
  49146. if v == nil {
  49147. return
  49148. }
  49149. return *v, true
  49150. }
  49151. // ResetOrganizationID resets all changes to the "organization_id" field.
  49152. func (m *XunjiServiceMutation) ResetOrganizationID() {
  49153. m.organization_id = nil
  49154. m.addorganization_id = nil
  49155. }
  49156. // SetWxid sets the "wxid" field.
  49157. func (m *XunjiServiceMutation) SetWxid(s string) {
  49158. m.wxid = &s
  49159. }
  49160. // Wxid returns the value of the "wxid" field in the mutation.
  49161. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  49162. v := m.wxid
  49163. if v == nil {
  49164. return
  49165. }
  49166. return *v, true
  49167. }
  49168. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  49169. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49171. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  49172. if !m.op.Is(OpUpdateOne) {
  49173. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  49174. }
  49175. if m.id == nil || m.oldValue == nil {
  49176. return v, errors.New("OldWxid requires an ID field in the mutation")
  49177. }
  49178. oldValue, err := m.oldValue(ctx)
  49179. if err != nil {
  49180. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  49181. }
  49182. return oldValue.Wxid, nil
  49183. }
  49184. // ResetWxid resets all changes to the "wxid" field.
  49185. func (m *XunjiServiceMutation) ResetWxid() {
  49186. m.wxid = nil
  49187. }
  49188. // SetAPIBase sets the "api_base" field.
  49189. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  49190. m.api_base = &s
  49191. }
  49192. // APIBase returns the value of the "api_base" field in the mutation.
  49193. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  49194. v := m.api_base
  49195. if v == nil {
  49196. return
  49197. }
  49198. return *v, true
  49199. }
  49200. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  49201. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49203. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49204. if !m.op.Is(OpUpdateOne) {
  49205. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49206. }
  49207. if m.id == nil || m.oldValue == nil {
  49208. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49209. }
  49210. oldValue, err := m.oldValue(ctx)
  49211. if err != nil {
  49212. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49213. }
  49214. return oldValue.APIBase, nil
  49215. }
  49216. // ClearAPIBase clears the value of the "api_base" field.
  49217. func (m *XunjiServiceMutation) ClearAPIBase() {
  49218. m.api_base = nil
  49219. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  49220. }
  49221. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49222. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  49223. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  49224. return ok
  49225. }
  49226. // ResetAPIBase resets all changes to the "api_base" field.
  49227. func (m *XunjiServiceMutation) ResetAPIBase() {
  49228. m.api_base = nil
  49229. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  49230. }
  49231. // SetAPIKey sets the "api_key" field.
  49232. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  49233. m.api_key = &s
  49234. }
  49235. // APIKey returns the value of the "api_key" field in the mutation.
  49236. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  49237. v := m.api_key
  49238. if v == nil {
  49239. return
  49240. }
  49241. return *v, true
  49242. }
  49243. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  49244. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49246. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49247. if !m.op.Is(OpUpdateOne) {
  49248. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49249. }
  49250. if m.id == nil || m.oldValue == nil {
  49251. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49252. }
  49253. oldValue, err := m.oldValue(ctx)
  49254. if err != nil {
  49255. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49256. }
  49257. return oldValue.APIKey, nil
  49258. }
  49259. // ClearAPIKey clears the value of the "api_key" field.
  49260. func (m *XunjiServiceMutation) ClearAPIKey() {
  49261. m.api_key = nil
  49262. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  49263. }
  49264. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49265. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  49266. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  49267. return ok
  49268. }
  49269. // ResetAPIKey resets all changes to the "api_key" field.
  49270. func (m *XunjiServiceMutation) ResetAPIKey() {
  49271. m.api_key = nil
  49272. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  49273. }
  49274. // ClearAgent clears the "agent" edge to the Agent entity.
  49275. func (m *XunjiServiceMutation) ClearAgent() {
  49276. m.clearedagent = true
  49277. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  49278. }
  49279. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  49280. func (m *XunjiServiceMutation) AgentCleared() bool {
  49281. return m.clearedagent
  49282. }
  49283. // AgentIDs returns the "agent" edge IDs in the mutation.
  49284. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  49285. // AgentID instead. It exists only for internal usage by the builders.
  49286. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  49287. if id := m.agent; id != nil {
  49288. ids = append(ids, *id)
  49289. }
  49290. return
  49291. }
  49292. // ResetAgent resets all changes to the "agent" edge.
  49293. func (m *XunjiServiceMutation) ResetAgent() {
  49294. m.agent = nil
  49295. m.clearedagent = false
  49296. }
  49297. // Where appends a list predicates to the XunjiServiceMutation builder.
  49298. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  49299. m.predicates = append(m.predicates, ps...)
  49300. }
  49301. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  49302. // users can use type-assertion to append predicates that do not depend on any generated package.
  49303. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  49304. p := make([]predicate.XunjiService, len(ps))
  49305. for i := range ps {
  49306. p[i] = ps[i]
  49307. }
  49308. m.Where(p...)
  49309. }
  49310. // Op returns the operation name.
  49311. func (m *XunjiServiceMutation) Op() Op {
  49312. return m.op
  49313. }
  49314. // SetOp allows setting the mutation operation.
  49315. func (m *XunjiServiceMutation) SetOp(op Op) {
  49316. m.op = op
  49317. }
  49318. // Type returns the node type of this mutation (XunjiService).
  49319. func (m *XunjiServiceMutation) Type() string {
  49320. return m.typ
  49321. }
  49322. // Fields returns all fields that were changed during this mutation. Note that in
  49323. // order to get all numeric fields that were incremented/decremented, call
  49324. // AddedFields().
  49325. func (m *XunjiServiceMutation) Fields() []string {
  49326. fields := make([]string, 0, 10)
  49327. if m.created_at != nil {
  49328. fields = append(fields, xunjiservice.FieldCreatedAt)
  49329. }
  49330. if m.updated_at != nil {
  49331. fields = append(fields, xunjiservice.FieldUpdatedAt)
  49332. }
  49333. if m.status != nil {
  49334. fields = append(fields, xunjiservice.FieldStatus)
  49335. }
  49336. if m.deleted_at != nil {
  49337. fields = append(fields, xunjiservice.FieldDeletedAt)
  49338. }
  49339. if m.xunji_id != nil {
  49340. fields = append(fields, xunjiservice.FieldXunjiID)
  49341. }
  49342. if m.agent != nil {
  49343. fields = append(fields, xunjiservice.FieldAgentID)
  49344. }
  49345. if m.organization_id != nil {
  49346. fields = append(fields, xunjiservice.FieldOrganizationID)
  49347. }
  49348. if m.wxid != nil {
  49349. fields = append(fields, xunjiservice.FieldWxid)
  49350. }
  49351. if m.api_base != nil {
  49352. fields = append(fields, xunjiservice.FieldAPIBase)
  49353. }
  49354. if m.api_key != nil {
  49355. fields = append(fields, xunjiservice.FieldAPIKey)
  49356. }
  49357. return fields
  49358. }
  49359. // Field returns the value of a field with the given name. The second boolean
  49360. // return value indicates that this field was not set, or was not defined in the
  49361. // schema.
  49362. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  49363. switch name {
  49364. case xunjiservice.FieldCreatedAt:
  49365. return m.CreatedAt()
  49366. case xunjiservice.FieldUpdatedAt:
  49367. return m.UpdatedAt()
  49368. case xunjiservice.FieldStatus:
  49369. return m.Status()
  49370. case xunjiservice.FieldDeletedAt:
  49371. return m.DeletedAt()
  49372. case xunjiservice.FieldXunjiID:
  49373. return m.XunjiID()
  49374. case xunjiservice.FieldAgentID:
  49375. return m.AgentID()
  49376. case xunjiservice.FieldOrganizationID:
  49377. return m.OrganizationID()
  49378. case xunjiservice.FieldWxid:
  49379. return m.Wxid()
  49380. case xunjiservice.FieldAPIBase:
  49381. return m.APIBase()
  49382. case xunjiservice.FieldAPIKey:
  49383. return m.APIKey()
  49384. }
  49385. return nil, false
  49386. }
  49387. // OldField returns the old value of the field from the database. An error is
  49388. // returned if the mutation operation is not UpdateOne, or the query to the
  49389. // database failed.
  49390. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49391. switch name {
  49392. case xunjiservice.FieldCreatedAt:
  49393. return m.OldCreatedAt(ctx)
  49394. case xunjiservice.FieldUpdatedAt:
  49395. return m.OldUpdatedAt(ctx)
  49396. case xunjiservice.FieldStatus:
  49397. return m.OldStatus(ctx)
  49398. case xunjiservice.FieldDeletedAt:
  49399. return m.OldDeletedAt(ctx)
  49400. case xunjiservice.FieldXunjiID:
  49401. return m.OldXunjiID(ctx)
  49402. case xunjiservice.FieldAgentID:
  49403. return m.OldAgentID(ctx)
  49404. case xunjiservice.FieldOrganizationID:
  49405. return m.OldOrganizationID(ctx)
  49406. case xunjiservice.FieldWxid:
  49407. return m.OldWxid(ctx)
  49408. case xunjiservice.FieldAPIBase:
  49409. return m.OldAPIBase(ctx)
  49410. case xunjiservice.FieldAPIKey:
  49411. return m.OldAPIKey(ctx)
  49412. }
  49413. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  49414. }
  49415. // SetField sets the value of a field with the given name. It returns an error if
  49416. // the field is not defined in the schema, or if the type mismatched the field
  49417. // type.
  49418. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  49419. switch name {
  49420. case xunjiservice.FieldCreatedAt:
  49421. v, ok := value.(time.Time)
  49422. if !ok {
  49423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49424. }
  49425. m.SetCreatedAt(v)
  49426. return nil
  49427. case xunjiservice.FieldUpdatedAt:
  49428. v, ok := value.(time.Time)
  49429. if !ok {
  49430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49431. }
  49432. m.SetUpdatedAt(v)
  49433. return nil
  49434. case xunjiservice.FieldStatus:
  49435. v, ok := value.(uint8)
  49436. if !ok {
  49437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49438. }
  49439. m.SetStatus(v)
  49440. return nil
  49441. case xunjiservice.FieldDeletedAt:
  49442. v, ok := value.(time.Time)
  49443. if !ok {
  49444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49445. }
  49446. m.SetDeletedAt(v)
  49447. return nil
  49448. case xunjiservice.FieldXunjiID:
  49449. v, ok := value.(uint64)
  49450. if !ok {
  49451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49452. }
  49453. m.SetXunjiID(v)
  49454. return nil
  49455. case xunjiservice.FieldAgentID:
  49456. v, ok := value.(uint64)
  49457. if !ok {
  49458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49459. }
  49460. m.SetAgentID(v)
  49461. return nil
  49462. case xunjiservice.FieldOrganizationID:
  49463. v, ok := value.(uint64)
  49464. if !ok {
  49465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49466. }
  49467. m.SetOrganizationID(v)
  49468. return nil
  49469. case xunjiservice.FieldWxid:
  49470. v, ok := value.(string)
  49471. if !ok {
  49472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49473. }
  49474. m.SetWxid(v)
  49475. return nil
  49476. case xunjiservice.FieldAPIBase:
  49477. v, ok := value.(string)
  49478. if !ok {
  49479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49480. }
  49481. m.SetAPIBase(v)
  49482. return nil
  49483. case xunjiservice.FieldAPIKey:
  49484. v, ok := value.(string)
  49485. if !ok {
  49486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49487. }
  49488. m.SetAPIKey(v)
  49489. return nil
  49490. }
  49491. return fmt.Errorf("unknown XunjiService field %s", name)
  49492. }
  49493. // AddedFields returns all numeric fields that were incremented/decremented during
  49494. // this mutation.
  49495. func (m *XunjiServiceMutation) AddedFields() []string {
  49496. var fields []string
  49497. if m.addstatus != nil {
  49498. fields = append(fields, xunjiservice.FieldStatus)
  49499. }
  49500. if m.addxunji_id != nil {
  49501. fields = append(fields, xunjiservice.FieldXunjiID)
  49502. }
  49503. if m.addorganization_id != nil {
  49504. fields = append(fields, xunjiservice.FieldOrganizationID)
  49505. }
  49506. return fields
  49507. }
  49508. // AddedField returns the numeric value that was incremented/decremented on a field
  49509. // with the given name. The second boolean return value indicates that this field
  49510. // was not set, or was not defined in the schema.
  49511. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  49512. switch name {
  49513. case xunjiservice.FieldStatus:
  49514. return m.AddedStatus()
  49515. case xunjiservice.FieldXunjiID:
  49516. return m.AddedXunjiID()
  49517. case xunjiservice.FieldOrganizationID:
  49518. return m.AddedOrganizationID()
  49519. }
  49520. return nil, false
  49521. }
  49522. // AddField adds the value to the field with the given name. It returns an error if
  49523. // the field is not defined in the schema, or if the type mismatched the field
  49524. // type.
  49525. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  49526. switch name {
  49527. case xunjiservice.FieldStatus:
  49528. v, ok := value.(int8)
  49529. if !ok {
  49530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49531. }
  49532. m.AddStatus(v)
  49533. return nil
  49534. case xunjiservice.FieldXunjiID:
  49535. v, ok := value.(int64)
  49536. if !ok {
  49537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49538. }
  49539. m.AddXunjiID(v)
  49540. return nil
  49541. case xunjiservice.FieldOrganizationID:
  49542. v, ok := value.(int64)
  49543. if !ok {
  49544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49545. }
  49546. m.AddOrganizationID(v)
  49547. return nil
  49548. }
  49549. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  49550. }
  49551. // ClearedFields returns all nullable fields that were cleared during this
  49552. // mutation.
  49553. func (m *XunjiServiceMutation) ClearedFields() []string {
  49554. var fields []string
  49555. if m.FieldCleared(xunjiservice.FieldStatus) {
  49556. fields = append(fields, xunjiservice.FieldStatus)
  49557. }
  49558. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  49559. fields = append(fields, xunjiservice.FieldDeletedAt)
  49560. }
  49561. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  49562. fields = append(fields, xunjiservice.FieldAPIBase)
  49563. }
  49564. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  49565. fields = append(fields, xunjiservice.FieldAPIKey)
  49566. }
  49567. return fields
  49568. }
  49569. // FieldCleared returns a boolean indicating if a field with the given name was
  49570. // cleared in this mutation.
  49571. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  49572. _, ok := m.clearedFields[name]
  49573. return ok
  49574. }
  49575. // ClearField clears the value of the field with the given name. It returns an
  49576. // error if the field is not defined in the schema.
  49577. func (m *XunjiServiceMutation) ClearField(name string) error {
  49578. switch name {
  49579. case xunjiservice.FieldStatus:
  49580. m.ClearStatus()
  49581. return nil
  49582. case xunjiservice.FieldDeletedAt:
  49583. m.ClearDeletedAt()
  49584. return nil
  49585. case xunjiservice.FieldAPIBase:
  49586. m.ClearAPIBase()
  49587. return nil
  49588. case xunjiservice.FieldAPIKey:
  49589. m.ClearAPIKey()
  49590. return nil
  49591. }
  49592. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  49593. }
  49594. // ResetField resets all changes in the mutation for the field with the given name.
  49595. // It returns an error if the field is not defined in the schema.
  49596. func (m *XunjiServiceMutation) ResetField(name string) error {
  49597. switch name {
  49598. case xunjiservice.FieldCreatedAt:
  49599. m.ResetCreatedAt()
  49600. return nil
  49601. case xunjiservice.FieldUpdatedAt:
  49602. m.ResetUpdatedAt()
  49603. return nil
  49604. case xunjiservice.FieldStatus:
  49605. m.ResetStatus()
  49606. return nil
  49607. case xunjiservice.FieldDeletedAt:
  49608. m.ResetDeletedAt()
  49609. return nil
  49610. case xunjiservice.FieldXunjiID:
  49611. m.ResetXunjiID()
  49612. return nil
  49613. case xunjiservice.FieldAgentID:
  49614. m.ResetAgentID()
  49615. return nil
  49616. case xunjiservice.FieldOrganizationID:
  49617. m.ResetOrganizationID()
  49618. return nil
  49619. case xunjiservice.FieldWxid:
  49620. m.ResetWxid()
  49621. return nil
  49622. case xunjiservice.FieldAPIBase:
  49623. m.ResetAPIBase()
  49624. return nil
  49625. case xunjiservice.FieldAPIKey:
  49626. m.ResetAPIKey()
  49627. return nil
  49628. }
  49629. return fmt.Errorf("unknown XunjiService field %s", name)
  49630. }
  49631. // AddedEdges returns all edge names that were set/added in this mutation.
  49632. func (m *XunjiServiceMutation) AddedEdges() []string {
  49633. edges := make([]string, 0, 1)
  49634. if m.agent != nil {
  49635. edges = append(edges, xunjiservice.EdgeAgent)
  49636. }
  49637. return edges
  49638. }
  49639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49640. // name in this mutation.
  49641. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  49642. switch name {
  49643. case xunjiservice.EdgeAgent:
  49644. if id := m.agent; id != nil {
  49645. return []ent.Value{*id}
  49646. }
  49647. }
  49648. return nil
  49649. }
  49650. // RemovedEdges returns all edge names that were removed in this mutation.
  49651. func (m *XunjiServiceMutation) RemovedEdges() []string {
  49652. edges := make([]string, 0, 1)
  49653. return edges
  49654. }
  49655. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49656. // the given name in this mutation.
  49657. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  49658. return nil
  49659. }
  49660. // ClearedEdges returns all edge names that were cleared in this mutation.
  49661. func (m *XunjiServiceMutation) ClearedEdges() []string {
  49662. edges := make([]string, 0, 1)
  49663. if m.clearedagent {
  49664. edges = append(edges, xunjiservice.EdgeAgent)
  49665. }
  49666. return edges
  49667. }
  49668. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49669. // was cleared in this mutation.
  49670. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  49671. switch name {
  49672. case xunjiservice.EdgeAgent:
  49673. return m.clearedagent
  49674. }
  49675. return false
  49676. }
  49677. // ClearEdge clears the value of the edge with the given name. It returns an error
  49678. // if that edge is not defined in the schema.
  49679. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  49680. switch name {
  49681. case xunjiservice.EdgeAgent:
  49682. m.ClearAgent()
  49683. return nil
  49684. }
  49685. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  49686. }
  49687. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49688. // It returns an error if the edge is not defined in the schema.
  49689. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  49690. switch name {
  49691. case xunjiservice.EdgeAgent:
  49692. m.ResetAgent()
  49693. return nil
  49694. }
  49695. return fmt.Errorf("unknown XunjiService edge %s", name)
  49696. }