mutation.go 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490
  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/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "entgo.io/ent"
  52. "entgo.io/ent/dialect/sql"
  53. )
  54. const (
  55. // Operation types.
  56. OpCreate = ent.OpCreate
  57. OpDelete = ent.OpDelete
  58. OpDeleteOne = ent.OpDeleteOne
  59. OpUpdate = ent.OpUpdate
  60. OpUpdateOne = ent.OpUpdateOne
  61. // Node types.
  62. TypeAgent = "Agent"
  63. TypeAgentBase = "AgentBase"
  64. TypeAliyunAvatar = "AliyunAvatar"
  65. TypeAllocAgent = "AllocAgent"
  66. TypeBatchMsg = "BatchMsg"
  67. TypeCategory = "Category"
  68. TypeChatRecords = "ChatRecords"
  69. TypeChatSession = "ChatSession"
  70. TypeContact = "Contact"
  71. TypeCreditBalance = "CreditBalance"
  72. TypeCreditUsage = "CreditUsage"
  73. TypeEmployee = "Employee"
  74. TypeEmployeeConfig = "EmployeeConfig"
  75. TypeLabel = "Label"
  76. TypeLabelRelationship = "LabelRelationship"
  77. TypeLabelTagging = "LabelTagging"
  78. TypeMessage = "Message"
  79. TypeMessageRecords = "MessageRecords"
  80. TypeMsg = "Msg"
  81. TypePayRecharge = "PayRecharge"
  82. TypeServer = "Server"
  83. TypeSopNode = "SopNode"
  84. TypeSopStage = "SopStage"
  85. TypeSopTask = "SopTask"
  86. TypeToken = "Token"
  87. TypeTutorial = "Tutorial"
  88. TypeUsageDetail = "UsageDetail"
  89. TypeUsageStatisticDay = "UsageStatisticDay"
  90. TypeUsageStatisticHour = "UsageStatisticHour"
  91. TypeUsageStatisticMonth = "UsageStatisticMonth"
  92. TypeUsageTotal = "UsageTotal"
  93. TypeWhatsapp = "Whatsapp"
  94. TypeWhatsappChannel = "WhatsappChannel"
  95. TypeWorkExperience = "WorkExperience"
  96. TypeWpChatroom = "WpChatroom"
  97. TypeWpChatroomMember = "WpChatroomMember"
  98. TypeWx = "Wx"
  99. TypeWxCard = "WxCard"
  100. TypeWxCardUser = "WxCardUser"
  101. TypeWxCardVisit = "WxCardVisit"
  102. )
  103. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  104. type AgentMutation struct {
  105. config
  106. op Op
  107. typ string
  108. id *uint64
  109. created_at *time.Time
  110. updated_at *time.Time
  111. deleted_at *time.Time
  112. name *string
  113. role *string
  114. status *int
  115. addstatus *int
  116. background *string
  117. examples *string
  118. organization_id *uint64
  119. addorganization_id *int64
  120. dataset_id *string
  121. collection_id *string
  122. clearedFields map[string]struct{}
  123. wx_agent map[uint64]struct{}
  124. removedwx_agent map[uint64]struct{}
  125. clearedwx_agent bool
  126. token_agent map[uint64]struct{}
  127. removedtoken_agent map[uint64]struct{}
  128. clearedtoken_agent bool
  129. wa_agent map[uint64]struct{}
  130. removedwa_agent map[uint64]struct{}
  131. clearedwa_agent bool
  132. done bool
  133. oldValue func(context.Context) (*Agent, error)
  134. predicates []predicate.Agent
  135. }
  136. var _ ent.Mutation = (*AgentMutation)(nil)
  137. // agentOption allows management of the mutation configuration using functional options.
  138. type agentOption func(*AgentMutation)
  139. // newAgentMutation creates new mutation for the Agent entity.
  140. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  141. m := &AgentMutation{
  142. config: c,
  143. op: op,
  144. typ: TypeAgent,
  145. clearedFields: make(map[string]struct{}),
  146. }
  147. for _, opt := range opts {
  148. opt(m)
  149. }
  150. return m
  151. }
  152. // withAgentID sets the ID field of the mutation.
  153. func withAgentID(id uint64) agentOption {
  154. return func(m *AgentMutation) {
  155. var (
  156. err error
  157. once sync.Once
  158. value *Agent
  159. )
  160. m.oldValue = func(ctx context.Context) (*Agent, error) {
  161. once.Do(func() {
  162. if m.done {
  163. err = errors.New("querying old values post mutation is not allowed")
  164. } else {
  165. value, err = m.Client().Agent.Get(ctx, id)
  166. }
  167. })
  168. return value, err
  169. }
  170. m.id = &id
  171. }
  172. }
  173. // withAgent sets the old Agent of the mutation.
  174. func withAgent(node *Agent) agentOption {
  175. return func(m *AgentMutation) {
  176. m.oldValue = func(context.Context) (*Agent, error) {
  177. return node, nil
  178. }
  179. m.id = &node.ID
  180. }
  181. }
  182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  183. // executed in a transaction (ent.Tx), a transactional client is returned.
  184. func (m AgentMutation) Client() *Client {
  185. client := &Client{config: m.config}
  186. client.init()
  187. return client
  188. }
  189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  190. // it returns an error otherwise.
  191. func (m AgentMutation) Tx() (*Tx, error) {
  192. if _, ok := m.driver.(*txDriver); !ok {
  193. return nil, errors.New("ent: mutation is not running in a transaction")
  194. }
  195. tx := &Tx{config: m.config}
  196. tx.init()
  197. return tx, nil
  198. }
  199. // SetID sets the value of the id field. Note that this
  200. // operation is only accepted on creation of Agent entities.
  201. func (m *AgentMutation) SetID(id uint64) {
  202. m.id = &id
  203. }
  204. // ID returns the ID value in the mutation. Note that the ID is only available
  205. // if it was provided to the builder or after it was returned from the database.
  206. func (m *AgentMutation) ID() (id uint64, exists bool) {
  207. if m.id == nil {
  208. return
  209. }
  210. return *m.id, true
  211. }
  212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  213. // That means, if the mutation is applied within a transaction with an isolation level such
  214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  215. // or updated by the mutation.
  216. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  217. switch {
  218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  219. id, exists := m.ID()
  220. if exists {
  221. return []uint64{id}, nil
  222. }
  223. fallthrough
  224. case m.op.Is(OpUpdate | OpDelete):
  225. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  226. default:
  227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  228. }
  229. }
  230. // SetCreatedAt sets the "created_at" field.
  231. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  232. m.created_at = &t
  233. }
  234. // CreatedAt returns the value of the "created_at" field in the mutation.
  235. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  236. v := m.created_at
  237. if v == nil {
  238. return
  239. }
  240. return *v, true
  241. }
  242. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  243. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  245. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  246. if !m.op.Is(OpUpdateOne) {
  247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  248. }
  249. if m.id == nil || m.oldValue == nil {
  250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  251. }
  252. oldValue, err := m.oldValue(ctx)
  253. if err != nil {
  254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  255. }
  256. return oldValue.CreatedAt, nil
  257. }
  258. // ResetCreatedAt resets all changes to the "created_at" field.
  259. func (m *AgentMutation) ResetCreatedAt() {
  260. m.created_at = nil
  261. }
  262. // SetUpdatedAt sets the "updated_at" field.
  263. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  264. m.updated_at = &t
  265. }
  266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  267. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  268. v := m.updated_at
  269. if v == nil {
  270. return
  271. }
  272. return *v, true
  273. }
  274. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  275. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  277. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  278. if !m.op.Is(OpUpdateOne) {
  279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  280. }
  281. if m.id == nil || m.oldValue == nil {
  282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  283. }
  284. oldValue, err := m.oldValue(ctx)
  285. if err != nil {
  286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  287. }
  288. return oldValue.UpdatedAt, nil
  289. }
  290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  291. func (m *AgentMutation) ResetUpdatedAt() {
  292. m.updated_at = nil
  293. }
  294. // SetDeletedAt sets the "deleted_at" field.
  295. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  296. m.deleted_at = &t
  297. }
  298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  299. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  300. v := m.deleted_at
  301. if v == nil {
  302. return
  303. }
  304. return *v, true
  305. }
  306. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  307. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  309. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  310. if !m.op.Is(OpUpdateOne) {
  311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  312. }
  313. if m.id == nil || m.oldValue == nil {
  314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  315. }
  316. oldValue, err := m.oldValue(ctx)
  317. if err != nil {
  318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  319. }
  320. return oldValue.DeletedAt, nil
  321. }
  322. // ClearDeletedAt clears the value of the "deleted_at" field.
  323. func (m *AgentMutation) ClearDeletedAt() {
  324. m.deleted_at = nil
  325. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  326. }
  327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  328. func (m *AgentMutation) DeletedAtCleared() bool {
  329. _, ok := m.clearedFields[agent.FieldDeletedAt]
  330. return ok
  331. }
  332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  333. func (m *AgentMutation) ResetDeletedAt() {
  334. m.deleted_at = nil
  335. delete(m.clearedFields, agent.FieldDeletedAt)
  336. }
  337. // SetName sets the "name" field.
  338. func (m *AgentMutation) SetName(s string) {
  339. m.name = &s
  340. }
  341. // Name returns the value of the "name" field in the mutation.
  342. func (m *AgentMutation) Name() (r string, exists bool) {
  343. v := m.name
  344. if v == nil {
  345. return
  346. }
  347. return *v, true
  348. }
  349. // OldName returns the old "name" field's value of the Agent entity.
  350. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  352. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  353. if !m.op.Is(OpUpdateOne) {
  354. return v, errors.New("OldName is only allowed on UpdateOne operations")
  355. }
  356. if m.id == nil || m.oldValue == nil {
  357. return v, errors.New("OldName requires an ID field in the mutation")
  358. }
  359. oldValue, err := m.oldValue(ctx)
  360. if err != nil {
  361. return v, fmt.Errorf("querying old value for OldName: %w", err)
  362. }
  363. return oldValue.Name, nil
  364. }
  365. // ResetName resets all changes to the "name" field.
  366. func (m *AgentMutation) ResetName() {
  367. m.name = nil
  368. }
  369. // SetRole sets the "role" field.
  370. func (m *AgentMutation) SetRole(s string) {
  371. m.role = &s
  372. }
  373. // Role returns the value of the "role" field in the mutation.
  374. func (m *AgentMutation) Role() (r string, exists bool) {
  375. v := m.role
  376. if v == nil {
  377. return
  378. }
  379. return *v, true
  380. }
  381. // OldRole returns the old "role" field's value of the Agent entity.
  382. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  384. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  385. if !m.op.Is(OpUpdateOne) {
  386. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  387. }
  388. if m.id == nil || m.oldValue == nil {
  389. return v, errors.New("OldRole requires an ID field in the mutation")
  390. }
  391. oldValue, err := m.oldValue(ctx)
  392. if err != nil {
  393. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  394. }
  395. return oldValue.Role, nil
  396. }
  397. // ResetRole resets all changes to the "role" field.
  398. func (m *AgentMutation) ResetRole() {
  399. m.role = nil
  400. }
  401. // SetStatus sets the "status" field.
  402. func (m *AgentMutation) SetStatus(i int) {
  403. m.status = &i
  404. m.addstatus = nil
  405. }
  406. // Status returns the value of the "status" field in the mutation.
  407. func (m *AgentMutation) Status() (r int, exists bool) {
  408. v := m.status
  409. if v == nil {
  410. return
  411. }
  412. return *v, true
  413. }
  414. // OldStatus returns the old "status" field's value of the Agent entity.
  415. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  417. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  418. if !m.op.Is(OpUpdateOne) {
  419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  420. }
  421. if m.id == nil || m.oldValue == nil {
  422. return v, errors.New("OldStatus requires an ID field in the mutation")
  423. }
  424. oldValue, err := m.oldValue(ctx)
  425. if err != nil {
  426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  427. }
  428. return oldValue.Status, nil
  429. }
  430. // AddStatus adds i to the "status" field.
  431. func (m *AgentMutation) AddStatus(i int) {
  432. if m.addstatus != nil {
  433. *m.addstatus += i
  434. } else {
  435. m.addstatus = &i
  436. }
  437. }
  438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  439. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  440. v := m.addstatus
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // ClearStatus clears the value of the "status" field.
  447. func (m *AgentMutation) ClearStatus() {
  448. m.status = nil
  449. m.addstatus = nil
  450. m.clearedFields[agent.FieldStatus] = struct{}{}
  451. }
  452. // StatusCleared returns if the "status" field was cleared in this mutation.
  453. func (m *AgentMutation) StatusCleared() bool {
  454. _, ok := m.clearedFields[agent.FieldStatus]
  455. return ok
  456. }
  457. // ResetStatus resets all changes to the "status" field.
  458. func (m *AgentMutation) ResetStatus() {
  459. m.status = nil
  460. m.addstatus = nil
  461. delete(m.clearedFields, agent.FieldStatus)
  462. }
  463. // SetBackground sets the "background" field.
  464. func (m *AgentMutation) SetBackground(s string) {
  465. m.background = &s
  466. }
  467. // Background returns the value of the "background" field in the mutation.
  468. func (m *AgentMutation) Background() (r string, exists bool) {
  469. v := m.background
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // OldBackground returns the old "background" field's value of the Agent entity.
  476. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  478. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  479. if !m.op.Is(OpUpdateOne) {
  480. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  481. }
  482. if m.id == nil || m.oldValue == nil {
  483. return v, errors.New("OldBackground requires an ID field in the mutation")
  484. }
  485. oldValue, err := m.oldValue(ctx)
  486. if err != nil {
  487. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  488. }
  489. return oldValue.Background, nil
  490. }
  491. // ClearBackground clears the value of the "background" field.
  492. func (m *AgentMutation) ClearBackground() {
  493. m.background = nil
  494. m.clearedFields[agent.FieldBackground] = struct{}{}
  495. }
  496. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  497. func (m *AgentMutation) BackgroundCleared() bool {
  498. _, ok := m.clearedFields[agent.FieldBackground]
  499. return ok
  500. }
  501. // ResetBackground resets all changes to the "background" field.
  502. func (m *AgentMutation) ResetBackground() {
  503. m.background = nil
  504. delete(m.clearedFields, agent.FieldBackground)
  505. }
  506. // SetExamples sets the "examples" field.
  507. func (m *AgentMutation) SetExamples(s string) {
  508. m.examples = &s
  509. }
  510. // Examples returns the value of the "examples" field in the mutation.
  511. func (m *AgentMutation) Examples() (r string, exists bool) {
  512. v := m.examples
  513. if v == nil {
  514. return
  515. }
  516. return *v, true
  517. }
  518. // OldExamples returns the old "examples" field's value of the Agent entity.
  519. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  521. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  522. if !m.op.Is(OpUpdateOne) {
  523. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  524. }
  525. if m.id == nil || m.oldValue == nil {
  526. return v, errors.New("OldExamples requires an ID field in the mutation")
  527. }
  528. oldValue, err := m.oldValue(ctx)
  529. if err != nil {
  530. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  531. }
  532. return oldValue.Examples, nil
  533. }
  534. // ClearExamples clears the value of the "examples" field.
  535. func (m *AgentMutation) ClearExamples() {
  536. m.examples = nil
  537. m.clearedFields[agent.FieldExamples] = struct{}{}
  538. }
  539. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  540. func (m *AgentMutation) ExamplesCleared() bool {
  541. _, ok := m.clearedFields[agent.FieldExamples]
  542. return ok
  543. }
  544. // ResetExamples resets all changes to the "examples" field.
  545. func (m *AgentMutation) ResetExamples() {
  546. m.examples = nil
  547. delete(m.clearedFields, agent.FieldExamples)
  548. }
  549. // SetOrganizationID sets the "organization_id" field.
  550. func (m *AgentMutation) SetOrganizationID(u uint64) {
  551. m.organization_id = &u
  552. m.addorganization_id = nil
  553. }
  554. // OrganizationID returns the value of the "organization_id" field in the mutation.
  555. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  556. v := m.organization_id
  557. if v == nil {
  558. return
  559. }
  560. return *v, true
  561. }
  562. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  563. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  565. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  566. if !m.op.Is(OpUpdateOne) {
  567. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  568. }
  569. if m.id == nil || m.oldValue == nil {
  570. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  571. }
  572. oldValue, err := m.oldValue(ctx)
  573. if err != nil {
  574. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  575. }
  576. return oldValue.OrganizationID, nil
  577. }
  578. // AddOrganizationID adds u to the "organization_id" field.
  579. func (m *AgentMutation) AddOrganizationID(u int64) {
  580. if m.addorganization_id != nil {
  581. *m.addorganization_id += u
  582. } else {
  583. m.addorganization_id = &u
  584. }
  585. }
  586. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  587. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  588. v := m.addorganization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // ResetOrganizationID resets all changes to the "organization_id" field.
  595. func (m *AgentMutation) ResetOrganizationID() {
  596. m.organization_id = nil
  597. m.addorganization_id = nil
  598. }
  599. // SetDatasetID sets the "dataset_id" field.
  600. func (m *AgentMutation) SetDatasetID(s string) {
  601. m.dataset_id = &s
  602. }
  603. // DatasetID returns the value of the "dataset_id" field in the mutation.
  604. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  605. v := m.dataset_id
  606. if v == nil {
  607. return
  608. }
  609. return *v, true
  610. }
  611. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  612. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  614. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  615. if !m.op.Is(OpUpdateOne) {
  616. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  617. }
  618. if m.id == nil || m.oldValue == nil {
  619. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  620. }
  621. oldValue, err := m.oldValue(ctx)
  622. if err != nil {
  623. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  624. }
  625. return oldValue.DatasetID, nil
  626. }
  627. // ResetDatasetID resets all changes to the "dataset_id" field.
  628. func (m *AgentMutation) ResetDatasetID() {
  629. m.dataset_id = nil
  630. }
  631. // SetCollectionID sets the "collection_id" field.
  632. func (m *AgentMutation) SetCollectionID(s string) {
  633. m.collection_id = &s
  634. }
  635. // CollectionID returns the value of the "collection_id" field in the mutation.
  636. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  637. v := m.collection_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldCollectionID returns the old "collection_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) OldCollectionID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldCollectionID 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 OldCollectionID: %w", err)
  656. }
  657. return oldValue.CollectionID, nil
  658. }
  659. // ResetCollectionID resets all changes to the "collection_id" field.
  660. func (m *AgentMutation) ResetCollectionID() {
  661. m.collection_id = nil
  662. }
  663. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  664. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  665. if m.wx_agent == nil {
  666. m.wx_agent = make(map[uint64]struct{})
  667. }
  668. for i := range ids {
  669. m.wx_agent[ids[i]] = struct{}{}
  670. }
  671. }
  672. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  673. func (m *AgentMutation) ClearWxAgent() {
  674. m.clearedwx_agent = true
  675. }
  676. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  677. func (m *AgentMutation) WxAgentCleared() bool {
  678. return m.clearedwx_agent
  679. }
  680. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  681. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  682. if m.removedwx_agent == nil {
  683. m.removedwx_agent = make(map[uint64]struct{})
  684. }
  685. for i := range ids {
  686. delete(m.wx_agent, ids[i])
  687. m.removedwx_agent[ids[i]] = struct{}{}
  688. }
  689. }
  690. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  691. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  692. for id := range m.removedwx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  698. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  699. for id := range m.wx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // ResetWxAgent resets all changes to the "wx_agent" edge.
  705. func (m *AgentMutation) ResetWxAgent() {
  706. m.wx_agent = nil
  707. m.clearedwx_agent = false
  708. m.removedwx_agent = nil
  709. }
  710. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  711. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  712. if m.token_agent == nil {
  713. m.token_agent = make(map[uint64]struct{})
  714. }
  715. for i := range ids {
  716. m.token_agent[ids[i]] = struct{}{}
  717. }
  718. }
  719. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  720. func (m *AgentMutation) ClearTokenAgent() {
  721. m.clearedtoken_agent = true
  722. }
  723. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  724. func (m *AgentMutation) TokenAgentCleared() bool {
  725. return m.clearedtoken_agent
  726. }
  727. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  728. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  729. if m.removedtoken_agent == nil {
  730. m.removedtoken_agent = make(map[uint64]struct{})
  731. }
  732. for i := range ids {
  733. delete(m.token_agent, ids[i])
  734. m.removedtoken_agent[ids[i]] = struct{}{}
  735. }
  736. }
  737. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  738. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  739. for id := range m.removedtoken_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  745. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  746. for id := range m.token_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // ResetTokenAgent resets all changes to the "token_agent" edge.
  752. func (m *AgentMutation) ResetTokenAgent() {
  753. m.token_agent = nil
  754. m.clearedtoken_agent = false
  755. m.removedtoken_agent = nil
  756. }
  757. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  758. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  759. if m.wa_agent == nil {
  760. m.wa_agent = make(map[uint64]struct{})
  761. }
  762. for i := range ids {
  763. m.wa_agent[ids[i]] = struct{}{}
  764. }
  765. }
  766. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  767. func (m *AgentMutation) ClearWaAgent() {
  768. m.clearedwa_agent = true
  769. }
  770. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  771. func (m *AgentMutation) WaAgentCleared() bool {
  772. return m.clearedwa_agent
  773. }
  774. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  775. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  776. if m.removedwa_agent == nil {
  777. m.removedwa_agent = make(map[uint64]struct{})
  778. }
  779. for i := range ids {
  780. delete(m.wa_agent, ids[i])
  781. m.removedwa_agent[ids[i]] = struct{}{}
  782. }
  783. }
  784. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  785. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  786. for id := range m.removedwa_agent {
  787. ids = append(ids, id)
  788. }
  789. return
  790. }
  791. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  792. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  793. for id := range m.wa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // ResetWaAgent resets all changes to the "wa_agent" edge.
  799. func (m *AgentMutation) ResetWaAgent() {
  800. m.wa_agent = nil
  801. m.clearedwa_agent = false
  802. m.removedwa_agent = nil
  803. }
  804. // Where appends a list predicates to the AgentMutation builder.
  805. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  806. m.predicates = append(m.predicates, ps...)
  807. }
  808. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  809. // users can use type-assertion to append predicates that do not depend on any generated package.
  810. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  811. p := make([]predicate.Agent, len(ps))
  812. for i := range ps {
  813. p[i] = ps[i]
  814. }
  815. m.Where(p...)
  816. }
  817. // Op returns the operation name.
  818. func (m *AgentMutation) Op() Op {
  819. return m.op
  820. }
  821. // SetOp allows setting the mutation operation.
  822. func (m *AgentMutation) SetOp(op Op) {
  823. m.op = op
  824. }
  825. // Type returns the node type of this mutation (Agent).
  826. func (m *AgentMutation) Type() string {
  827. return m.typ
  828. }
  829. // Fields returns all fields that were changed during this mutation. Note that in
  830. // order to get all numeric fields that were incremented/decremented, call
  831. // AddedFields().
  832. func (m *AgentMutation) Fields() []string {
  833. fields := make([]string, 0, 11)
  834. if m.created_at != nil {
  835. fields = append(fields, agent.FieldCreatedAt)
  836. }
  837. if m.updated_at != nil {
  838. fields = append(fields, agent.FieldUpdatedAt)
  839. }
  840. if m.deleted_at != nil {
  841. fields = append(fields, agent.FieldDeletedAt)
  842. }
  843. if m.name != nil {
  844. fields = append(fields, agent.FieldName)
  845. }
  846. if m.role != nil {
  847. fields = append(fields, agent.FieldRole)
  848. }
  849. if m.status != nil {
  850. fields = append(fields, agent.FieldStatus)
  851. }
  852. if m.background != nil {
  853. fields = append(fields, agent.FieldBackground)
  854. }
  855. if m.examples != nil {
  856. fields = append(fields, agent.FieldExamples)
  857. }
  858. if m.organization_id != nil {
  859. fields = append(fields, agent.FieldOrganizationID)
  860. }
  861. if m.dataset_id != nil {
  862. fields = append(fields, agent.FieldDatasetID)
  863. }
  864. if m.collection_id != nil {
  865. fields = append(fields, agent.FieldCollectionID)
  866. }
  867. return fields
  868. }
  869. // Field returns the value of a field with the given name. The second boolean
  870. // return value indicates that this field was not set, or was not defined in the
  871. // schema.
  872. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. return m.CreatedAt()
  876. case agent.FieldUpdatedAt:
  877. return m.UpdatedAt()
  878. case agent.FieldDeletedAt:
  879. return m.DeletedAt()
  880. case agent.FieldName:
  881. return m.Name()
  882. case agent.FieldRole:
  883. return m.Role()
  884. case agent.FieldStatus:
  885. return m.Status()
  886. case agent.FieldBackground:
  887. return m.Background()
  888. case agent.FieldExamples:
  889. return m.Examples()
  890. case agent.FieldOrganizationID:
  891. return m.OrganizationID()
  892. case agent.FieldDatasetID:
  893. return m.DatasetID()
  894. case agent.FieldCollectionID:
  895. return m.CollectionID()
  896. }
  897. return nil, false
  898. }
  899. // OldField returns the old value of the field from the database. An error is
  900. // returned if the mutation operation is not UpdateOne, or the query to the
  901. // database failed.
  902. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  903. switch name {
  904. case agent.FieldCreatedAt:
  905. return m.OldCreatedAt(ctx)
  906. case agent.FieldUpdatedAt:
  907. return m.OldUpdatedAt(ctx)
  908. case agent.FieldDeletedAt:
  909. return m.OldDeletedAt(ctx)
  910. case agent.FieldName:
  911. return m.OldName(ctx)
  912. case agent.FieldRole:
  913. return m.OldRole(ctx)
  914. case agent.FieldStatus:
  915. return m.OldStatus(ctx)
  916. case agent.FieldBackground:
  917. return m.OldBackground(ctx)
  918. case agent.FieldExamples:
  919. return m.OldExamples(ctx)
  920. case agent.FieldOrganizationID:
  921. return m.OldOrganizationID(ctx)
  922. case agent.FieldDatasetID:
  923. return m.OldDatasetID(ctx)
  924. case agent.FieldCollectionID:
  925. return m.OldCollectionID(ctx)
  926. }
  927. return nil, fmt.Errorf("unknown Agent field %s", name)
  928. }
  929. // SetField sets the value of a field with the given name. It returns an error if
  930. // the field is not defined in the schema, or if the type mismatched the field
  931. // type.
  932. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  933. switch name {
  934. case agent.FieldCreatedAt:
  935. v, ok := value.(time.Time)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetCreatedAt(v)
  940. return nil
  941. case agent.FieldUpdatedAt:
  942. v, ok := value.(time.Time)
  943. if !ok {
  944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  945. }
  946. m.SetUpdatedAt(v)
  947. return nil
  948. case agent.FieldDeletedAt:
  949. v, ok := value.(time.Time)
  950. if !ok {
  951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  952. }
  953. m.SetDeletedAt(v)
  954. return nil
  955. case agent.FieldName:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetName(v)
  961. return nil
  962. case agent.FieldRole:
  963. v, ok := value.(string)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetRole(v)
  968. return nil
  969. case agent.FieldStatus:
  970. v, ok := value.(int)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetStatus(v)
  975. return nil
  976. case agent.FieldBackground:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetBackground(v)
  982. return nil
  983. case agent.FieldExamples:
  984. v, ok := value.(string)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetExamples(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(uint64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetOrganizationID(v)
  996. return nil
  997. case agent.FieldDatasetID:
  998. v, ok := value.(string)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetDatasetID(v)
  1003. return nil
  1004. case agent.FieldCollectionID:
  1005. v, ok := value.(string)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetCollectionID(v)
  1010. return nil
  1011. }
  1012. return fmt.Errorf("unknown Agent field %s", name)
  1013. }
  1014. // AddedFields returns all numeric fields that were incremented/decremented during
  1015. // this mutation.
  1016. func (m *AgentMutation) AddedFields() []string {
  1017. var fields []string
  1018. if m.addstatus != nil {
  1019. fields = append(fields, agent.FieldStatus)
  1020. }
  1021. if m.addorganization_id != nil {
  1022. fields = append(fields, agent.FieldOrganizationID)
  1023. }
  1024. return fields
  1025. }
  1026. // AddedField returns the numeric value that was incremented/decremented on a field
  1027. // with the given name. The second boolean return value indicates that this field
  1028. // was not set, or was not defined in the schema.
  1029. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1030. switch name {
  1031. case agent.FieldStatus:
  1032. return m.AddedStatus()
  1033. case agent.FieldOrganizationID:
  1034. return m.AddedOrganizationID()
  1035. }
  1036. return nil, false
  1037. }
  1038. // AddField adds the value to the field with the given name. It returns an error if
  1039. // the field is not defined in the schema, or if the type mismatched the field
  1040. // type.
  1041. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1042. switch name {
  1043. case agent.FieldStatus:
  1044. v, ok := value.(int)
  1045. if !ok {
  1046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1047. }
  1048. m.AddStatus(v)
  1049. return nil
  1050. case agent.FieldOrganizationID:
  1051. v, ok := value.(int64)
  1052. if !ok {
  1053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1054. }
  1055. m.AddOrganizationID(v)
  1056. return nil
  1057. }
  1058. return fmt.Errorf("unknown Agent numeric field %s", name)
  1059. }
  1060. // ClearedFields returns all nullable fields that were cleared during this
  1061. // mutation.
  1062. func (m *AgentMutation) ClearedFields() []string {
  1063. var fields []string
  1064. if m.FieldCleared(agent.FieldDeletedAt) {
  1065. fields = append(fields, agent.FieldDeletedAt)
  1066. }
  1067. if m.FieldCleared(agent.FieldStatus) {
  1068. fields = append(fields, agent.FieldStatus)
  1069. }
  1070. if m.FieldCleared(agent.FieldBackground) {
  1071. fields = append(fields, agent.FieldBackground)
  1072. }
  1073. if m.FieldCleared(agent.FieldExamples) {
  1074. fields = append(fields, agent.FieldExamples)
  1075. }
  1076. return fields
  1077. }
  1078. // FieldCleared returns a boolean indicating if a field with the given name was
  1079. // cleared in this mutation.
  1080. func (m *AgentMutation) FieldCleared(name string) bool {
  1081. _, ok := m.clearedFields[name]
  1082. return ok
  1083. }
  1084. // ClearField clears the value of the field with the given name. It returns an
  1085. // error if the field is not defined in the schema.
  1086. func (m *AgentMutation) ClearField(name string) error {
  1087. switch name {
  1088. case agent.FieldDeletedAt:
  1089. m.ClearDeletedAt()
  1090. return nil
  1091. case agent.FieldStatus:
  1092. m.ClearStatus()
  1093. return nil
  1094. case agent.FieldBackground:
  1095. m.ClearBackground()
  1096. return nil
  1097. case agent.FieldExamples:
  1098. m.ClearExamples()
  1099. return nil
  1100. }
  1101. return fmt.Errorf("unknown Agent nullable field %s", name)
  1102. }
  1103. // ResetField resets all changes in the mutation for the field with the given name.
  1104. // It returns an error if the field is not defined in the schema.
  1105. func (m *AgentMutation) ResetField(name string) error {
  1106. switch name {
  1107. case agent.FieldCreatedAt:
  1108. m.ResetCreatedAt()
  1109. return nil
  1110. case agent.FieldUpdatedAt:
  1111. m.ResetUpdatedAt()
  1112. return nil
  1113. case agent.FieldDeletedAt:
  1114. m.ResetDeletedAt()
  1115. return nil
  1116. case agent.FieldName:
  1117. m.ResetName()
  1118. return nil
  1119. case agent.FieldRole:
  1120. m.ResetRole()
  1121. return nil
  1122. case agent.FieldStatus:
  1123. m.ResetStatus()
  1124. return nil
  1125. case agent.FieldBackground:
  1126. m.ResetBackground()
  1127. return nil
  1128. case agent.FieldExamples:
  1129. m.ResetExamples()
  1130. return nil
  1131. case agent.FieldOrganizationID:
  1132. m.ResetOrganizationID()
  1133. return nil
  1134. case agent.FieldDatasetID:
  1135. m.ResetDatasetID()
  1136. return nil
  1137. case agent.FieldCollectionID:
  1138. m.ResetCollectionID()
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown Agent field %s", name)
  1142. }
  1143. // AddedEdges returns all edge names that were set/added in this mutation.
  1144. func (m *AgentMutation) AddedEdges() []string {
  1145. edges := make([]string, 0, 3)
  1146. if m.wx_agent != nil {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.token_agent != nil {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. if m.wa_agent != nil {
  1153. edges = append(edges, agent.EdgeWaAgent)
  1154. }
  1155. return edges
  1156. }
  1157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1158. // name in this mutation.
  1159. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1160. switch name {
  1161. case agent.EdgeWxAgent:
  1162. ids := make([]ent.Value, 0, len(m.wx_agent))
  1163. for id := range m.wx_agent {
  1164. ids = append(ids, id)
  1165. }
  1166. return ids
  1167. case agent.EdgeTokenAgent:
  1168. ids := make([]ent.Value, 0, len(m.token_agent))
  1169. for id := range m.token_agent {
  1170. ids = append(ids, id)
  1171. }
  1172. return ids
  1173. case agent.EdgeWaAgent:
  1174. ids := make([]ent.Value, 0, len(m.wa_agent))
  1175. for id := range m.wa_agent {
  1176. ids = append(ids, id)
  1177. }
  1178. return ids
  1179. }
  1180. return nil
  1181. }
  1182. // RemovedEdges returns all edge names that were removed in this mutation.
  1183. func (m *AgentMutation) RemovedEdges() []string {
  1184. edges := make([]string, 0, 3)
  1185. if m.removedwx_agent != nil {
  1186. edges = append(edges, agent.EdgeWxAgent)
  1187. }
  1188. if m.removedtoken_agent != nil {
  1189. edges = append(edges, agent.EdgeTokenAgent)
  1190. }
  1191. if m.removedwa_agent != nil {
  1192. edges = append(edges, agent.EdgeWaAgent)
  1193. }
  1194. return edges
  1195. }
  1196. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1197. // the given name in this mutation.
  1198. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1199. switch name {
  1200. case agent.EdgeWxAgent:
  1201. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1202. for id := range m.removedwx_agent {
  1203. ids = append(ids, id)
  1204. }
  1205. return ids
  1206. case agent.EdgeTokenAgent:
  1207. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1208. for id := range m.removedtoken_agent {
  1209. ids = append(ids, id)
  1210. }
  1211. return ids
  1212. case agent.EdgeWaAgent:
  1213. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1214. for id := range m.removedwa_agent {
  1215. ids = append(ids, id)
  1216. }
  1217. return ids
  1218. }
  1219. return nil
  1220. }
  1221. // ClearedEdges returns all edge names that were cleared in this mutation.
  1222. func (m *AgentMutation) ClearedEdges() []string {
  1223. edges := make([]string, 0, 3)
  1224. if m.clearedwx_agent {
  1225. edges = append(edges, agent.EdgeWxAgent)
  1226. }
  1227. if m.clearedtoken_agent {
  1228. edges = append(edges, agent.EdgeTokenAgent)
  1229. }
  1230. if m.clearedwa_agent {
  1231. edges = append(edges, agent.EdgeWaAgent)
  1232. }
  1233. return edges
  1234. }
  1235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1236. // was cleared in this mutation.
  1237. func (m *AgentMutation) EdgeCleared(name string) bool {
  1238. switch name {
  1239. case agent.EdgeWxAgent:
  1240. return m.clearedwx_agent
  1241. case agent.EdgeTokenAgent:
  1242. return m.clearedtoken_agent
  1243. case agent.EdgeWaAgent:
  1244. return m.clearedwa_agent
  1245. }
  1246. return false
  1247. }
  1248. // ClearEdge clears the value of the edge with the given name. It returns an error
  1249. // if that edge is not defined in the schema.
  1250. func (m *AgentMutation) ClearEdge(name string) error {
  1251. switch name {
  1252. }
  1253. return fmt.Errorf("unknown Agent unique edge %s", name)
  1254. }
  1255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1256. // It returns an error if the edge is not defined in the schema.
  1257. func (m *AgentMutation) ResetEdge(name string) error {
  1258. switch name {
  1259. case agent.EdgeWxAgent:
  1260. m.ResetWxAgent()
  1261. return nil
  1262. case agent.EdgeTokenAgent:
  1263. m.ResetTokenAgent()
  1264. return nil
  1265. case agent.EdgeWaAgent:
  1266. m.ResetWaAgent()
  1267. return nil
  1268. }
  1269. return fmt.Errorf("unknown Agent edge %s", name)
  1270. }
  1271. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1272. type AgentBaseMutation struct {
  1273. config
  1274. op Op
  1275. typ string
  1276. id *string
  1277. q *string
  1278. a *string
  1279. chunk_index *uint64
  1280. addchunk_index *int64
  1281. indexes *[]string
  1282. appendindexes []string
  1283. dataset_id *string
  1284. collection_id *string
  1285. source_name *string
  1286. can_write *[]bool
  1287. appendcan_write []bool
  1288. is_owner *[]bool
  1289. appendis_owner []bool
  1290. clearedFields map[string]struct{}
  1291. wx_agent map[uint64]struct{}
  1292. removedwx_agent map[uint64]struct{}
  1293. clearedwx_agent bool
  1294. done bool
  1295. oldValue func(context.Context) (*AgentBase, error)
  1296. predicates []predicate.AgentBase
  1297. }
  1298. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1299. // agentbaseOption allows management of the mutation configuration using functional options.
  1300. type agentbaseOption func(*AgentBaseMutation)
  1301. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1302. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1303. m := &AgentBaseMutation{
  1304. config: c,
  1305. op: op,
  1306. typ: TypeAgentBase,
  1307. clearedFields: make(map[string]struct{}),
  1308. }
  1309. for _, opt := range opts {
  1310. opt(m)
  1311. }
  1312. return m
  1313. }
  1314. // withAgentBaseID sets the ID field of the mutation.
  1315. func withAgentBaseID(id string) agentbaseOption {
  1316. return func(m *AgentBaseMutation) {
  1317. var (
  1318. err error
  1319. once sync.Once
  1320. value *AgentBase
  1321. )
  1322. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1323. once.Do(func() {
  1324. if m.done {
  1325. err = errors.New("querying old values post mutation is not allowed")
  1326. } else {
  1327. value, err = m.Client().AgentBase.Get(ctx, id)
  1328. }
  1329. })
  1330. return value, err
  1331. }
  1332. m.id = &id
  1333. }
  1334. }
  1335. // withAgentBase sets the old AgentBase of the mutation.
  1336. func withAgentBase(node *AgentBase) agentbaseOption {
  1337. return func(m *AgentBaseMutation) {
  1338. m.oldValue = func(context.Context) (*AgentBase, error) {
  1339. return node, nil
  1340. }
  1341. m.id = &node.ID
  1342. }
  1343. }
  1344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1345. // executed in a transaction (ent.Tx), a transactional client is returned.
  1346. func (m AgentBaseMutation) Client() *Client {
  1347. client := &Client{config: m.config}
  1348. client.init()
  1349. return client
  1350. }
  1351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1352. // it returns an error otherwise.
  1353. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1354. if _, ok := m.driver.(*txDriver); !ok {
  1355. return nil, errors.New("ent: mutation is not running in a transaction")
  1356. }
  1357. tx := &Tx{config: m.config}
  1358. tx.init()
  1359. return tx, nil
  1360. }
  1361. // SetID sets the value of the id field. Note that this
  1362. // operation is only accepted on creation of AgentBase entities.
  1363. func (m *AgentBaseMutation) SetID(id string) {
  1364. m.id = &id
  1365. }
  1366. // ID returns the ID value in the mutation. Note that the ID is only available
  1367. // if it was provided to the builder or after it was returned from the database.
  1368. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1369. if m.id == nil {
  1370. return
  1371. }
  1372. return *m.id, true
  1373. }
  1374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1375. // That means, if the mutation is applied within a transaction with an isolation level such
  1376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1377. // or updated by the mutation.
  1378. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1379. switch {
  1380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1381. id, exists := m.ID()
  1382. if exists {
  1383. return []string{id}, nil
  1384. }
  1385. fallthrough
  1386. case m.op.Is(OpUpdate | OpDelete):
  1387. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1388. default:
  1389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1390. }
  1391. }
  1392. // SetQ sets the "q" field.
  1393. func (m *AgentBaseMutation) SetQ(s string) {
  1394. m.q = &s
  1395. }
  1396. // Q returns the value of the "q" field in the mutation.
  1397. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1398. v := m.q
  1399. if v == nil {
  1400. return
  1401. }
  1402. return *v, true
  1403. }
  1404. // OldQ returns the old "q" field's value of the AgentBase entity.
  1405. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1407. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1408. if !m.op.Is(OpUpdateOne) {
  1409. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1410. }
  1411. if m.id == nil || m.oldValue == nil {
  1412. return v, errors.New("OldQ requires an ID field in the mutation")
  1413. }
  1414. oldValue, err := m.oldValue(ctx)
  1415. if err != nil {
  1416. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1417. }
  1418. return oldValue.Q, nil
  1419. }
  1420. // ClearQ clears the value of the "q" field.
  1421. func (m *AgentBaseMutation) ClearQ() {
  1422. m.q = nil
  1423. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1424. }
  1425. // QCleared returns if the "q" field was cleared in this mutation.
  1426. func (m *AgentBaseMutation) QCleared() bool {
  1427. _, ok := m.clearedFields[agentbase.FieldQ]
  1428. return ok
  1429. }
  1430. // ResetQ resets all changes to the "q" field.
  1431. func (m *AgentBaseMutation) ResetQ() {
  1432. m.q = nil
  1433. delete(m.clearedFields, agentbase.FieldQ)
  1434. }
  1435. // SetA sets the "a" field.
  1436. func (m *AgentBaseMutation) SetA(s string) {
  1437. m.a = &s
  1438. }
  1439. // A returns the value of the "a" field in the mutation.
  1440. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1441. v := m.a
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldA returns the old "a" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldA requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1460. }
  1461. return oldValue.A, nil
  1462. }
  1463. // ClearA clears the value of the "a" field.
  1464. func (m *AgentBaseMutation) ClearA() {
  1465. m.a = nil
  1466. m.clearedFields[agentbase.FieldA] = struct{}{}
  1467. }
  1468. // ACleared returns if the "a" field was cleared in this mutation.
  1469. func (m *AgentBaseMutation) ACleared() bool {
  1470. _, ok := m.clearedFields[agentbase.FieldA]
  1471. return ok
  1472. }
  1473. // ResetA resets all changes to the "a" field.
  1474. func (m *AgentBaseMutation) ResetA() {
  1475. m.a = nil
  1476. delete(m.clearedFields, agentbase.FieldA)
  1477. }
  1478. // SetChunkIndex sets the "chunk_index" field.
  1479. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1480. m.chunk_index = &u
  1481. m.addchunk_index = nil
  1482. }
  1483. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1484. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1485. v := m.chunk_index
  1486. if v == nil {
  1487. return
  1488. }
  1489. return *v, true
  1490. }
  1491. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1492. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1494. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1495. if !m.op.Is(OpUpdateOne) {
  1496. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1497. }
  1498. if m.id == nil || m.oldValue == nil {
  1499. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1500. }
  1501. oldValue, err := m.oldValue(ctx)
  1502. if err != nil {
  1503. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1504. }
  1505. return oldValue.ChunkIndex, nil
  1506. }
  1507. // AddChunkIndex adds u to the "chunk_index" field.
  1508. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1509. if m.addchunk_index != nil {
  1510. *m.addchunk_index += u
  1511. } else {
  1512. m.addchunk_index = &u
  1513. }
  1514. }
  1515. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1516. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1517. v := m.addchunk_index
  1518. if v == nil {
  1519. return
  1520. }
  1521. return *v, true
  1522. }
  1523. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1524. func (m *AgentBaseMutation) ResetChunkIndex() {
  1525. m.chunk_index = nil
  1526. m.addchunk_index = nil
  1527. }
  1528. // SetIndexes sets the "indexes" field.
  1529. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1530. m.indexes = &s
  1531. m.appendindexes = nil
  1532. }
  1533. // Indexes returns the value of the "indexes" field in the mutation.
  1534. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1535. v := m.indexes
  1536. if v == nil {
  1537. return
  1538. }
  1539. return *v, true
  1540. }
  1541. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1542. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1544. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1545. if !m.op.Is(OpUpdateOne) {
  1546. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1547. }
  1548. if m.id == nil || m.oldValue == nil {
  1549. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1550. }
  1551. oldValue, err := m.oldValue(ctx)
  1552. if err != nil {
  1553. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1554. }
  1555. return oldValue.Indexes, nil
  1556. }
  1557. // AppendIndexes adds s to the "indexes" field.
  1558. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1559. m.appendindexes = append(m.appendindexes, s...)
  1560. }
  1561. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1562. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1563. if len(m.appendindexes) == 0 {
  1564. return nil, false
  1565. }
  1566. return m.appendindexes, true
  1567. }
  1568. // ClearIndexes clears the value of the "indexes" field.
  1569. func (m *AgentBaseMutation) ClearIndexes() {
  1570. m.indexes = nil
  1571. m.appendindexes = nil
  1572. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1573. }
  1574. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1575. func (m *AgentBaseMutation) IndexesCleared() bool {
  1576. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1577. return ok
  1578. }
  1579. // ResetIndexes resets all changes to the "indexes" field.
  1580. func (m *AgentBaseMutation) ResetIndexes() {
  1581. m.indexes = nil
  1582. m.appendindexes = nil
  1583. delete(m.clearedFields, agentbase.FieldIndexes)
  1584. }
  1585. // SetDatasetID sets the "dataset_id" field.
  1586. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1587. m.dataset_id = &s
  1588. }
  1589. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1590. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1591. v := m.dataset_id
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1610. }
  1611. return oldValue.DatasetID, nil
  1612. }
  1613. // ClearDatasetID clears the value of the "dataset_id" field.
  1614. func (m *AgentBaseMutation) ClearDatasetID() {
  1615. m.dataset_id = nil
  1616. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1617. }
  1618. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1621. return ok
  1622. }
  1623. // ResetDatasetID resets all changes to the "dataset_id" field.
  1624. func (m *AgentBaseMutation) ResetDatasetID() {
  1625. m.dataset_id = nil
  1626. delete(m.clearedFields, agentbase.FieldDatasetID)
  1627. }
  1628. // SetCollectionID sets the "collection_id" field.
  1629. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1630. m.collection_id = &s
  1631. }
  1632. // CollectionID returns the value of the "collection_id" field in the mutation.
  1633. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1634. v := m.collection_id
  1635. if v == nil {
  1636. return
  1637. }
  1638. return *v, true
  1639. }
  1640. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1641. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1643. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1644. if !m.op.Is(OpUpdateOne) {
  1645. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1646. }
  1647. if m.id == nil || m.oldValue == nil {
  1648. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1649. }
  1650. oldValue, err := m.oldValue(ctx)
  1651. if err != nil {
  1652. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1653. }
  1654. return oldValue.CollectionID, nil
  1655. }
  1656. // ClearCollectionID clears the value of the "collection_id" field.
  1657. func (m *AgentBaseMutation) ClearCollectionID() {
  1658. m.collection_id = nil
  1659. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1660. }
  1661. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1662. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1663. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1664. return ok
  1665. }
  1666. // ResetCollectionID resets all changes to the "collection_id" field.
  1667. func (m *AgentBaseMutation) ResetCollectionID() {
  1668. m.collection_id = nil
  1669. delete(m.clearedFields, agentbase.FieldCollectionID)
  1670. }
  1671. // SetSourceName sets the "source_name" field.
  1672. func (m *AgentBaseMutation) SetSourceName(s string) {
  1673. m.source_name = &s
  1674. }
  1675. // SourceName returns the value of the "source_name" field in the mutation.
  1676. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1677. v := m.source_name
  1678. if v == nil {
  1679. return
  1680. }
  1681. return *v, true
  1682. }
  1683. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1684. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1686. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1687. if !m.op.Is(OpUpdateOne) {
  1688. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1689. }
  1690. if m.id == nil || m.oldValue == nil {
  1691. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1692. }
  1693. oldValue, err := m.oldValue(ctx)
  1694. if err != nil {
  1695. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1696. }
  1697. return oldValue.SourceName, nil
  1698. }
  1699. // ClearSourceName clears the value of the "source_name" field.
  1700. func (m *AgentBaseMutation) ClearSourceName() {
  1701. m.source_name = nil
  1702. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1703. }
  1704. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1705. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1706. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1707. return ok
  1708. }
  1709. // ResetSourceName resets all changes to the "source_name" field.
  1710. func (m *AgentBaseMutation) ResetSourceName() {
  1711. m.source_name = nil
  1712. delete(m.clearedFields, agentbase.FieldSourceName)
  1713. }
  1714. // SetCanWrite sets the "can_write" field.
  1715. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1716. m.can_write = &b
  1717. m.appendcan_write = nil
  1718. }
  1719. // CanWrite returns the value of the "can_write" field in the mutation.
  1720. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1721. v := m.can_write
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1728. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1740. }
  1741. return oldValue.CanWrite, nil
  1742. }
  1743. // AppendCanWrite adds b to the "can_write" field.
  1744. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1745. m.appendcan_write = append(m.appendcan_write, b...)
  1746. }
  1747. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1748. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1749. if len(m.appendcan_write) == 0 {
  1750. return nil, false
  1751. }
  1752. return m.appendcan_write, true
  1753. }
  1754. // ClearCanWrite clears the value of the "can_write" field.
  1755. func (m *AgentBaseMutation) ClearCanWrite() {
  1756. m.can_write = nil
  1757. m.appendcan_write = nil
  1758. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1759. }
  1760. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1761. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1762. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1763. return ok
  1764. }
  1765. // ResetCanWrite resets all changes to the "can_write" field.
  1766. func (m *AgentBaseMutation) ResetCanWrite() {
  1767. m.can_write = nil
  1768. m.appendcan_write = nil
  1769. delete(m.clearedFields, agentbase.FieldCanWrite)
  1770. }
  1771. // SetIsOwner sets the "is_owner" field.
  1772. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1773. m.is_owner = &b
  1774. m.appendis_owner = nil
  1775. }
  1776. // IsOwner returns the value of the "is_owner" field in the mutation.
  1777. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1778. v := m.is_owner
  1779. if v == nil {
  1780. return
  1781. }
  1782. return *v, true
  1783. }
  1784. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1785. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1787. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1788. if !m.op.Is(OpUpdateOne) {
  1789. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1790. }
  1791. if m.id == nil || m.oldValue == nil {
  1792. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1793. }
  1794. oldValue, err := m.oldValue(ctx)
  1795. if err != nil {
  1796. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1797. }
  1798. return oldValue.IsOwner, nil
  1799. }
  1800. // AppendIsOwner adds b to the "is_owner" field.
  1801. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1802. m.appendis_owner = append(m.appendis_owner, b...)
  1803. }
  1804. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1805. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1806. if len(m.appendis_owner) == 0 {
  1807. return nil, false
  1808. }
  1809. return m.appendis_owner, true
  1810. }
  1811. // ClearIsOwner clears the value of the "is_owner" field.
  1812. func (m *AgentBaseMutation) ClearIsOwner() {
  1813. m.is_owner = nil
  1814. m.appendis_owner = nil
  1815. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1816. }
  1817. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1818. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1819. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1820. return ok
  1821. }
  1822. // ResetIsOwner resets all changes to the "is_owner" field.
  1823. func (m *AgentBaseMutation) ResetIsOwner() {
  1824. m.is_owner = nil
  1825. m.appendis_owner = nil
  1826. delete(m.clearedFields, agentbase.FieldIsOwner)
  1827. }
  1828. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1829. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1830. if m.wx_agent == nil {
  1831. m.wx_agent = make(map[uint64]struct{})
  1832. }
  1833. for i := range ids {
  1834. m.wx_agent[ids[i]] = struct{}{}
  1835. }
  1836. }
  1837. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1838. func (m *AgentBaseMutation) ClearWxAgent() {
  1839. m.clearedwx_agent = true
  1840. }
  1841. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1842. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1843. return m.clearedwx_agent
  1844. }
  1845. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1846. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1847. if m.removedwx_agent == nil {
  1848. m.removedwx_agent = make(map[uint64]struct{})
  1849. }
  1850. for i := range ids {
  1851. delete(m.wx_agent, ids[i])
  1852. m.removedwx_agent[ids[i]] = struct{}{}
  1853. }
  1854. }
  1855. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1856. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1857. for id := range m.removedwx_agent {
  1858. ids = append(ids, id)
  1859. }
  1860. return
  1861. }
  1862. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1863. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1864. for id := range m.wx_agent {
  1865. ids = append(ids, id)
  1866. }
  1867. return
  1868. }
  1869. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1870. func (m *AgentBaseMutation) ResetWxAgent() {
  1871. m.wx_agent = nil
  1872. m.clearedwx_agent = false
  1873. m.removedwx_agent = nil
  1874. }
  1875. // Where appends a list predicates to the AgentBaseMutation builder.
  1876. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1877. m.predicates = append(m.predicates, ps...)
  1878. }
  1879. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1880. // users can use type-assertion to append predicates that do not depend on any generated package.
  1881. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1882. p := make([]predicate.AgentBase, len(ps))
  1883. for i := range ps {
  1884. p[i] = ps[i]
  1885. }
  1886. m.Where(p...)
  1887. }
  1888. // Op returns the operation name.
  1889. func (m *AgentBaseMutation) Op() Op {
  1890. return m.op
  1891. }
  1892. // SetOp allows setting the mutation operation.
  1893. func (m *AgentBaseMutation) SetOp(op Op) {
  1894. m.op = op
  1895. }
  1896. // Type returns the node type of this mutation (AgentBase).
  1897. func (m *AgentBaseMutation) Type() string {
  1898. return m.typ
  1899. }
  1900. // Fields returns all fields that were changed during this mutation. Note that in
  1901. // order to get all numeric fields that were incremented/decremented, call
  1902. // AddedFields().
  1903. func (m *AgentBaseMutation) Fields() []string {
  1904. fields := make([]string, 0, 9)
  1905. if m.q != nil {
  1906. fields = append(fields, agentbase.FieldQ)
  1907. }
  1908. if m.a != nil {
  1909. fields = append(fields, agentbase.FieldA)
  1910. }
  1911. if m.chunk_index != nil {
  1912. fields = append(fields, agentbase.FieldChunkIndex)
  1913. }
  1914. if m.indexes != nil {
  1915. fields = append(fields, agentbase.FieldIndexes)
  1916. }
  1917. if m.dataset_id != nil {
  1918. fields = append(fields, agentbase.FieldDatasetID)
  1919. }
  1920. if m.collection_id != nil {
  1921. fields = append(fields, agentbase.FieldCollectionID)
  1922. }
  1923. if m.source_name != nil {
  1924. fields = append(fields, agentbase.FieldSourceName)
  1925. }
  1926. if m.can_write != nil {
  1927. fields = append(fields, agentbase.FieldCanWrite)
  1928. }
  1929. if m.is_owner != nil {
  1930. fields = append(fields, agentbase.FieldIsOwner)
  1931. }
  1932. return fields
  1933. }
  1934. // Field returns the value of a field with the given name. The second boolean
  1935. // return value indicates that this field was not set, or was not defined in the
  1936. // schema.
  1937. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1938. switch name {
  1939. case agentbase.FieldQ:
  1940. return m.Q()
  1941. case agentbase.FieldA:
  1942. return m.A()
  1943. case agentbase.FieldChunkIndex:
  1944. return m.ChunkIndex()
  1945. case agentbase.FieldIndexes:
  1946. return m.Indexes()
  1947. case agentbase.FieldDatasetID:
  1948. return m.DatasetID()
  1949. case agentbase.FieldCollectionID:
  1950. return m.CollectionID()
  1951. case agentbase.FieldSourceName:
  1952. return m.SourceName()
  1953. case agentbase.FieldCanWrite:
  1954. return m.CanWrite()
  1955. case agentbase.FieldIsOwner:
  1956. return m.IsOwner()
  1957. }
  1958. return nil, false
  1959. }
  1960. // OldField returns the old value of the field from the database. An error is
  1961. // returned if the mutation operation is not UpdateOne, or the query to the
  1962. // database failed.
  1963. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1964. switch name {
  1965. case agentbase.FieldQ:
  1966. return m.OldQ(ctx)
  1967. case agentbase.FieldA:
  1968. return m.OldA(ctx)
  1969. case agentbase.FieldChunkIndex:
  1970. return m.OldChunkIndex(ctx)
  1971. case agentbase.FieldIndexes:
  1972. return m.OldIndexes(ctx)
  1973. case agentbase.FieldDatasetID:
  1974. return m.OldDatasetID(ctx)
  1975. case agentbase.FieldCollectionID:
  1976. return m.OldCollectionID(ctx)
  1977. case agentbase.FieldSourceName:
  1978. return m.OldSourceName(ctx)
  1979. case agentbase.FieldCanWrite:
  1980. return m.OldCanWrite(ctx)
  1981. case agentbase.FieldIsOwner:
  1982. return m.OldIsOwner(ctx)
  1983. }
  1984. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1985. }
  1986. // SetField sets the value of a field with the given name. It returns an error if
  1987. // the field is not defined in the schema, or if the type mismatched the field
  1988. // type.
  1989. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1990. switch name {
  1991. case agentbase.FieldQ:
  1992. v, ok := value.(string)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.SetQ(v)
  1997. return nil
  1998. case agentbase.FieldA:
  1999. v, ok := value.(string)
  2000. if !ok {
  2001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2002. }
  2003. m.SetA(v)
  2004. return nil
  2005. case agentbase.FieldChunkIndex:
  2006. v, ok := value.(uint64)
  2007. if !ok {
  2008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2009. }
  2010. m.SetChunkIndex(v)
  2011. return nil
  2012. case agentbase.FieldIndexes:
  2013. v, ok := value.([]string)
  2014. if !ok {
  2015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2016. }
  2017. m.SetIndexes(v)
  2018. return nil
  2019. case agentbase.FieldDatasetID:
  2020. v, ok := value.(string)
  2021. if !ok {
  2022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2023. }
  2024. m.SetDatasetID(v)
  2025. return nil
  2026. case agentbase.FieldCollectionID:
  2027. v, ok := value.(string)
  2028. if !ok {
  2029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2030. }
  2031. m.SetCollectionID(v)
  2032. return nil
  2033. case agentbase.FieldSourceName:
  2034. v, ok := value.(string)
  2035. if !ok {
  2036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2037. }
  2038. m.SetSourceName(v)
  2039. return nil
  2040. case agentbase.FieldCanWrite:
  2041. v, ok := value.([]bool)
  2042. if !ok {
  2043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2044. }
  2045. m.SetCanWrite(v)
  2046. return nil
  2047. case agentbase.FieldIsOwner:
  2048. v, ok := value.([]bool)
  2049. if !ok {
  2050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2051. }
  2052. m.SetIsOwner(v)
  2053. return nil
  2054. }
  2055. return fmt.Errorf("unknown AgentBase field %s", name)
  2056. }
  2057. // AddedFields returns all numeric fields that were incremented/decremented during
  2058. // this mutation.
  2059. func (m *AgentBaseMutation) AddedFields() []string {
  2060. var fields []string
  2061. if m.addchunk_index != nil {
  2062. fields = append(fields, agentbase.FieldChunkIndex)
  2063. }
  2064. return fields
  2065. }
  2066. // AddedField returns the numeric value that was incremented/decremented on a field
  2067. // with the given name. The second boolean return value indicates that this field
  2068. // was not set, or was not defined in the schema.
  2069. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2070. switch name {
  2071. case agentbase.FieldChunkIndex:
  2072. return m.AddedChunkIndex()
  2073. }
  2074. return nil, false
  2075. }
  2076. // AddField adds the value to the field with the given name. It returns an error if
  2077. // the field is not defined in the schema, or if the type mismatched the field
  2078. // type.
  2079. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2080. switch name {
  2081. case agentbase.FieldChunkIndex:
  2082. v, ok := value.(int64)
  2083. if !ok {
  2084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2085. }
  2086. m.AddChunkIndex(v)
  2087. return nil
  2088. }
  2089. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2090. }
  2091. // ClearedFields returns all nullable fields that were cleared during this
  2092. // mutation.
  2093. func (m *AgentBaseMutation) ClearedFields() []string {
  2094. var fields []string
  2095. if m.FieldCleared(agentbase.FieldQ) {
  2096. fields = append(fields, agentbase.FieldQ)
  2097. }
  2098. if m.FieldCleared(agentbase.FieldA) {
  2099. fields = append(fields, agentbase.FieldA)
  2100. }
  2101. if m.FieldCleared(agentbase.FieldIndexes) {
  2102. fields = append(fields, agentbase.FieldIndexes)
  2103. }
  2104. if m.FieldCleared(agentbase.FieldDatasetID) {
  2105. fields = append(fields, agentbase.FieldDatasetID)
  2106. }
  2107. if m.FieldCleared(agentbase.FieldCollectionID) {
  2108. fields = append(fields, agentbase.FieldCollectionID)
  2109. }
  2110. if m.FieldCleared(agentbase.FieldSourceName) {
  2111. fields = append(fields, agentbase.FieldSourceName)
  2112. }
  2113. if m.FieldCleared(agentbase.FieldCanWrite) {
  2114. fields = append(fields, agentbase.FieldCanWrite)
  2115. }
  2116. if m.FieldCleared(agentbase.FieldIsOwner) {
  2117. fields = append(fields, agentbase.FieldIsOwner)
  2118. }
  2119. return fields
  2120. }
  2121. // FieldCleared returns a boolean indicating if a field with the given name was
  2122. // cleared in this mutation.
  2123. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2124. _, ok := m.clearedFields[name]
  2125. return ok
  2126. }
  2127. // ClearField clears the value of the field with the given name. It returns an
  2128. // error if the field is not defined in the schema.
  2129. func (m *AgentBaseMutation) ClearField(name string) error {
  2130. switch name {
  2131. case agentbase.FieldQ:
  2132. m.ClearQ()
  2133. return nil
  2134. case agentbase.FieldA:
  2135. m.ClearA()
  2136. return nil
  2137. case agentbase.FieldIndexes:
  2138. m.ClearIndexes()
  2139. return nil
  2140. case agentbase.FieldDatasetID:
  2141. m.ClearDatasetID()
  2142. return nil
  2143. case agentbase.FieldCollectionID:
  2144. m.ClearCollectionID()
  2145. return nil
  2146. case agentbase.FieldSourceName:
  2147. m.ClearSourceName()
  2148. return nil
  2149. case agentbase.FieldCanWrite:
  2150. m.ClearCanWrite()
  2151. return nil
  2152. case agentbase.FieldIsOwner:
  2153. m.ClearIsOwner()
  2154. return nil
  2155. }
  2156. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2157. }
  2158. // ResetField resets all changes in the mutation for the field with the given name.
  2159. // It returns an error if the field is not defined in the schema.
  2160. func (m *AgentBaseMutation) ResetField(name string) error {
  2161. switch name {
  2162. case agentbase.FieldQ:
  2163. m.ResetQ()
  2164. return nil
  2165. case agentbase.FieldA:
  2166. m.ResetA()
  2167. return nil
  2168. case agentbase.FieldChunkIndex:
  2169. m.ResetChunkIndex()
  2170. return nil
  2171. case agentbase.FieldIndexes:
  2172. m.ResetIndexes()
  2173. return nil
  2174. case agentbase.FieldDatasetID:
  2175. m.ResetDatasetID()
  2176. return nil
  2177. case agentbase.FieldCollectionID:
  2178. m.ResetCollectionID()
  2179. return nil
  2180. case agentbase.FieldSourceName:
  2181. m.ResetSourceName()
  2182. return nil
  2183. case agentbase.FieldCanWrite:
  2184. m.ResetCanWrite()
  2185. return nil
  2186. case agentbase.FieldIsOwner:
  2187. m.ResetIsOwner()
  2188. return nil
  2189. }
  2190. return fmt.Errorf("unknown AgentBase field %s", name)
  2191. }
  2192. // AddedEdges returns all edge names that were set/added in this mutation.
  2193. func (m *AgentBaseMutation) AddedEdges() []string {
  2194. edges := make([]string, 0, 1)
  2195. if m.wx_agent != nil {
  2196. edges = append(edges, agentbase.EdgeWxAgent)
  2197. }
  2198. return edges
  2199. }
  2200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2201. // name in this mutation.
  2202. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2203. switch name {
  2204. case agentbase.EdgeWxAgent:
  2205. ids := make([]ent.Value, 0, len(m.wx_agent))
  2206. for id := range m.wx_agent {
  2207. ids = append(ids, id)
  2208. }
  2209. return ids
  2210. }
  2211. return nil
  2212. }
  2213. // RemovedEdges returns all edge names that were removed in this mutation.
  2214. func (m *AgentBaseMutation) RemovedEdges() []string {
  2215. edges := make([]string, 0, 1)
  2216. if m.removedwx_agent != nil {
  2217. edges = append(edges, agentbase.EdgeWxAgent)
  2218. }
  2219. return edges
  2220. }
  2221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2222. // the given name in this mutation.
  2223. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2224. switch name {
  2225. case agentbase.EdgeWxAgent:
  2226. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2227. for id := range m.removedwx_agent {
  2228. ids = append(ids, id)
  2229. }
  2230. return ids
  2231. }
  2232. return nil
  2233. }
  2234. // ClearedEdges returns all edge names that were cleared in this mutation.
  2235. func (m *AgentBaseMutation) ClearedEdges() []string {
  2236. edges := make([]string, 0, 1)
  2237. if m.clearedwx_agent {
  2238. edges = append(edges, agentbase.EdgeWxAgent)
  2239. }
  2240. return edges
  2241. }
  2242. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2243. // was cleared in this mutation.
  2244. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2245. switch name {
  2246. case agentbase.EdgeWxAgent:
  2247. return m.clearedwx_agent
  2248. }
  2249. return false
  2250. }
  2251. // ClearEdge clears the value of the edge with the given name. It returns an error
  2252. // if that edge is not defined in the schema.
  2253. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2254. switch name {
  2255. }
  2256. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2257. }
  2258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2259. // It returns an error if the edge is not defined in the schema.
  2260. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2261. switch name {
  2262. case agentbase.EdgeWxAgent:
  2263. m.ResetWxAgent()
  2264. return nil
  2265. }
  2266. return fmt.Errorf("unknown AgentBase edge %s", name)
  2267. }
  2268. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2269. type AliyunAvatarMutation struct {
  2270. config
  2271. op Op
  2272. typ string
  2273. id *uint64
  2274. created_at *time.Time
  2275. updated_at *time.Time
  2276. deleted_at *time.Time
  2277. user_id *uint64
  2278. adduser_id *int64
  2279. biz_id *string
  2280. access_key_id *string
  2281. access_key_secret *string
  2282. app_id *string
  2283. tenant_id *uint64
  2284. addtenant_id *int64
  2285. response *string
  2286. token *string
  2287. session_id *string
  2288. clearedFields map[string]struct{}
  2289. done bool
  2290. oldValue func(context.Context) (*AliyunAvatar, error)
  2291. predicates []predicate.AliyunAvatar
  2292. }
  2293. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2294. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2295. type aliyunavatarOption func(*AliyunAvatarMutation)
  2296. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2297. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2298. m := &AliyunAvatarMutation{
  2299. config: c,
  2300. op: op,
  2301. typ: TypeAliyunAvatar,
  2302. clearedFields: make(map[string]struct{}),
  2303. }
  2304. for _, opt := range opts {
  2305. opt(m)
  2306. }
  2307. return m
  2308. }
  2309. // withAliyunAvatarID sets the ID field of the mutation.
  2310. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2311. return func(m *AliyunAvatarMutation) {
  2312. var (
  2313. err error
  2314. once sync.Once
  2315. value *AliyunAvatar
  2316. )
  2317. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2318. once.Do(func() {
  2319. if m.done {
  2320. err = errors.New("querying old values post mutation is not allowed")
  2321. } else {
  2322. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2323. }
  2324. })
  2325. return value, err
  2326. }
  2327. m.id = &id
  2328. }
  2329. }
  2330. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2331. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2332. return func(m *AliyunAvatarMutation) {
  2333. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2334. return node, nil
  2335. }
  2336. m.id = &node.ID
  2337. }
  2338. }
  2339. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2340. // executed in a transaction (ent.Tx), a transactional client is returned.
  2341. func (m AliyunAvatarMutation) Client() *Client {
  2342. client := &Client{config: m.config}
  2343. client.init()
  2344. return client
  2345. }
  2346. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2347. // it returns an error otherwise.
  2348. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2349. if _, ok := m.driver.(*txDriver); !ok {
  2350. return nil, errors.New("ent: mutation is not running in a transaction")
  2351. }
  2352. tx := &Tx{config: m.config}
  2353. tx.init()
  2354. return tx, nil
  2355. }
  2356. // SetID sets the value of the id field. Note that this
  2357. // operation is only accepted on creation of AliyunAvatar entities.
  2358. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2359. m.id = &id
  2360. }
  2361. // ID returns the ID value in the mutation. Note that the ID is only available
  2362. // if it was provided to the builder or after it was returned from the database.
  2363. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2364. if m.id == nil {
  2365. return
  2366. }
  2367. return *m.id, true
  2368. }
  2369. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2370. // That means, if the mutation is applied within a transaction with an isolation level such
  2371. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2372. // or updated by the mutation.
  2373. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2374. switch {
  2375. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2376. id, exists := m.ID()
  2377. if exists {
  2378. return []uint64{id}, nil
  2379. }
  2380. fallthrough
  2381. case m.op.Is(OpUpdate | OpDelete):
  2382. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2383. default:
  2384. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2385. }
  2386. }
  2387. // SetCreatedAt sets the "created_at" field.
  2388. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2389. m.created_at = &t
  2390. }
  2391. // CreatedAt returns the value of the "created_at" field in the mutation.
  2392. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2393. v := m.created_at
  2394. if v == nil {
  2395. return
  2396. }
  2397. return *v, true
  2398. }
  2399. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2400. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2402. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2403. if !m.op.Is(OpUpdateOne) {
  2404. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2405. }
  2406. if m.id == nil || m.oldValue == nil {
  2407. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2408. }
  2409. oldValue, err := m.oldValue(ctx)
  2410. if err != nil {
  2411. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2412. }
  2413. return oldValue.CreatedAt, nil
  2414. }
  2415. // ResetCreatedAt resets all changes to the "created_at" field.
  2416. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2417. m.created_at = nil
  2418. }
  2419. // SetUpdatedAt sets the "updated_at" field.
  2420. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2421. m.updated_at = &t
  2422. }
  2423. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2424. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2425. v := m.updated_at
  2426. if v == nil {
  2427. return
  2428. }
  2429. return *v, true
  2430. }
  2431. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2432. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2434. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2435. if !m.op.Is(OpUpdateOne) {
  2436. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2437. }
  2438. if m.id == nil || m.oldValue == nil {
  2439. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2440. }
  2441. oldValue, err := m.oldValue(ctx)
  2442. if err != nil {
  2443. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2444. }
  2445. return oldValue.UpdatedAt, nil
  2446. }
  2447. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2448. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2449. m.updated_at = nil
  2450. }
  2451. // SetDeletedAt sets the "deleted_at" field.
  2452. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2453. m.deleted_at = &t
  2454. }
  2455. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2456. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2457. v := m.deleted_at
  2458. if v == nil {
  2459. return
  2460. }
  2461. return *v, true
  2462. }
  2463. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2464. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2466. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2467. if !m.op.Is(OpUpdateOne) {
  2468. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2469. }
  2470. if m.id == nil || m.oldValue == nil {
  2471. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2472. }
  2473. oldValue, err := m.oldValue(ctx)
  2474. if err != nil {
  2475. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2476. }
  2477. return oldValue.DeletedAt, nil
  2478. }
  2479. // ClearDeletedAt clears the value of the "deleted_at" field.
  2480. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2481. m.deleted_at = nil
  2482. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2483. }
  2484. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2485. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2486. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2487. return ok
  2488. }
  2489. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2490. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2491. m.deleted_at = nil
  2492. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2493. }
  2494. // SetUserID sets the "user_id" field.
  2495. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2496. m.user_id = &u
  2497. m.adduser_id = nil
  2498. }
  2499. // UserID returns the value of the "user_id" field in the mutation.
  2500. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2501. v := m.user_id
  2502. if v == nil {
  2503. return
  2504. }
  2505. return *v, true
  2506. }
  2507. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2508. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2510. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2511. if !m.op.Is(OpUpdateOne) {
  2512. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2513. }
  2514. if m.id == nil || m.oldValue == nil {
  2515. return v, errors.New("OldUserID requires an ID field in the mutation")
  2516. }
  2517. oldValue, err := m.oldValue(ctx)
  2518. if err != nil {
  2519. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2520. }
  2521. return oldValue.UserID, nil
  2522. }
  2523. // AddUserID adds u to the "user_id" field.
  2524. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2525. if m.adduser_id != nil {
  2526. *m.adduser_id += u
  2527. } else {
  2528. m.adduser_id = &u
  2529. }
  2530. }
  2531. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2532. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2533. v := m.adduser_id
  2534. if v == nil {
  2535. return
  2536. }
  2537. return *v, true
  2538. }
  2539. // ResetUserID resets all changes to the "user_id" field.
  2540. func (m *AliyunAvatarMutation) ResetUserID() {
  2541. m.user_id = nil
  2542. m.adduser_id = nil
  2543. }
  2544. // SetBizID sets the "biz_id" field.
  2545. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2546. m.biz_id = &s
  2547. }
  2548. // BizID returns the value of the "biz_id" field in the mutation.
  2549. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2550. v := m.biz_id
  2551. if v == nil {
  2552. return
  2553. }
  2554. return *v, true
  2555. }
  2556. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2557. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2559. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2560. if !m.op.Is(OpUpdateOne) {
  2561. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2562. }
  2563. if m.id == nil || m.oldValue == nil {
  2564. return v, errors.New("OldBizID requires an ID field in the mutation")
  2565. }
  2566. oldValue, err := m.oldValue(ctx)
  2567. if err != nil {
  2568. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2569. }
  2570. return oldValue.BizID, nil
  2571. }
  2572. // ResetBizID resets all changes to the "biz_id" field.
  2573. func (m *AliyunAvatarMutation) ResetBizID() {
  2574. m.biz_id = nil
  2575. }
  2576. // SetAccessKeyID sets the "access_key_id" field.
  2577. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2578. m.access_key_id = &s
  2579. }
  2580. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2581. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2582. v := m.access_key_id
  2583. if v == nil {
  2584. return
  2585. }
  2586. return *v, true
  2587. }
  2588. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2589. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2591. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2592. if !m.op.Is(OpUpdateOne) {
  2593. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2594. }
  2595. if m.id == nil || m.oldValue == nil {
  2596. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2597. }
  2598. oldValue, err := m.oldValue(ctx)
  2599. if err != nil {
  2600. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2601. }
  2602. return oldValue.AccessKeyID, nil
  2603. }
  2604. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2605. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2606. m.access_key_id = nil
  2607. }
  2608. // SetAccessKeySecret sets the "access_key_secret" field.
  2609. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2610. m.access_key_secret = &s
  2611. }
  2612. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2613. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2614. v := m.access_key_secret
  2615. if v == nil {
  2616. return
  2617. }
  2618. return *v, true
  2619. }
  2620. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2621. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2623. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2624. if !m.op.Is(OpUpdateOne) {
  2625. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2626. }
  2627. if m.id == nil || m.oldValue == nil {
  2628. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2629. }
  2630. oldValue, err := m.oldValue(ctx)
  2631. if err != nil {
  2632. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2633. }
  2634. return oldValue.AccessKeySecret, nil
  2635. }
  2636. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2637. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2638. m.access_key_secret = nil
  2639. }
  2640. // SetAppID sets the "app_id" field.
  2641. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2642. m.app_id = &s
  2643. }
  2644. // AppID returns the value of the "app_id" field in the mutation.
  2645. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2646. v := m.app_id
  2647. if v == nil {
  2648. return
  2649. }
  2650. return *v, true
  2651. }
  2652. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2653. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2655. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2656. if !m.op.Is(OpUpdateOne) {
  2657. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2658. }
  2659. if m.id == nil || m.oldValue == nil {
  2660. return v, errors.New("OldAppID requires an ID field in the mutation")
  2661. }
  2662. oldValue, err := m.oldValue(ctx)
  2663. if err != nil {
  2664. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2665. }
  2666. return oldValue.AppID, nil
  2667. }
  2668. // ClearAppID clears the value of the "app_id" field.
  2669. func (m *AliyunAvatarMutation) ClearAppID() {
  2670. m.app_id = nil
  2671. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2672. }
  2673. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2674. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2675. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2676. return ok
  2677. }
  2678. // ResetAppID resets all changes to the "app_id" field.
  2679. func (m *AliyunAvatarMutation) ResetAppID() {
  2680. m.app_id = nil
  2681. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2682. }
  2683. // SetTenantID sets the "tenant_id" field.
  2684. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2685. m.tenant_id = &u
  2686. m.addtenant_id = nil
  2687. }
  2688. // TenantID returns the value of the "tenant_id" field in the mutation.
  2689. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2690. v := m.tenant_id
  2691. if v == nil {
  2692. return
  2693. }
  2694. return *v, true
  2695. }
  2696. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2697. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2699. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2700. if !m.op.Is(OpUpdateOne) {
  2701. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2702. }
  2703. if m.id == nil || m.oldValue == nil {
  2704. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2705. }
  2706. oldValue, err := m.oldValue(ctx)
  2707. if err != nil {
  2708. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2709. }
  2710. return oldValue.TenantID, nil
  2711. }
  2712. // AddTenantID adds u to the "tenant_id" field.
  2713. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2714. if m.addtenant_id != nil {
  2715. *m.addtenant_id += u
  2716. } else {
  2717. m.addtenant_id = &u
  2718. }
  2719. }
  2720. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2721. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2722. v := m.addtenant_id
  2723. if v == nil {
  2724. return
  2725. }
  2726. return *v, true
  2727. }
  2728. // ResetTenantID resets all changes to the "tenant_id" field.
  2729. func (m *AliyunAvatarMutation) ResetTenantID() {
  2730. m.tenant_id = nil
  2731. m.addtenant_id = nil
  2732. }
  2733. // SetResponse sets the "response" field.
  2734. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2735. m.response = &s
  2736. }
  2737. // Response returns the value of the "response" field in the mutation.
  2738. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2739. v := m.response
  2740. if v == nil {
  2741. return
  2742. }
  2743. return *v, true
  2744. }
  2745. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2746. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2748. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2749. if !m.op.Is(OpUpdateOne) {
  2750. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2751. }
  2752. if m.id == nil || m.oldValue == nil {
  2753. return v, errors.New("OldResponse requires an ID field in the mutation")
  2754. }
  2755. oldValue, err := m.oldValue(ctx)
  2756. if err != nil {
  2757. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2758. }
  2759. return oldValue.Response, nil
  2760. }
  2761. // ResetResponse resets all changes to the "response" field.
  2762. func (m *AliyunAvatarMutation) ResetResponse() {
  2763. m.response = nil
  2764. }
  2765. // SetToken sets the "token" field.
  2766. func (m *AliyunAvatarMutation) SetToken(s string) {
  2767. m.token = &s
  2768. }
  2769. // Token returns the value of the "token" field in the mutation.
  2770. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2771. v := m.token
  2772. if v == nil {
  2773. return
  2774. }
  2775. return *v, true
  2776. }
  2777. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2778. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2780. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2781. if !m.op.Is(OpUpdateOne) {
  2782. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2783. }
  2784. if m.id == nil || m.oldValue == nil {
  2785. return v, errors.New("OldToken requires an ID field in the mutation")
  2786. }
  2787. oldValue, err := m.oldValue(ctx)
  2788. if err != nil {
  2789. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2790. }
  2791. return oldValue.Token, nil
  2792. }
  2793. // ResetToken resets all changes to the "token" field.
  2794. func (m *AliyunAvatarMutation) ResetToken() {
  2795. m.token = nil
  2796. }
  2797. // SetSessionID sets the "session_id" field.
  2798. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2799. m.session_id = &s
  2800. }
  2801. // SessionID returns the value of the "session_id" field in the mutation.
  2802. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2803. v := m.session_id
  2804. if v == nil {
  2805. return
  2806. }
  2807. return *v, true
  2808. }
  2809. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2810. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2812. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2813. if !m.op.Is(OpUpdateOne) {
  2814. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2815. }
  2816. if m.id == nil || m.oldValue == nil {
  2817. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2818. }
  2819. oldValue, err := m.oldValue(ctx)
  2820. if err != nil {
  2821. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2822. }
  2823. return oldValue.SessionID, nil
  2824. }
  2825. // ResetSessionID resets all changes to the "session_id" field.
  2826. func (m *AliyunAvatarMutation) ResetSessionID() {
  2827. m.session_id = nil
  2828. }
  2829. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2830. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2831. m.predicates = append(m.predicates, ps...)
  2832. }
  2833. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2834. // users can use type-assertion to append predicates that do not depend on any generated package.
  2835. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2836. p := make([]predicate.AliyunAvatar, len(ps))
  2837. for i := range ps {
  2838. p[i] = ps[i]
  2839. }
  2840. m.Where(p...)
  2841. }
  2842. // Op returns the operation name.
  2843. func (m *AliyunAvatarMutation) Op() Op {
  2844. return m.op
  2845. }
  2846. // SetOp allows setting the mutation operation.
  2847. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2848. m.op = op
  2849. }
  2850. // Type returns the node type of this mutation (AliyunAvatar).
  2851. func (m *AliyunAvatarMutation) Type() string {
  2852. return m.typ
  2853. }
  2854. // Fields returns all fields that were changed during this mutation. Note that in
  2855. // order to get all numeric fields that were incremented/decremented, call
  2856. // AddedFields().
  2857. func (m *AliyunAvatarMutation) Fields() []string {
  2858. fields := make([]string, 0, 12)
  2859. if m.created_at != nil {
  2860. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2861. }
  2862. if m.updated_at != nil {
  2863. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2864. }
  2865. if m.deleted_at != nil {
  2866. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2867. }
  2868. if m.user_id != nil {
  2869. fields = append(fields, aliyunavatar.FieldUserID)
  2870. }
  2871. if m.biz_id != nil {
  2872. fields = append(fields, aliyunavatar.FieldBizID)
  2873. }
  2874. if m.access_key_id != nil {
  2875. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2876. }
  2877. if m.access_key_secret != nil {
  2878. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2879. }
  2880. if m.app_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldAppID)
  2882. }
  2883. if m.tenant_id != nil {
  2884. fields = append(fields, aliyunavatar.FieldTenantID)
  2885. }
  2886. if m.response != nil {
  2887. fields = append(fields, aliyunavatar.FieldResponse)
  2888. }
  2889. if m.token != nil {
  2890. fields = append(fields, aliyunavatar.FieldToken)
  2891. }
  2892. if m.session_id != nil {
  2893. fields = append(fields, aliyunavatar.FieldSessionID)
  2894. }
  2895. return fields
  2896. }
  2897. // Field returns the value of a field with the given name. The second boolean
  2898. // return value indicates that this field was not set, or was not defined in the
  2899. // schema.
  2900. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2901. switch name {
  2902. case aliyunavatar.FieldCreatedAt:
  2903. return m.CreatedAt()
  2904. case aliyunavatar.FieldUpdatedAt:
  2905. return m.UpdatedAt()
  2906. case aliyunavatar.FieldDeletedAt:
  2907. return m.DeletedAt()
  2908. case aliyunavatar.FieldUserID:
  2909. return m.UserID()
  2910. case aliyunavatar.FieldBizID:
  2911. return m.BizID()
  2912. case aliyunavatar.FieldAccessKeyID:
  2913. return m.AccessKeyID()
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. return m.AccessKeySecret()
  2916. case aliyunavatar.FieldAppID:
  2917. return m.AppID()
  2918. case aliyunavatar.FieldTenantID:
  2919. return m.TenantID()
  2920. case aliyunavatar.FieldResponse:
  2921. return m.Response()
  2922. case aliyunavatar.FieldToken:
  2923. return m.Token()
  2924. case aliyunavatar.FieldSessionID:
  2925. return m.SessionID()
  2926. }
  2927. return nil, false
  2928. }
  2929. // OldField returns the old value of the field from the database. An error is
  2930. // returned if the mutation operation is not UpdateOne, or the query to the
  2931. // database failed.
  2932. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2933. switch name {
  2934. case aliyunavatar.FieldCreatedAt:
  2935. return m.OldCreatedAt(ctx)
  2936. case aliyunavatar.FieldUpdatedAt:
  2937. return m.OldUpdatedAt(ctx)
  2938. case aliyunavatar.FieldDeletedAt:
  2939. return m.OldDeletedAt(ctx)
  2940. case aliyunavatar.FieldUserID:
  2941. return m.OldUserID(ctx)
  2942. case aliyunavatar.FieldBizID:
  2943. return m.OldBizID(ctx)
  2944. case aliyunavatar.FieldAccessKeyID:
  2945. return m.OldAccessKeyID(ctx)
  2946. case aliyunavatar.FieldAccessKeySecret:
  2947. return m.OldAccessKeySecret(ctx)
  2948. case aliyunavatar.FieldAppID:
  2949. return m.OldAppID(ctx)
  2950. case aliyunavatar.FieldTenantID:
  2951. return m.OldTenantID(ctx)
  2952. case aliyunavatar.FieldResponse:
  2953. return m.OldResponse(ctx)
  2954. case aliyunavatar.FieldToken:
  2955. return m.OldToken(ctx)
  2956. case aliyunavatar.FieldSessionID:
  2957. return m.OldSessionID(ctx)
  2958. }
  2959. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2960. }
  2961. // SetField sets the value of a field with the given name. It returns an error if
  2962. // the field is not defined in the schema, or if the type mismatched the field
  2963. // type.
  2964. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2965. switch name {
  2966. case aliyunavatar.FieldCreatedAt:
  2967. v, ok := value.(time.Time)
  2968. if !ok {
  2969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2970. }
  2971. m.SetCreatedAt(v)
  2972. return nil
  2973. case aliyunavatar.FieldUpdatedAt:
  2974. v, ok := value.(time.Time)
  2975. if !ok {
  2976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2977. }
  2978. m.SetUpdatedAt(v)
  2979. return nil
  2980. case aliyunavatar.FieldDeletedAt:
  2981. v, ok := value.(time.Time)
  2982. if !ok {
  2983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2984. }
  2985. m.SetDeletedAt(v)
  2986. return nil
  2987. case aliyunavatar.FieldUserID:
  2988. v, ok := value.(uint64)
  2989. if !ok {
  2990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2991. }
  2992. m.SetUserID(v)
  2993. return nil
  2994. case aliyunavatar.FieldBizID:
  2995. v, ok := value.(string)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.SetBizID(v)
  3000. return nil
  3001. case aliyunavatar.FieldAccessKeyID:
  3002. v, ok := value.(string)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.SetAccessKeyID(v)
  3007. return nil
  3008. case aliyunavatar.FieldAccessKeySecret:
  3009. v, ok := value.(string)
  3010. if !ok {
  3011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3012. }
  3013. m.SetAccessKeySecret(v)
  3014. return nil
  3015. case aliyunavatar.FieldAppID:
  3016. v, ok := value.(string)
  3017. if !ok {
  3018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3019. }
  3020. m.SetAppID(v)
  3021. return nil
  3022. case aliyunavatar.FieldTenantID:
  3023. v, ok := value.(uint64)
  3024. if !ok {
  3025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3026. }
  3027. m.SetTenantID(v)
  3028. return nil
  3029. case aliyunavatar.FieldResponse:
  3030. v, ok := value.(string)
  3031. if !ok {
  3032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3033. }
  3034. m.SetResponse(v)
  3035. return nil
  3036. case aliyunavatar.FieldToken:
  3037. v, ok := value.(string)
  3038. if !ok {
  3039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3040. }
  3041. m.SetToken(v)
  3042. return nil
  3043. case aliyunavatar.FieldSessionID:
  3044. v, ok := value.(string)
  3045. if !ok {
  3046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3047. }
  3048. m.SetSessionID(v)
  3049. return nil
  3050. }
  3051. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3052. }
  3053. // AddedFields returns all numeric fields that were incremented/decremented during
  3054. // this mutation.
  3055. func (m *AliyunAvatarMutation) AddedFields() []string {
  3056. var fields []string
  3057. if m.adduser_id != nil {
  3058. fields = append(fields, aliyunavatar.FieldUserID)
  3059. }
  3060. if m.addtenant_id != nil {
  3061. fields = append(fields, aliyunavatar.FieldTenantID)
  3062. }
  3063. return fields
  3064. }
  3065. // AddedField returns the numeric value that was incremented/decremented on a field
  3066. // with the given name. The second boolean return value indicates that this field
  3067. // was not set, or was not defined in the schema.
  3068. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3069. switch name {
  3070. case aliyunavatar.FieldUserID:
  3071. return m.AddedUserID()
  3072. case aliyunavatar.FieldTenantID:
  3073. return m.AddedTenantID()
  3074. }
  3075. return nil, false
  3076. }
  3077. // AddField adds the value to the field with the given name. It returns an error if
  3078. // the field is not defined in the schema, or if the type mismatched the field
  3079. // type.
  3080. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3081. switch name {
  3082. case aliyunavatar.FieldUserID:
  3083. v, ok := value.(int64)
  3084. if !ok {
  3085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3086. }
  3087. m.AddUserID(v)
  3088. return nil
  3089. case aliyunavatar.FieldTenantID:
  3090. v, ok := value.(int64)
  3091. if !ok {
  3092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3093. }
  3094. m.AddTenantID(v)
  3095. return nil
  3096. }
  3097. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3098. }
  3099. // ClearedFields returns all nullable fields that were cleared during this
  3100. // mutation.
  3101. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3102. var fields []string
  3103. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3104. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3105. }
  3106. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3107. fields = append(fields, aliyunavatar.FieldAppID)
  3108. }
  3109. return fields
  3110. }
  3111. // FieldCleared returns a boolean indicating if a field with the given name was
  3112. // cleared in this mutation.
  3113. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3114. _, ok := m.clearedFields[name]
  3115. return ok
  3116. }
  3117. // ClearField clears the value of the field with the given name. It returns an
  3118. // error if the field is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3120. switch name {
  3121. case aliyunavatar.FieldDeletedAt:
  3122. m.ClearDeletedAt()
  3123. return nil
  3124. case aliyunavatar.FieldAppID:
  3125. m.ClearAppID()
  3126. return nil
  3127. }
  3128. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3129. }
  3130. // ResetField resets all changes in the mutation for the field with the given name.
  3131. // It returns an error if the field is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3133. switch name {
  3134. case aliyunavatar.FieldCreatedAt:
  3135. m.ResetCreatedAt()
  3136. return nil
  3137. case aliyunavatar.FieldUpdatedAt:
  3138. m.ResetUpdatedAt()
  3139. return nil
  3140. case aliyunavatar.FieldDeletedAt:
  3141. m.ResetDeletedAt()
  3142. return nil
  3143. case aliyunavatar.FieldUserID:
  3144. m.ResetUserID()
  3145. return nil
  3146. case aliyunavatar.FieldBizID:
  3147. m.ResetBizID()
  3148. return nil
  3149. case aliyunavatar.FieldAccessKeyID:
  3150. m.ResetAccessKeyID()
  3151. return nil
  3152. case aliyunavatar.FieldAccessKeySecret:
  3153. m.ResetAccessKeySecret()
  3154. return nil
  3155. case aliyunavatar.FieldAppID:
  3156. m.ResetAppID()
  3157. return nil
  3158. case aliyunavatar.FieldTenantID:
  3159. m.ResetTenantID()
  3160. return nil
  3161. case aliyunavatar.FieldResponse:
  3162. m.ResetResponse()
  3163. return nil
  3164. case aliyunavatar.FieldToken:
  3165. m.ResetToken()
  3166. return nil
  3167. case aliyunavatar.FieldSessionID:
  3168. m.ResetSessionID()
  3169. return nil
  3170. }
  3171. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3172. }
  3173. // AddedEdges returns all edge names that were set/added in this mutation.
  3174. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3175. edges := make([]string, 0, 0)
  3176. return edges
  3177. }
  3178. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3179. // name in this mutation.
  3180. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3181. return nil
  3182. }
  3183. // RemovedEdges returns all edge names that were removed in this mutation.
  3184. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3185. edges := make([]string, 0, 0)
  3186. return edges
  3187. }
  3188. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3189. // the given name in this mutation.
  3190. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3191. return nil
  3192. }
  3193. // ClearedEdges returns all edge names that were cleared in this mutation.
  3194. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3195. edges := make([]string, 0, 0)
  3196. return edges
  3197. }
  3198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3199. // was cleared in this mutation.
  3200. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3201. return false
  3202. }
  3203. // ClearEdge clears the value of the edge with the given name. It returns an error
  3204. // if that edge is not defined in the schema.
  3205. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3206. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3207. }
  3208. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3209. // It returns an error if the edge is not defined in the schema.
  3210. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3211. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3212. }
  3213. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3214. type AllocAgentMutation struct {
  3215. config
  3216. op Op
  3217. typ string
  3218. id *uint64
  3219. created_at *time.Time
  3220. updated_at *time.Time
  3221. deleted_at *time.Time
  3222. user_id *string
  3223. organization_id *uint64
  3224. addorganization_id *int64
  3225. agents *[]uint64
  3226. appendagents []uint64
  3227. status *int
  3228. addstatus *int
  3229. clearedFields map[string]struct{}
  3230. done bool
  3231. oldValue func(context.Context) (*AllocAgent, error)
  3232. predicates []predicate.AllocAgent
  3233. }
  3234. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3235. // allocagentOption allows management of the mutation configuration using functional options.
  3236. type allocagentOption func(*AllocAgentMutation)
  3237. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3238. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3239. m := &AllocAgentMutation{
  3240. config: c,
  3241. op: op,
  3242. typ: TypeAllocAgent,
  3243. clearedFields: make(map[string]struct{}),
  3244. }
  3245. for _, opt := range opts {
  3246. opt(m)
  3247. }
  3248. return m
  3249. }
  3250. // withAllocAgentID sets the ID field of the mutation.
  3251. func withAllocAgentID(id uint64) allocagentOption {
  3252. return func(m *AllocAgentMutation) {
  3253. var (
  3254. err error
  3255. once sync.Once
  3256. value *AllocAgent
  3257. )
  3258. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3259. once.Do(func() {
  3260. if m.done {
  3261. err = errors.New("querying old values post mutation is not allowed")
  3262. } else {
  3263. value, err = m.Client().AllocAgent.Get(ctx, id)
  3264. }
  3265. })
  3266. return value, err
  3267. }
  3268. m.id = &id
  3269. }
  3270. }
  3271. // withAllocAgent sets the old AllocAgent of the mutation.
  3272. func withAllocAgent(node *AllocAgent) allocagentOption {
  3273. return func(m *AllocAgentMutation) {
  3274. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3275. return node, nil
  3276. }
  3277. m.id = &node.ID
  3278. }
  3279. }
  3280. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3281. // executed in a transaction (ent.Tx), a transactional client is returned.
  3282. func (m AllocAgentMutation) Client() *Client {
  3283. client := &Client{config: m.config}
  3284. client.init()
  3285. return client
  3286. }
  3287. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3288. // it returns an error otherwise.
  3289. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3290. if _, ok := m.driver.(*txDriver); !ok {
  3291. return nil, errors.New("ent: mutation is not running in a transaction")
  3292. }
  3293. tx := &Tx{config: m.config}
  3294. tx.init()
  3295. return tx, nil
  3296. }
  3297. // SetID sets the value of the id field. Note that this
  3298. // operation is only accepted on creation of AllocAgent entities.
  3299. func (m *AllocAgentMutation) SetID(id uint64) {
  3300. m.id = &id
  3301. }
  3302. // ID returns the ID value in the mutation. Note that the ID is only available
  3303. // if it was provided to the builder or after it was returned from the database.
  3304. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3305. if m.id == nil {
  3306. return
  3307. }
  3308. return *m.id, true
  3309. }
  3310. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3311. // That means, if the mutation is applied within a transaction with an isolation level such
  3312. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3313. // or updated by the mutation.
  3314. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3315. switch {
  3316. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3317. id, exists := m.ID()
  3318. if exists {
  3319. return []uint64{id}, nil
  3320. }
  3321. fallthrough
  3322. case m.op.Is(OpUpdate | OpDelete):
  3323. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3324. default:
  3325. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3326. }
  3327. }
  3328. // SetCreatedAt sets the "created_at" field.
  3329. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3330. m.created_at = &t
  3331. }
  3332. // CreatedAt returns the value of the "created_at" field in the mutation.
  3333. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3334. v := m.created_at
  3335. if v == nil {
  3336. return
  3337. }
  3338. return *v, true
  3339. }
  3340. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3341. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3343. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3344. if !m.op.Is(OpUpdateOne) {
  3345. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3346. }
  3347. if m.id == nil || m.oldValue == nil {
  3348. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3349. }
  3350. oldValue, err := m.oldValue(ctx)
  3351. if err != nil {
  3352. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3353. }
  3354. return oldValue.CreatedAt, nil
  3355. }
  3356. // ResetCreatedAt resets all changes to the "created_at" field.
  3357. func (m *AllocAgentMutation) ResetCreatedAt() {
  3358. m.created_at = nil
  3359. }
  3360. // SetUpdatedAt sets the "updated_at" field.
  3361. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3362. m.updated_at = &t
  3363. }
  3364. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3365. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3366. v := m.updated_at
  3367. if v == nil {
  3368. return
  3369. }
  3370. return *v, true
  3371. }
  3372. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3373. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3375. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3376. if !m.op.Is(OpUpdateOne) {
  3377. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3378. }
  3379. if m.id == nil || m.oldValue == nil {
  3380. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3381. }
  3382. oldValue, err := m.oldValue(ctx)
  3383. if err != nil {
  3384. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3385. }
  3386. return oldValue.UpdatedAt, nil
  3387. }
  3388. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3389. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3390. m.updated_at = nil
  3391. }
  3392. // SetDeletedAt sets the "deleted_at" field.
  3393. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3394. m.deleted_at = &t
  3395. }
  3396. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3397. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3398. v := m.deleted_at
  3399. if v == nil {
  3400. return
  3401. }
  3402. return *v, true
  3403. }
  3404. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3405. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3407. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3408. if !m.op.Is(OpUpdateOne) {
  3409. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3410. }
  3411. if m.id == nil || m.oldValue == nil {
  3412. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3413. }
  3414. oldValue, err := m.oldValue(ctx)
  3415. if err != nil {
  3416. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3417. }
  3418. return oldValue.DeletedAt, nil
  3419. }
  3420. // ClearDeletedAt clears the value of the "deleted_at" field.
  3421. func (m *AllocAgentMutation) ClearDeletedAt() {
  3422. m.deleted_at = nil
  3423. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3424. }
  3425. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3426. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3427. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3428. return ok
  3429. }
  3430. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3431. func (m *AllocAgentMutation) ResetDeletedAt() {
  3432. m.deleted_at = nil
  3433. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3434. }
  3435. // SetUserID sets the "user_id" field.
  3436. func (m *AllocAgentMutation) SetUserID(s string) {
  3437. m.user_id = &s
  3438. }
  3439. // UserID returns the value of the "user_id" field in the mutation.
  3440. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3441. v := m.user_id
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3448. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldUserID requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3460. }
  3461. return oldValue.UserID, nil
  3462. }
  3463. // ClearUserID clears the value of the "user_id" field.
  3464. func (m *AllocAgentMutation) ClearUserID() {
  3465. m.user_id = nil
  3466. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3467. }
  3468. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3469. func (m *AllocAgentMutation) UserIDCleared() bool {
  3470. _, ok := m.clearedFields[allocagent.FieldUserID]
  3471. return ok
  3472. }
  3473. // ResetUserID resets all changes to the "user_id" field.
  3474. func (m *AllocAgentMutation) ResetUserID() {
  3475. m.user_id = nil
  3476. delete(m.clearedFields, allocagent.FieldUserID)
  3477. }
  3478. // SetOrganizationID sets the "organization_id" field.
  3479. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3480. m.organization_id = &u
  3481. m.addorganization_id = nil
  3482. }
  3483. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3484. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3485. v := m.organization_id
  3486. if v == nil {
  3487. return
  3488. }
  3489. return *v, true
  3490. }
  3491. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3492. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3494. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3495. if !m.op.Is(OpUpdateOne) {
  3496. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3497. }
  3498. if m.id == nil || m.oldValue == nil {
  3499. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3500. }
  3501. oldValue, err := m.oldValue(ctx)
  3502. if err != nil {
  3503. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3504. }
  3505. return oldValue.OrganizationID, nil
  3506. }
  3507. // AddOrganizationID adds u to the "organization_id" field.
  3508. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3509. if m.addorganization_id != nil {
  3510. *m.addorganization_id += u
  3511. } else {
  3512. m.addorganization_id = &u
  3513. }
  3514. }
  3515. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3516. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3517. v := m.addorganization_id
  3518. if v == nil {
  3519. return
  3520. }
  3521. return *v, true
  3522. }
  3523. // ClearOrganizationID clears the value of the "organization_id" field.
  3524. func (m *AllocAgentMutation) ClearOrganizationID() {
  3525. m.organization_id = nil
  3526. m.addorganization_id = nil
  3527. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3528. }
  3529. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3530. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3531. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3532. return ok
  3533. }
  3534. // ResetOrganizationID resets all changes to the "organization_id" field.
  3535. func (m *AllocAgentMutation) ResetOrganizationID() {
  3536. m.organization_id = nil
  3537. m.addorganization_id = nil
  3538. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3539. }
  3540. // SetAgents sets the "agents" field.
  3541. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3542. m.agents = &u
  3543. m.appendagents = nil
  3544. }
  3545. // Agents returns the value of the "agents" field in the mutation.
  3546. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3547. v := m.agents
  3548. if v == nil {
  3549. return
  3550. }
  3551. return *v, true
  3552. }
  3553. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3554. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3556. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3557. if !m.op.Is(OpUpdateOne) {
  3558. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3559. }
  3560. if m.id == nil || m.oldValue == nil {
  3561. return v, errors.New("OldAgents requires an ID field in the mutation")
  3562. }
  3563. oldValue, err := m.oldValue(ctx)
  3564. if err != nil {
  3565. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3566. }
  3567. return oldValue.Agents, nil
  3568. }
  3569. // AppendAgents adds u to the "agents" field.
  3570. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3571. m.appendagents = append(m.appendagents, u...)
  3572. }
  3573. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3574. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3575. if len(m.appendagents) == 0 {
  3576. return nil, false
  3577. }
  3578. return m.appendagents, true
  3579. }
  3580. // ResetAgents resets all changes to the "agents" field.
  3581. func (m *AllocAgentMutation) ResetAgents() {
  3582. m.agents = nil
  3583. m.appendagents = nil
  3584. }
  3585. // SetStatus sets the "status" field.
  3586. func (m *AllocAgentMutation) SetStatus(i int) {
  3587. m.status = &i
  3588. m.addstatus = nil
  3589. }
  3590. // Status returns the value of the "status" field in the mutation.
  3591. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3592. v := m.status
  3593. if v == nil {
  3594. return
  3595. }
  3596. return *v, true
  3597. }
  3598. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3599. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3601. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3602. if !m.op.Is(OpUpdateOne) {
  3603. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3604. }
  3605. if m.id == nil || m.oldValue == nil {
  3606. return v, errors.New("OldStatus requires an ID field in the mutation")
  3607. }
  3608. oldValue, err := m.oldValue(ctx)
  3609. if err != nil {
  3610. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3611. }
  3612. return oldValue.Status, nil
  3613. }
  3614. // AddStatus adds i to the "status" field.
  3615. func (m *AllocAgentMutation) AddStatus(i int) {
  3616. if m.addstatus != nil {
  3617. *m.addstatus += i
  3618. } else {
  3619. m.addstatus = &i
  3620. }
  3621. }
  3622. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3623. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3624. v := m.addstatus
  3625. if v == nil {
  3626. return
  3627. }
  3628. return *v, true
  3629. }
  3630. // ClearStatus clears the value of the "status" field.
  3631. func (m *AllocAgentMutation) ClearStatus() {
  3632. m.status = nil
  3633. m.addstatus = nil
  3634. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3635. }
  3636. // StatusCleared returns if the "status" field was cleared in this mutation.
  3637. func (m *AllocAgentMutation) StatusCleared() bool {
  3638. _, ok := m.clearedFields[allocagent.FieldStatus]
  3639. return ok
  3640. }
  3641. // ResetStatus resets all changes to the "status" field.
  3642. func (m *AllocAgentMutation) ResetStatus() {
  3643. m.status = nil
  3644. m.addstatus = nil
  3645. delete(m.clearedFields, allocagent.FieldStatus)
  3646. }
  3647. // Where appends a list predicates to the AllocAgentMutation builder.
  3648. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3649. m.predicates = append(m.predicates, ps...)
  3650. }
  3651. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3652. // users can use type-assertion to append predicates that do not depend on any generated package.
  3653. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3654. p := make([]predicate.AllocAgent, len(ps))
  3655. for i := range ps {
  3656. p[i] = ps[i]
  3657. }
  3658. m.Where(p...)
  3659. }
  3660. // Op returns the operation name.
  3661. func (m *AllocAgentMutation) Op() Op {
  3662. return m.op
  3663. }
  3664. // SetOp allows setting the mutation operation.
  3665. func (m *AllocAgentMutation) SetOp(op Op) {
  3666. m.op = op
  3667. }
  3668. // Type returns the node type of this mutation (AllocAgent).
  3669. func (m *AllocAgentMutation) Type() string {
  3670. return m.typ
  3671. }
  3672. // Fields returns all fields that were changed during this mutation. Note that in
  3673. // order to get all numeric fields that were incremented/decremented, call
  3674. // AddedFields().
  3675. func (m *AllocAgentMutation) Fields() []string {
  3676. fields := make([]string, 0, 7)
  3677. if m.created_at != nil {
  3678. fields = append(fields, allocagent.FieldCreatedAt)
  3679. }
  3680. if m.updated_at != nil {
  3681. fields = append(fields, allocagent.FieldUpdatedAt)
  3682. }
  3683. if m.deleted_at != nil {
  3684. fields = append(fields, allocagent.FieldDeletedAt)
  3685. }
  3686. if m.user_id != nil {
  3687. fields = append(fields, allocagent.FieldUserID)
  3688. }
  3689. if m.organization_id != nil {
  3690. fields = append(fields, allocagent.FieldOrganizationID)
  3691. }
  3692. if m.agents != nil {
  3693. fields = append(fields, allocagent.FieldAgents)
  3694. }
  3695. if m.status != nil {
  3696. fields = append(fields, allocagent.FieldStatus)
  3697. }
  3698. return fields
  3699. }
  3700. // Field returns the value of a field with the given name. The second boolean
  3701. // return value indicates that this field was not set, or was not defined in the
  3702. // schema.
  3703. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3704. switch name {
  3705. case allocagent.FieldCreatedAt:
  3706. return m.CreatedAt()
  3707. case allocagent.FieldUpdatedAt:
  3708. return m.UpdatedAt()
  3709. case allocagent.FieldDeletedAt:
  3710. return m.DeletedAt()
  3711. case allocagent.FieldUserID:
  3712. return m.UserID()
  3713. case allocagent.FieldOrganizationID:
  3714. return m.OrganizationID()
  3715. case allocagent.FieldAgents:
  3716. return m.Agents()
  3717. case allocagent.FieldStatus:
  3718. return m.Status()
  3719. }
  3720. return nil, false
  3721. }
  3722. // OldField returns the old value of the field from the database. An error is
  3723. // returned if the mutation operation is not UpdateOne, or the query to the
  3724. // database failed.
  3725. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3726. switch name {
  3727. case allocagent.FieldCreatedAt:
  3728. return m.OldCreatedAt(ctx)
  3729. case allocagent.FieldUpdatedAt:
  3730. return m.OldUpdatedAt(ctx)
  3731. case allocagent.FieldDeletedAt:
  3732. return m.OldDeletedAt(ctx)
  3733. case allocagent.FieldUserID:
  3734. return m.OldUserID(ctx)
  3735. case allocagent.FieldOrganizationID:
  3736. return m.OldOrganizationID(ctx)
  3737. case allocagent.FieldAgents:
  3738. return m.OldAgents(ctx)
  3739. case allocagent.FieldStatus:
  3740. return m.OldStatus(ctx)
  3741. }
  3742. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3743. }
  3744. // SetField sets the value of a field with the given name. It returns an error if
  3745. // the field is not defined in the schema, or if the type mismatched the field
  3746. // type.
  3747. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3748. switch name {
  3749. case allocagent.FieldCreatedAt:
  3750. v, ok := value.(time.Time)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.SetCreatedAt(v)
  3755. return nil
  3756. case allocagent.FieldUpdatedAt:
  3757. v, ok := value.(time.Time)
  3758. if !ok {
  3759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3760. }
  3761. m.SetUpdatedAt(v)
  3762. return nil
  3763. case allocagent.FieldDeletedAt:
  3764. v, ok := value.(time.Time)
  3765. if !ok {
  3766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3767. }
  3768. m.SetDeletedAt(v)
  3769. return nil
  3770. case allocagent.FieldUserID:
  3771. v, ok := value.(string)
  3772. if !ok {
  3773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3774. }
  3775. m.SetUserID(v)
  3776. return nil
  3777. case allocagent.FieldOrganizationID:
  3778. v, ok := value.(uint64)
  3779. if !ok {
  3780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3781. }
  3782. m.SetOrganizationID(v)
  3783. return nil
  3784. case allocagent.FieldAgents:
  3785. v, ok := value.([]uint64)
  3786. if !ok {
  3787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3788. }
  3789. m.SetAgents(v)
  3790. return nil
  3791. case allocagent.FieldStatus:
  3792. v, ok := value.(int)
  3793. if !ok {
  3794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3795. }
  3796. m.SetStatus(v)
  3797. return nil
  3798. }
  3799. return fmt.Errorf("unknown AllocAgent field %s", name)
  3800. }
  3801. // AddedFields returns all numeric fields that were incremented/decremented during
  3802. // this mutation.
  3803. func (m *AllocAgentMutation) AddedFields() []string {
  3804. var fields []string
  3805. if m.addorganization_id != nil {
  3806. fields = append(fields, allocagent.FieldOrganizationID)
  3807. }
  3808. if m.addstatus != nil {
  3809. fields = append(fields, allocagent.FieldStatus)
  3810. }
  3811. return fields
  3812. }
  3813. // AddedField returns the numeric value that was incremented/decremented on a field
  3814. // with the given name. The second boolean return value indicates that this field
  3815. // was not set, or was not defined in the schema.
  3816. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3817. switch name {
  3818. case allocagent.FieldOrganizationID:
  3819. return m.AddedOrganizationID()
  3820. case allocagent.FieldStatus:
  3821. return m.AddedStatus()
  3822. }
  3823. return nil, false
  3824. }
  3825. // AddField adds the value to the field with the given name. It returns an error if
  3826. // the field is not defined in the schema, or if the type mismatched the field
  3827. // type.
  3828. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3829. switch name {
  3830. case allocagent.FieldOrganizationID:
  3831. v, ok := value.(int64)
  3832. if !ok {
  3833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3834. }
  3835. m.AddOrganizationID(v)
  3836. return nil
  3837. case allocagent.FieldStatus:
  3838. v, ok := value.(int)
  3839. if !ok {
  3840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3841. }
  3842. m.AddStatus(v)
  3843. return nil
  3844. }
  3845. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3846. }
  3847. // ClearedFields returns all nullable fields that were cleared during this
  3848. // mutation.
  3849. func (m *AllocAgentMutation) ClearedFields() []string {
  3850. var fields []string
  3851. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3852. fields = append(fields, allocagent.FieldDeletedAt)
  3853. }
  3854. if m.FieldCleared(allocagent.FieldUserID) {
  3855. fields = append(fields, allocagent.FieldUserID)
  3856. }
  3857. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3858. fields = append(fields, allocagent.FieldOrganizationID)
  3859. }
  3860. if m.FieldCleared(allocagent.FieldStatus) {
  3861. fields = append(fields, allocagent.FieldStatus)
  3862. }
  3863. return fields
  3864. }
  3865. // FieldCleared returns a boolean indicating if a field with the given name was
  3866. // cleared in this mutation.
  3867. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3868. _, ok := m.clearedFields[name]
  3869. return ok
  3870. }
  3871. // ClearField clears the value of the field with the given name. It returns an
  3872. // error if the field is not defined in the schema.
  3873. func (m *AllocAgentMutation) ClearField(name string) error {
  3874. switch name {
  3875. case allocagent.FieldDeletedAt:
  3876. m.ClearDeletedAt()
  3877. return nil
  3878. case allocagent.FieldUserID:
  3879. m.ClearUserID()
  3880. return nil
  3881. case allocagent.FieldOrganizationID:
  3882. m.ClearOrganizationID()
  3883. return nil
  3884. case allocagent.FieldStatus:
  3885. m.ClearStatus()
  3886. return nil
  3887. }
  3888. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3889. }
  3890. // ResetField resets all changes in the mutation for the field with the given name.
  3891. // It returns an error if the field is not defined in the schema.
  3892. func (m *AllocAgentMutation) ResetField(name string) error {
  3893. switch name {
  3894. case allocagent.FieldCreatedAt:
  3895. m.ResetCreatedAt()
  3896. return nil
  3897. case allocagent.FieldUpdatedAt:
  3898. m.ResetUpdatedAt()
  3899. return nil
  3900. case allocagent.FieldDeletedAt:
  3901. m.ResetDeletedAt()
  3902. return nil
  3903. case allocagent.FieldUserID:
  3904. m.ResetUserID()
  3905. return nil
  3906. case allocagent.FieldOrganizationID:
  3907. m.ResetOrganizationID()
  3908. return nil
  3909. case allocagent.FieldAgents:
  3910. m.ResetAgents()
  3911. return nil
  3912. case allocagent.FieldStatus:
  3913. m.ResetStatus()
  3914. return nil
  3915. }
  3916. return fmt.Errorf("unknown AllocAgent field %s", name)
  3917. }
  3918. // AddedEdges returns all edge names that were set/added in this mutation.
  3919. func (m *AllocAgentMutation) AddedEdges() []string {
  3920. edges := make([]string, 0, 0)
  3921. return edges
  3922. }
  3923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3924. // name in this mutation.
  3925. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3926. return nil
  3927. }
  3928. // RemovedEdges returns all edge names that were removed in this mutation.
  3929. func (m *AllocAgentMutation) RemovedEdges() []string {
  3930. edges := make([]string, 0, 0)
  3931. return edges
  3932. }
  3933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3934. // the given name in this mutation.
  3935. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3936. return nil
  3937. }
  3938. // ClearedEdges returns all edge names that were cleared in this mutation.
  3939. func (m *AllocAgentMutation) ClearedEdges() []string {
  3940. edges := make([]string, 0, 0)
  3941. return edges
  3942. }
  3943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3944. // was cleared in this mutation.
  3945. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3946. return false
  3947. }
  3948. // ClearEdge clears the value of the edge with the given name. It returns an error
  3949. // if that edge is not defined in the schema.
  3950. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3951. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3952. }
  3953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3954. // It returns an error if the edge is not defined in the schema.
  3955. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3956. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3957. }
  3958. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3959. type BatchMsgMutation struct {
  3960. config
  3961. op Op
  3962. typ string
  3963. id *uint64
  3964. created_at *time.Time
  3965. updated_at *time.Time
  3966. deleted_at *time.Time
  3967. status *uint8
  3968. addstatus *int8
  3969. batch_no *string
  3970. task_name *string
  3971. fromwxid *string
  3972. msg *string
  3973. tag *string
  3974. tagids *string
  3975. total *int32
  3976. addtotal *int32
  3977. success *int32
  3978. addsuccess *int32
  3979. fail *int32
  3980. addfail *int32
  3981. start_time *time.Time
  3982. stop_time *time.Time
  3983. send_time *time.Time
  3984. _type *int32
  3985. add_type *int32
  3986. organization_id *uint64
  3987. addorganization_id *int64
  3988. clearedFields map[string]struct{}
  3989. done bool
  3990. oldValue func(context.Context) (*BatchMsg, error)
  3991. predicates []predicate.BatchMsg
  3992. }
  3993. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3994. // batchmsgOption allows management of the mutation configuration using functional options.
  3995. type batchmsgOption func(*BatchMsgMutation)
  3996. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3997. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3998. m := &BatchMsgMutation{
  3999. config: c,
  4000. op: op,
  4001. typ: TypeBatchMsg,
  4002. clearedFields: make(map[string]struct{}),
  4003. }
  4004. for _, opt := range opts {
  4005. opt(m)
  4006. }
  4007. return m
  4008. }
  4009. // withBatchMsgID sets the ID field of the mutation.
  4010. func withBatchMsgID(id uint64) batchmsgOption {
  4011. return func(m *BatchMsgMutation) {
  4012. var (
  4013. err error
  4014. once sync.Once
  4015. value *BatchMsg
  4016. )
  4017. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4018. once.Do(func() {
  4019. if m.done {
  4020. err = errors.New("querying old values post mutation is not allowed")
  4021. } else {
  4022. value, err = m.Client().BatchMsg.Get(ctx, id)
  4023. }
  4024. })
  4025. return value, err
  4026. }
  4027. m.id = &id
  4028. }
  4029. }
  4030. // withBatchMsg sets the old BatchMsg of the mutation.
  4031. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4032. return func(m *BatchMsgMutation) {
  4033. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4034. return node, nil
  4035. }
  4036. m.id = &node.ID
  4037. }
  4038. }
  4039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4040. // executed in a transaction (ent.Tx), a transactional client is returned.
  4041. func (m BatchMsgMutation) Client() *Client {
  4042. client := &Client{config: m.config}
  4043. client.init()
  4044. return client
  4045. }
  4046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4047. // it returns an error otherwise.
  4048. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4049. if _, ok := m.driver.(*txDriver); !ok {
  4050. return nil, errors.New("ent: mutation is not running in a transaction")
  4051. }
  4052. tx := &Tx{config: m.config}
  4053. tx.init()
  4054. return tx, nil
  4055. }
  4056. // SetID sets the value of the id field. Note that this
  4057. // operation is only accepted on creation of BatchMsg entities.
  4058. func (m *BatchMsgMutation) SetID(id uint64) {
  4059. m.id = &id
  4060. }
  4061. // ID returns the ID value in the mutation. Note that the ID is only available
  4062. // if it was provided to the builder or after it was returned from the database.
  4063. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4064. if m.id == nil {
  4065. return
  4066. }
  4067. return *m.id, true
  4068. }
  4069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4070. // That means, if the mutation is applied within a transaction with an isolation level such
  4071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4072. // or updated by the mutation.
  4073. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4074. switch {
  4075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4076. id, exists := m.ID()
  4077. if exists {
  4078. return []uint64{id}, nil
  4079. }
  4080. fallthrough
  4081. case m.op.Is(OpUpdate | OpDelete):
  4082. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4083. default:
  4084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4085. }
  4086. }
  4087. // SetCreatedAt sets the "created_at" field.
  4088. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4089. m.created_at = &t
  4090. }
  4091. // CreatedAt returns the value of the "created_at" field in the mutation.
  4092. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4093. v := m.created_at
  4094. if v == nil {
  4095. return
  4096. }
  4097. return *v, true
  4098. }
  4099. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4100. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4102. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4103. if !m.op.Is(OpUpdateOne) {
  4104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4105. }
  4106. if m.id == nil || m.oldValue == nil {
  4107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4108. }
  4109. oldValue, err := m.oldValue(ctx)
  4110. if err != nil {
  4111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4112. }
  4113. return oldValue.CreatedAt, nil
  4114. }
  4115. // ResetCreatedAt resets all changes to the "created_at" field.
  4116. func (m *BatchMsgMutation) ResetCreatedAt() {
  4117. m.created_at = nil
  4118. }
  4119. // SetUpdatedAt sets the "updated_at" field.
  4120. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4121. m.updated_at = &t
  4122. }
  4123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4124. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4125. v := m.updated_at
  4126. if v == nil {
  4127. return
  4128. }
  4129. return *v, true
  4130. }
  4131. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4132. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4134. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4135. if !m.op.Is(OpUpdateOne) {
  4136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4137. }
  4138. if m.id == nil || m.oldValue == nil {
  4139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4140. }
  4141. oldValue, err := m.oldValue(ctx)
  4142. if err != nil {
  4143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4144. }
  4145. return oldValue.UpdatedAt, nil
  4146. }
  4147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4148. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4149. m.updated_at = nil
  4150. }
  4151. // SetDeletedAt sets the "deleted_at" field.
  4152. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4153. m.deleted_at = &t
  4154. }
  4155. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4156. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4157. v := m.deleted_at
  4158. if v == nil {
  4159. return
  4160. }
  4161. return *v, true
  4162. }
  4163. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4164. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4166. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4167. if !m.op.Is(OpUpdateOne) {
  4168. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4169. }
  4170. if m.id == nil || m.oldValue == nil {
  4171. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4172. }
  4173. oldValue, err := m.oldValue(ctx)
  4174. if err != nil {
  4175. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4176. }
  4177. return oldValue.DeletedAt, nil
  4178. }
  4179. // ClearDeletedAt clears the value of the "deleted_at" field.
  4180. func (m *BatchMsgMutation) ClearDeletedAt() {
  4181. m.deleted_at = nil
  4182. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4183. }
  4184. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4185. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4186. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4187. return ok
  4188. }
  4189. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4190. func (m *BatchMsgMutation) ResetDeletedAt() {
  4191. m.deleted_at = nil
  4192. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4193. }
  4194. // SetStatus sets the "status" field.
  4195. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4196. m.status = &u
  4197. m.addstatus = nil
  4198. }
  4199. // Status returns the value of the "status" field in the mutation.
  4200. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4201. v := m.status
  4202. if v == nil {
  4203. return
  4204. }
  4205. return *v, true
  4206. }
  4207. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4208. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4210. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4211. if !m.op.Is(OpUpdateOne) {
  4212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4213. }
  4214. if m.id == nil || m.oldValue == nil {
  4215. return v, errors.New("OldStatus requires an ID field in the mutation")
  4216. }
  4217. oldValue, err := m.oldValue(ctx)
  4218. if err != nil {
  4219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4220. }
  4221. return oldValue.Status, nil
  4222. }
  4223. // AddStatus adds u to the "status" field.
  4224. func (m *BatchMsgMutation) AddStatus(u int8) {
  4225. if m.addstatus != nil {
  4226. *m.addstatus += u
  4227. } else {
  4228. m.addstatus = &u
  4229. }
  4230. }
  4231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4232. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4233. v := m.addstatus
  4234. if v == nil {
  4235. return
  4236. }
  4237. return *v, true
  4238. }
  4239. // ClearStatus clears the value of the "status" field.
  4240. func (m *BatchMsgMutation) ClearStatus() {
  4241. m.status = nil
  4242. m.addstatus = nil
  4243. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4244. }
  4245. // StatusCleared returns if the "status" field was cleared in this mutation.
  4246. func (m *BatchMsgMutation) StatusCleared() bool {
  4247. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4248. return ok
  4249. }
  4250. // ResetStatus resets all changes to the "status" field.
  4251. func (m *BatchMsgMutation) ResetStatus() {
  4252. m.status = nil
  4253. m.addstatus = nil
  4254. delete(m.clearedFields, batchmsg.FieldStatus)
  4255. }
  4256. // SetBatchNo sets the "batch_no" field.
  4257. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4258. m.batch_no = &s
  4259. }
  4260. // BatchNo returns the value of the "batch_no" field in the mutation.
  4261. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4262. v := m.batch_no
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4271. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4277. }
  4278. oldValue, err := m.oldValue(ctx)
  4279. if err != nil {
  4280. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4281. }
  4282. return oldValue.BatchNo, nil
  4283. }
  4284. // ClearBatchNo clears the value of the "batch_no" field.
  4285. func (m *BatchMsgMutation) ClearBatchNo() {
  4286. m.batch_no = nil
  4287. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4288. }
  4289. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4290. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4291. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4292. return ok
  4293. }
  4294. // ResetBatchNo resets all changes to the "batch_no" field.
  4295. func (m *BatchMsgMutation) ResetBatchNo() {
  4296. m.batch_no = nil
  4297. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4298. }
  4299. // SetTaskName sets the "task_name" field.
  4300. func (m *BatchMsgMutation) SetTaskName(s string) {
  4301. m.task_name = &s
  4302. }
  4303. // TaskName returns the value of the "task_name" field in the mutation.
  4304. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4305. v := m.task_name
  4306. if v == nil {
  4307. return
  4308. }
  4309. return *v, true
  4310. }
  4311. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4314. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4315. if !m.op.Is(OpUpdateOne) {
  4316. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4317. }
  4318. if m.id == nil || m.oldValue == nil {
  4319. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4320. }
  4321. oldValue, err := m.oldValue(ctx)
  4322. if err != nil {
  4323. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4324. }
  4325. return oldValue.TaskName, nil
  4326. }
  4327. // ClearTaskName clears the value of the "task_name" field.
  4328. func (m *BatchMsgMutation) ClearTaskName() {
  4329. m.task_name = nil
  4330. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4331. }
  4332. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4333. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4334. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4335. return ok
  4336. }
  4337. // ResetTaskName resets all changes to the "task_name" field.
  4338. func (m *BatchMsgMutation) ResetTaskName() {
  4339. m.task_name = nil
  4340. delete(m.clearedFields, batchmsg.FieldTaskName)
  4341. }
  4342. // SetFromwxid sets the "fromwxid" field.
  4343. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4344. m.fromwxid = &s
  4345. }
  4346. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4347. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4348. v := m.fromwxid
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4367. }
  4368. return oldValue.Fromwxid, nil
  4369. }
  4370. // ClearFromwxid clears the value of the "fromwxid" field.
  4371. func (m *BatchMsgMutation) ClearFromwxid() {
  4372. m.fromwxid = nil
  4373. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4374. }
  4375. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4376. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4377. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4378. return ok
  4379. }
  4380. // ResetFromwxid resets all changes to the "fromwxid" field.
  4381. func (m *BatchMsgMutation) ResetFromwxid() {
  4382. m.fromwxid = nil
  4383. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4384. }
  4385. // SetMsg sets the "msg" field.
  4386. func (m *BatchMsgMutation) SetMsg(s string) {
  4387. m.msg = &s
  4388. }
  4389. // Msg returns the value of the "msg" field in the mutation.
  4390. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4391. v := m.msg
  4392. if v == nil {
  4393. return
  4394. }
  4395. return *v, true
  4396. }
  4397. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4400. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4401. if !m.op.Is(OpUpdateOne) {
  4402. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4403. }
  4404. if m.id == nil || m.oldValue == nil {
  4405. return v, errors.New("OldMsg requires an ID field in the mutation")
  4406. }
  4407. oldValue, err := m.oldValue(ctx)
  4408. if err != nil {
  4409. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4410. }
  4411. return oldValue.Msg, nil
  4412. }
  4413. // ClearMsg clears the value of the "msg" field.
  4414. func (m *BatchMsgMutation) ClearMsg() {
  4415. m.msg = nil
  4416. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4417. }
  4418. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4419. func (m *BatchMsgMutation) MsgCleared() bool {
  4420. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4421. return ok
  4422. }
  4423. // ResetMsg resets all changes to the "msg" field.
  4424. func (m *BatchMsgMutation) ResetMsg() {
  4425. m.msg = nil
  4426. delete(m.clearedFields, batchmsg.FieldMsg)
  4427. }
  4428. // SetTag sets the "tag" field.
  4429. func (m *BatchMsgMutation) SetTag(s string) {
  4430. m.tag = &s
  4431. }
  4432. // Tag returns the value of the "tag" field in the mutation.
  4433. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4434. v := m.tag
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4441. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldTag requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4453. }
  4454. return oldValue.Tag, nil
  4455. }
  4456. // ClearTag clears the value of the "tag" field.
  4457. func (m *BatchMsgMutation) ClearTag() {
  4458. m.tag = nil
  4459. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4460. }
  4461. // TagCleared returns if the "tag" field was cleared in this mutation.
  4462. func (m *BatchMsgMutation) TagCleared() bool {
  4463. _, ok := m.clearedFields[batchmsg.FieldTag]
  4464. return ok
  4465. }
  4466. // ResetTag resets all changes to the "tag" field.
  4467. func (m *BatchMsgMutation) ResetTag() {
  4468. m.tag = nil
  4469. delete(m.clearedFields, batchmsg.FieldTag)
  4470. }
  4471. // SetTagids sets the "tagids" field.
  4472. func (m *BatchMsgMutation) SetTagids(s string) {
  4473. m.tagids = &s
  4474. }
  4475. // Tagids returns the value of the "tagids" field in the mutation.
  4476. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4477. v := m.tagids
  4478. if v == nil {
  4479. return
  4480. }
  4481. return *v, true
  4482. }
  4483. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4484. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4486. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4487. if !m.op.Is(OpUpdateOne) {
  4488. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4489. }
  4490. if m.id == nil || m.oldValue == nil {
  4491. return v, errors.New("OldTagids requires an ID field in the mutation")
  4492. }
  4493. oldValue, err := m.oldValue(ctx)
  4494. if err != nil {
  4495. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4496. }
  4497. return oldValue.Tagids, nil
  4498. }
  4499. // ClearTagids clears the value of the "tagids" field.
  4500. func (m *BatchMsgMutation) ClearTagids() {
  4501. m.tagids = nil
  4502. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4503. }
  4504. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4505. func (m *BatchMsgMutation) TagidsCleared() bool {
  4506. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4507. return ok
  4508. }
  4509. // ResetTagids resets all changes to the "tagids" field.
  4510. func (m *BatchMsgMutation) ResetTagids() {
  4511. m.tagids = nil
  4512. delete(m.clearedFields, batchmsg.FieldTagids)
  4513. }
  4514. // SetTotal sets the "total" field.
  4515. func (m *BatchMsgMutation) SetTotal(i int32) {
  4516. m.total = &i
  4517. m.addtotal = nil
  4518. }
  4519. // Total returns the value of the "total" field in the mutation.
  4520. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4521. v := m.total
  4522. if v == nil {
  4523. return
  4524. }
  4525. return *v, true
  4526. }
  4527. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4528. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4530. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4531. if !m.op.Is(OpUpdateOne) {
  4532. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4533. }
  4534. if m.id == nil || m.oldValue == nil {
  4535. return v, errors.New("OldTotal requires an ID field in the mutation")
  4536. }
  4537. oldValue, err := m.oldValue(ctx)
  4538. if err != nil {
  4539. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4540. }
  4541. return oldValue.Total, nil
  4542. }
  4543. // AddTotal adds i to the "total" field.
  4544. func (m *BatchMsgMutation) AddTotal(i int32) {
  4545. if m.addtotal != nil {
  4546. *m.addtotal += i
  4547. } else {
  4548. m.addtotal = &i
  4549. }
  4550. }
  4551. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4552. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4553. v := m.addtotal
  4554. if v == nil {
  4555. return
  4556. }
  4557. return *v, true
  4558. }
  4559. // ClearTotal clears the value of the "total" field.
  4560. func (m *BatchMsgMutation) ClearTotal() {
  4561. m.total = nil
  4562. m.addtotal = nil
  4563. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4564. }
  4565. // TotalCleared returns if the "total" field was cleared in this mutation.
  4566. func (m *BatchMsgMutation) TotalCleared() bool {
  4567. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4568. return ok
  4569. }
  4570. // ResetTotal resets all changes to the "total" field.
  4571. func (m *BatchMsgMutation) ResetTotal() {
  4572. m.total = nil
  4573. m.addtotal = nil
  4574. delete(m.clearedFields, batchmsg.FieldTotal)
  4575. }
  4576. // SetSuccess sets the "success" field.
  4577. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4578. m.success = &i
  4579. m.addsuccess = nil
  4580. }
  4581. // Success returns the value of the "success" field in the mutation.
  4582. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4583. v := m.success
  4584. if v == nil {
  4585. return
  4586. }
  4587. return *v, true
  4588. }
  4589. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4590. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4592. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4593. if !m.op.Is(OpUpdateOne) {
  4594. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4595. }
  4596. if m.id == nil || m.oldValue == nil {
  4597. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4598. }
  4599. oldValue, err := m.oldValue(ctx)
  4600. if err != nil {
  4601. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4602. }
  4603. return oldValue.Success, nil
  4604. }
  4605. // AddSuccess adds i to the "success" field.
  4606. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4607. if m.addsuccess != nil {
  4608. *m.addsuccess += i
  4609. } else {
  4610. m.addsuccess = &i
  4611. }
  4612. }
  4613. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4614. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4615. v := m.addsuccess
  4616. if v == nil {
  4617. return
  4618. }
  4619. return *v, true
  4620. }
  4621. // ClearSuccess clears the value of the "success" field.
  4622. func (m *BatchMsgMutation) ClearSuccess() {
  4623. m.success = nil
  4624. m.addsuccess = nil
  4625. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4626. }
  4627. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4628. func (m *BatchMsgMutation) SuccessCleared() bool {
  4629. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4630. return ok
  4631. }
  4632. // ResetSuccess resets all changes to the "success" field.
  4633. func (m *BatchMsgMutation) ResetSuccess() {
  4634. m.success = nil
  4635. m.addsuccess = nil
  4636. delete(m.clearedFields, batchmsg.FieldSuccess)
  4637. }
  4638. // SetFail sets the "fail" field.
  4639. func (m *BatchMsgMutation) SetFail(i int32) {
  4640. m.fail = &i
  4641. m.addfail = nil
  4642. }
  4643. // Fail returns the value of the "fail" field in the mutation.
  4644. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4645. v := m.fail
  4646. if v == nil {
  4647. return
  4648. }
  4649. return *v, true
  4650. }
  4651. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4652. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4654. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4655. if !m.op.Is(OpUpdateOne) {
  4656. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4657. }
  4658. if m.id == nil || m.oldValue == nil {
  4659. return v, errors.New("OldFail requires an ID field in the mutation")
  4660. }
  4661. oldValue, err := m.oldValue(ctx)
  4662. if err != nil {
  4663. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4664. }
  4665. return oldValue.Fail, nil
  4666. }
  4667. // AddFail adds i to the "fail" field.
  4668. func (m *BatchMsgMutation) AddFail(i int32) {
  4669. if m.addfail != nil {
  4670. *m.addfail += i
  4671. } else {
  4672. m.addfail = &i
  4673. }
  4674. }
  4675. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4676. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4677. v := m.addfail
  4678. if v == nil {
  4679. return
  4680. }
  4681. return *v, true
  4682. }
  4683. // ClearFail clears the value of the "fail" field.
  4684. func (m *BatchMsgMutation) ClearFail() {
  4685. m.fail = nil
  4686. m.addfail = nil
  4687. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4688. }
  4689. // FailCleared returns if the "fail" field was cleared in this mutation.
  4690. func (m *BatchMsgMutation) FailCleared() bool {
  4691. _, ok := m.clearedFields[batchmsg.FieldFail]
  4692. return ok
  4693. }
  4694. // ResetFail resets all changes to the "fail" field.
  4695. func (m *BatchMsgMutation) ResetFail() {
  4696. m.fail = nil
  4697. m.addfail = nil
  4698. delete(m.clearedFields, batchmsg.FieldFail)
  4699. }
  4700. // SetStartTime sets the "start_time" field.
  4701. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4702. m.start_time = &t
  4703. }
  4704. // StartTime returns the value of the "start_time" field in the mutation.
  4705. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4706. v := m.start_time
  4707. if v == nil {
  4708. return
  4709. }
  4710. return *v, true
  4711. }
  4712. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4713. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4715. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4716. if !m.op.Is(OpUpdateOne) {
  4717. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4718. }
  4719. if m.id == nil || m.oldValue == nil {
  4720. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4721. }
  4722. oldValue, err := m.oldValue(ctx)
  4723. if err != nil {
  4724. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4725. }
  4726. return oldValue.StartTime, nil
  4727. }
  4728. // ClearStartTime clears the value of the "start_time" field.
  4729. func (m *BatchMsgMutation) ClearStartTime() {
  4730. m.start_time = nil
  4731. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4732. }
  4733. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4734. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4735. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4736. return ok
  4737. }
  4738. // ResetStartTime resets all changes to the "start_time" field.
  4739. func (m *BatchMsgMutation) ResetStartTime() {
  4740. m.start_time = nil
  4741. delete(m.clearedFields, batchmsg.FieldStartTime)
  4742. }
  4743. // SetStopTime sets the "stop_time" field.
  4744. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4745. m.stop_time = &t
  4746. }
  4747. // StopTime returns the value of the "stop_time" field in the mutation.
  4748. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4749. v := m.stop_time
  4750. if v == nil {
  4751. return
  4752. }
  4753. return *v, true
  4754. }
  4755. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4756. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4758. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4759. if !m.op.Is(OpUpdateOne) {
  4760. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4761. }
  4762. if m.id == nil || m.oldValue == nil {
  4763. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4764. }
  4765. oldValue, err := m.oldValue(ctx)
  4766. if err != nil {
  4767. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4768. }
  4769. return oldValue.StopTime, nil
  4770. }
  4771. // ClearStopTime clears the value of the "stop_time" field.
  4772. func (m *BatchMsgMutation) ClearStopTime() {
  4773. m.stop_time = nil
  4774. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4775. }
  4776. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4777. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4778. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4779. return ok
  4780. }
  4781. // ResetStopTime resets all changes to the "stop_time" field.
  4782. func (m *BatchMsgMutation) ResetStopTime() {
  4783. m.stop_time = nil
  4784. delete(m.clearedFields, batchmsg.FieldStopTime)
  4785. }
  4786. // SetSendTime sets the "send_time" field.
  4787. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4788. m.send_time = &t
  4789. }
  4790. // SendTime returns the value of the "send_time" field in the mutation.
  4791. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4792. v := m.send_time
  4793. if v == nil {
  4794. return
  4795. }
  4796. return *v, true
  4797. }
  4798. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4801. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4802. if !m.op.Is(OpUpdateOne) {
  4803. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4804. }
  4805. if m.id == nil || m.oldValue == nil {
  4806. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4807. }
  4808. oldValue, err := m.oldValue(ctx)
  4809. if err != nil {
  4810. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4811. }
  4812. return oldValue.SendTime, nil
  4813. }
  4814. // ClearSendTime clears the value of the "send_time" field.
  4815. func (m *BatchMsgMutation) ClearSendTime() {
  4816. m.send_time = nil
  4817. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4818. }
  4819. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4820. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4821. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4822. return ok
  4823. }
  4824. // ResetSendTime resets all changes to the "send_time" field.
  4825. func (m *BatchMsgMutation) ResetSendTime() {
  4826. m.send_time = nil
  4827. delete(m.clearedFields, batchmsg.FieldSendTime)
  4828. }
  4829. // SetType sets the "type" field.
  4830. func (m *BatchMsgMutation) SetType(i int32) {
  4831. m._type = &i
  4832. m.add_type = nil
  4833. }
  4834. // GetType returns the value of the "type" field in the mutation.
  4835. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4836. v := m._type
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // OldType returns the old "type" field's value of the BatchMsg entity.
  4843. // If the BatchMsg 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 *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4846. if !m.op.Is(OpUpdateOne) {
  4847. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4848. }
  4849. if m.id == nil || m.oldValue == nil {
  4850. return v, errors.New("OldType 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 OldType: %w", err)
  4855. }
  4856. return oldValue.Type, nil
  4857. }
  4858. // AddType adds i to the "type" field.
  4859. func (m *BatchMsgMutation) AddType(i int32) {
  4860. if m.add_type != nil {
  4861. *m.add_type += i
  4862. } else {
  4863. m.add_type = &i
  4864. }
  4865. }
  4866. // AddedType returns the value that was added to the "type" field in this mutation.
  4867. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4868. v := m.add_type
  4869. if v == nil {
  4870. return
  4871. }
  4872. return *v, true
  4873. }
  4874. // ClearType clears the value of the "type" field.
  4875. func (m *BatchMsgMutation) ClearType() {
  4876. m._type = nil
  4877. m.add_type = nil
  4878. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4879. }
  4880. // TypeCleared returns if the "type" field was cleared in this mutation.
  4881. func (m *BatchMsgMutation) TypeCleared() bool {
  4882. _, ok := m.clearedFields[batchmsg.FieldType]
  4883. return ok
  4884. }
  4885. // ResetType resets all changes to the "type" field.
  4886. func (m *BatchMsgMutation) ResetType() {
  4887. m._type = nil
  4888. m.add_type = nil
  4889. delete(m.clearedFields, batchmsg.FieldType)
  4890. }
  4891. // SetOrganizationID sets the "organization_id" field.
  4892. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4893. m.organization_id = &u
  4894. m.addorganization_id = nil
  4895. }
  4896. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4897. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4898. v := m.organization_id
  4899. if v == nil {
  4900. return
  4901. }
  4902. return *v, true
  4903. }
  4904. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4905. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4907. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4908. if !m.op.Is(OpUpdateOne) {
  4909. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4910. }
  4911. if m.id == nil || m.oldValue == nil {
  4912. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4913. }
  4914. oldValue, err := m.oldValue(ctx)
  4915. if err != nil {
  4916. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4917. }
  4918. return oldValue.OrganizationID, nil
  4919. }
  4920. // AddOrganizationID adds u to the "organization_id" field.
  4921. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4922. if m.addorganization_id != nil {
  4923. *m.addorganization_id += u
  4924. } else {
  4925. m.addorganization_id = &u
  4926. }
  4927. }
  4928. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4929. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4930. v := m.addorganization_id
  4931. if v == nil {
  4932. return
  4933. }
  4934. return *v, true
  4935. }
  4936. // ResetOrganizationID resets all changes to the "organization_id" field.
  4937. func (m *BatchMsgMutation) ResetOrganizationID() {
  4938. m.organization_id = nil
  4939. m.addorganization_id = nil
  4940. }
  4941. // Where appends a list predicates to the BatchMsgMutation builder.
  4942. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4943. m.predicates = append(m.predicates, ps...)
  4944. }
  4945. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4946. // users can use type-assertion to append predicates that do not depend on any generated package.
  4947. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4948. p := make([]predicate.BatchMsg, len(ps))
  4949. for i := range ps {
  4950. p[i] = ps[i]
  4951. }
  4952. m.Where(p...)
  4953. }
  4954. // Op returns the operation name.
  4955. func (m *BatchMsgMutation) Op() Op {
  4956. return m.op
  4957. }
  4958. // SetOp allows setting the mutation operation.
  4959. func (m *BatchMsgMutation) SetOp(op Op) {
  4960. m.op = op
  4961. }
  4962. // Type returns the node type of this mutation (BatchMsg).
  4963. func (m *BatchMsgMutation) Type() string {
  4964. return m.typ
  4965. }
  4966. // Fields returns all fields that were changed during this mutation. Note that in
  4967. // order to get all numeric fields that were incremented/decremented, call
  4968. // AddedFields().
  4969. func (m *BatchMsgMutation) Fields() []string {
  4970. fields := make([]string, 0, 18)
  4971. if m.created_at != nil {
  4972. fields = append(fields, batchmsg.FieldCreatedAt)
  4973. }
  4974. if m.updated_at != nil {
  4975. fields = append(fields, batchmsg.FieldUpdatedAt)
  4976. }
  4977. if m.deleted_at != nil {
  4978. fields = append(fields, batchmsg.FieldDeletedAt)
  4979. }
  4980. if m.status != nil {
  4981. fields = append(fields, batchmsg.FieldStatus)
  4982. }
  4983. if m.batch_no != nil {
  4984. fields = append(fields, batchmsg.FieldBatchNo)
  4985. }
  4986. if m.task_name != nil {
  4987. fields = append(fields, batchmsg.FieldTaskName)
  4988. }
  4989. if m.fromwxid != nil {
  4990. fields = append(fields, batchmsg.FieldFromwxid)
  4991. }
  4992. if m.msg != nil {
  4993. fields = append(fields, batchmsg.FieldMsg)
  4994. }
  4995. if m.tag != nil {
  4996. fields = append(fields, batchmsg.FieldTag)
  4997. }
  4998. if m.tagids != nil {
  4999. fields = append(fields, batchmsg.FieldTagids)
  5000. }
  5001. if m.total != nil {
  5002. fields = append(fields, batchmsg.FieldTotal)
  5003. }
  5004. if m.success != nil {
  5005. fields = append(fields, batchmsg.FieldSuccess)
  5006. }
  5007. if m.fail != nil {
  5008. fields = append(fields, batchmsg.FieldFail)
  5009. }
  5010. if m.start_time != nil {
  5011. fields = append(fields, batchmsg.FieldStartTime)
  5012. }
  5013. if m.stop_time != nil {
  5014. fields = append(fields, batchmsg.FieldStopTime)
  5015. }
  5016. if m.send_time != nil {
  5017. fields = append(fields, batchmsg.FieldSendTime)
  5018. }
  5019. if m._type != nil {
  5020. fields = append(fields, batchmsg.FieldType)
  5021. }
  5022. if m.organization_id != nil {
  5023. fields = append(fields, batchmsg.FieldOrganizationID)
  5024. }
  5025. return fields
  5026. }
  5027. // Field returns the value of a field with the given name. The second boolean
  5028. // return value indicates that this field was not set, or was not defined in the
  5029. // schema.
  5030. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5031. switch name {
  5032. case batchmsg.FieldCreatedAt:
  5033. return m.CreatedAt()
  5034. case batchmsg.FieldUpdatedAt:
  5035. return m.UpdatedAt()
  5036. case batchmsg.FieldDeletedAt:
  5037. return m.DeletedAt()
  5038. case batchmsg.FieldStatus:
  5039. return m.Status()
  5040. case batchmsg.FieldBatchNo:
  5041. return m.BatchNo()
  5042. case batchmsg.FieldTaskName:
  5043. return m.TaskName()
  5044. case batchmsg.FieldFromwxid:
  5045. return m.Fromwxid()
  5046. case batchmsg.FieldMsg:
  5047. return m.Msg()
  5048. case batchmsg.FieldTag:
  5049. return m.Tag()
  5050. case batchmsg.FieldTagids:
  5051. return m.Tagids()
  5052. case batchmsg.FieldTotal:
  5053. return m.Total()
  5054. case batchmsg.FieldSuccess:
  5055. return m.Success()
  5056. case batchmsg.FieldFail:
  5057. return m.Fail()
  5058. case batchmsg.FieldStartTime:
  5059. return m.StartTime()
  5060. case batchmsg.FieldStopTime:
  5061. return m.StopTime()
  5062. case batchmsg.FieldSendTime:
  5063. return m.SendTime()
  5064. case batchmsg.FieldType:
  5065. return m.GetType()
  5066. case batchmsg.FieldOrganizationID:
  5067. return m.OrganizationID()
  5068. }
  5069. return nil, false
  5070. }
  5071. // OldField returns the old value of the field from the database. An error is
  5072. // returned if the mutation operation is not UpdateOne, or the query to the
  5073. // database failed.
  5074. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5075. switch name {
  5076. case batchmsg.FieldCreatedAt:
  5077. return m.OldCreatedAt(ctx)
  5078. case batchmsg.FieldUpdatedAt:
  5079. return m.OldUpdatedAt(ctx)
  5080. case batchmsg.FieldDeletedAt:
  5081. return m.OldDeletedAt(ctx)
  5082. case batchmsg.FieldStatus:
  5083. return m.OldStatus(ctx)
  5084. case batchmsg.FieldBatchNo:
  5085. return m.OldBatchNo(ctx)
  5086. case batchmsg.FieldTaskName:
  5087. return m.OldTaskName(ctx)
  5088. case batchmsg.FieldFromwxid:
  5089. return m.OldFromwxid(ctx)
  5090. case batchmsg.FieldMsg:
  5091. return m.OldMsg(ctx)
  5092. case batchmsg.FieldTag:
  5093. return m.OldTag(ctx)
  5094. case batchmsg.FieldTagids:
  5095. return m.OldTagids(ctx)
  5096. case batchmsg.FieldTotal:
  5097. return m.OldTotal(ctx)
  5098. case batchmsg.FieldSuccess:
  5099. return m.OldSuccess(ctx)
  5100. case batchmsg.FieldFail:
  5101. return m.OldFail(ctx)
  5102. case batchmsg.FieldStartTime:
  5103. return m.OldStartTime(ctx)
  5104. case batchmsg.FieldStopTime:
  5105. return m.OldStopTime(ctx)
  5106. case batchmsg.FieldSendTime:
  5107. return m.OldSendTime(ctx)
  5108. case batchmsg.FieldType:
  5109. return m.OldType(ctx)
  5110. case batchmsg.FieldOrganizationID:
  5111. return m.OldOrganizationID(ctx)
  5112. }
  5113. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5114. }
  5115. // SetField sets the value of a field with the given name. It returns an error if
  5116. // the field is not defined in the schema, or if the type mismatched the field
  5117. // type.
  5118. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5119. switch name {
  5120. case batchmsg.FieldCreatedAt:
  5121. v, ok := value.(time.Time)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetCreatedAt(v)
  5126. return nil
  5127. case batchmsg.FieldUpdatedAt:
  5128. v, ok := value.(time.Time)
  5129. if !ok {
  5130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131. }
  5132. m.SetUpdatedAt(v)
  5133. return nil
  5134. case batchmsg.FieldDeletedAt:
  5135. v, ok := value.(time.Time)
  5136. if !ok {
  5137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5138. }
  5139. m.SetDeletedAt(v)
  5140. return nil
  5141. case batchmsg.FieldStatus:
  5142. v, ok := value.(uint8)
  5143. if !ok {
  5144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5145. }
  5146. m.SetStatus(v)
  5147. return nil
  5148. case batchmsg.FieldBatchNo:
  5149. v, ok := value.(string)
  5150. if !ok {
  5151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5152. }
  5153. m.SetBatchNo(v)
  5154. return nil
  5155. case batchmsg.FieldTaskName:
  5156. v, ok := value.(string)
  5157. if !ok {
  5158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5159. }
  5160. m.SetTaskName(v)
  5161. return nil
  5162. case batchmsg.FieldFromwxid:
  5163. v, ok := value.(string)
  5164. if !ok {
  5165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166. }
  5167. m.SetFromwxid(v)
  5168. return nil
  5169. case batchmsg.FieldMsg:
  5170. v, ok := value.(string)
  5171. if !ok {
  5172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5173. }
  5174. m.SetMsg(v)
  5175. return nil
  5176. case batchmsg.FieldTag:
  5177. v, ok := value.(string)
  5178. if !ok {
  5179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5180. }
  5181. m.SetTag(v)
  5182. return nil
  5183. case batchmsg.FieldTagids:
  5184. v, ok := value.(string)
  5185. if !ok {
  5186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187. }
  5188. m.SetTagids(v)
  5189. return nil
  5190. case batchmsg.FieldTotal:
  5191. v, ok := value.(int32)
  5192. if !ok {
  5193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5194. }
  5195. m.SetTotal(v)
  5196. return nil
  5197. case batchmsg.FieldSuccess:
  5198. v, ok := value.(int32)
  5199. if !ok {
  5200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5201. }
  5202. m.SetSuccess(v)
  5203. return nil
  5204. case batchmsg.FieldFail:
  5205. v, ok := value.(int32)
  5206. if !ok {
  5207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5208. }
  5209. m.SetFail(v)
  5210. return nil
  5211. case batchmsg.FieldStartTime:
  5212. v, ok := value.(time.Time)
  5213. if !ok {
  5214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5215. }
  5216. m.SetStartTime(v)
  5217. return nil
  5218. case batchmsg.FieldStopTime:
  5219. v, ok := value.(time.Time)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.SetStopTime(v)
  5224. return nil
  5225. case batchmsg.FieldSendTime:
  5226. v, ok := value.(time.Time)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.SetSendTime(v)
  5231. return nil
  5232. case batchmsg.FieldType:
  5233. v, ok := value.(int32)
  5234. if !ok {
  5235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5236. }
  5237. m.SetType(v)
  5238. return nil
  5239. case batchmsg.FieldOrganizationID:
  5240. v, ok := value.(uint64)
  5241. if !ok {
  5242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5243. }
  5244. m.SetOrganizationID(v)
  5245. return nil
  5246. }
  5247. return fmt.Errorf("unknown BatchMsg field %s", name)
  5248. }
  5249. // AddedFields returns all numeric fields that were incremented/decremented during
  5250. // this mutation.
  5251. func (m *BatchMsgMutation) AddedFields() []string {
  5252. var fields []string
  5253. if m.addstatus != nil {
  5254. fields = append(fields, batchmsg.FieldStatus)
  5255. }
  5256. if m.addtotal != nil {
  5257. fields = append(fields, batchmsg.FieldTotal)
  5258. }
  5259. if m.addsuccess != nil {
  5260. fields = append(fields, batchmsg.FieldSuccess)
  5261. }
  5262. if m.addfail != nil {
  5263. fields = append(fields, batchmsg.FieldFail)
  5264. }
  5265. if m.add_type != nil {
  5266. fields = append(fields, batchmsg.FieldType)
  5267. }
  5268. if m.addorganization_id != nil {
  5269. fields = append(fields, batchmsg.FieldOrganizationID)
  5270. }
  5271. return fields
  5272. }
  5273. // AddedField returns the numeric value that was incremented/decremented on a field
  5274. // with the given name. The second boolean return value indicates that this field
  5275. // was not set, or was not defined in the schema.
  5276. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5277. switch name {
  5278. case batchmsg.FieldStatus:
  5279. return m.AddedStatus()
  5280. case batchmsg.FieldTotal:
  5281. return m.AddedTotal()
  5282. case batchmsg.FieldSuccess:
  5283. return m.AddedSuccess()
  5284. case batchmsg.FieldFail:
  5285. return m.AddedFail()
  5286. case batchmsg.FieldType:
  5287. return m.AddedType()
  5288. case batchmsg.FieldOrganizationID:
  5289. return m.AddedOrganizationID()
  5290. }
  5291. return nil, false
  5292. }
  5293. // AddField adds the value to the field with the given name. It returns an error if
  5294. // the field is not defined in the schema, or if the type mismatched the field
  5295. // type.
  5296. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5297. switch name {
  5298. case batchmsg.FieldStatus:
  5299. v, ok := value.(int8)
  5300. if !ok {
  5301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5302. }
  5303. m.AddStatus(v)
  5304. return nil
  5305. case batchmsg.FieldTotal:
  5306. v, ok := value.(int32)
  5307. if !ok {
  5308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5309. }
  5310. m.AddTotal(v)
  5311. return nil
  5312. case batchmsg.FieldSuccess:
  5313. v, ok := value.(int32)
  5314. if !ok {
  5315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5316. }
  5317. m.AddSuccess(v)
  5318. return nil
  5319. case batchmsg.FieldFail:
  5320. v, ok := value.(int32)
  5321. if !ok {
  5322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5323. }
  5324. m.AddFail(v)
  5325. return nil
  5326. case batchmsg.FieldType:
  5327. v, ok := value.(int32)
  5328. if !ok {
  5329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5330. }
  5331. m.AddType(v)
  5332. return nil
  5333. case batchmsg.FieldOrganizationID:
  5334. v, ok := value.(int64)
  5335. if !ok {
  5336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5337. }
  5338. m.AddOrganizationID(v)
  5339. return nil
  5340. }
  5341. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5342. }
  5343. // ClearedFields returns all nullable fields that were cleared during this
  5344. // mutation.
  5345. func (m *BatchMsgMutation) ClearedFields() []string {
  5346. var fields []string
  5347. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5348. fields = append(fields, batchmsg.FieldDeletedAt)
  5349. }
  5350. if m.FieldCleared(batchmsg.FieldStatus) {
  5351. fields = append(fields, batchmsg.FieldStatus)
  5352. }
  5353. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5354. fields = append(fields, batchmsg.FieldBatchNo)
  5355. }
  5356. if m.FieldCleared(batchmsg.FieldTaskName) {
  5357. fields = append(fields, batchmsg.FieldTaskName)
  5358. }
  5359. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5360. fields = append(fields, batchmsg.FieldFromwxid)
  5361. }
  5362. if m.FieldCleared(batchmsg.FieldMsg) {
  5363. fields = append(fields, batchmsg.FieldMsg)
  5364. }
  5365. if m.FieldCleared(batchmsg.FieldTag) {
  5366. fields = append(fields, batchmsg.FieldTag)
  5367. }
  5368. if m.FieldCleared(batchmsg.FieldTagids) {
  5369. fields = append(fields, batchmsg.FieldTagids)
  5370. }
  5371. if m.FieldCleared(batchmsg.FieldTotal) {
  5372. fields = append(fields, batchmsg.FieldTotal)
  5373. }
  5374. if m.FieldCleared(batchmsg.FieldSuccess) {
  5375. fields = append(fields, batchmsg.FieldSuccess)
  5376. }
  5377. if m.FieldCleared(batchmsg.FieldFail) {
  5378. fields = append(fields, batchmsg.FieldFail)
  5379. }
  5380. if m.FieldCleared(batchmsg.FieldStartTime) {
  5381. fields = append(fields, batchmsg.FieldStartTime)
  5382. }
  5383. if m.FieldCleared(batchmsg.FieldStopTime) {
  5384. fields = append(fields, batchmsg.FieldStopTime)
  5385. }
  5386. if m.FieldCleared(batchmsg.FieldSendTime) {
  5387. fields = append(fields, batchmsg.FieldSendTime)
  5388. }
  5389. if m.FieldCleared(batchmsg.FieldType) {
  5390. fields = append(fields, batchmsg.FieldType)
  5391. }
  5392. return fields
  5393. }
  5394. // FieldCleared returns a boolean indicating if a field with the given name was
  5395. // cleared in this mutation.
  5396. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5397. _, ok := m.clearedFields[name]
  5398. return ok
  5399. }
  5400. // ClearField clears the value of the field with the given name. It returns an
  5401. // error if the field is not defined in the schema.
  5402. func (m *BatchMsgMutation) ClearField(name string) error {
  5403. switch name {
  5404. case batchmsg.FieldDeletedAt:
  5405. m.ClearDeletedAt()
  5406. return nil
  5407. case batchmsg.FieldStatus:
  5408. m.ClearStatus()
  5409. return nil
  5410. case batchmsg.FieldBatchNo:
  5411. m.ClearBatchNo()
  5412. return nil
  5413. case batchmsg.FieldTaskName:
  5414. m.ClearTaskName()
  5415. return nil
  5416. case batchmsg.FieldFromwxid:
  5417. m.ClearFromwxid()
  5418. return nil
  5419. case batchmsg.FieldMsg:
  5420. m.ClearMsg()
  5421. return nil
  5422. case batchmsg.FieldTag:
  5423. m.ClearTag()
  5424. return nil
  5425. case batchmsg.FieldTagids:
  5426. m.ClearTagids()
  5427. return nil
  5428. case batchmsg.FieldTotal:
  5429. m.ClearTotal()
  5430. return nil
  5431. case batchmsg.FieldSuccess:
  5432. m.ClearSuccess()
  5433. return nil
  5434. case batchmsg.FieldFail:
  5435. m.ClearFail()
  5436. return nil
  5437. case batchmsg.FieldStartTime:
  5438. m.ClearStartTime()
  5439. return nil
  5440. case batchmsg.FieldStopTime:
  5441. m.ClearStopTime()
  5442. return nil
  5443. case batchmsg.FieldSendTime:
  5444. m.ClearSendTime()
  5445. return nil
  5446. case batchmsg.FieldType:
  5447. m.ClearType()
  5448. return nil
  5449. }
  5450. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5451. }
  5452. // ResetField resets all changes in the mutation for the field with the given name.
  5453. // It returns an error if the field is not defined in the schema.
  5454. func (m *BatchMsgMutation) ResetField(name string) error {
  5455. switch name {
  5456. case batchmsg.FieldCreatedAt:
  5457. m.ResetCreatedAt()
  5458. return nil
  5459. case batchmsg.FieldUpdatedAt:
  5460. m.ResetUpdatedAt()
  5461. return nil
  5462. case batchmsg.FieldDeletedAt:
  5463. m.ResetDeletedAt()
  5464. return nil
  5465. case batchmsg.FieldStatus:
  5466. m.ResetStatus()
  5467. return nil
  5468. case batchmsg.FieldBatchNo:
  5469. m.ResetBatchNo()
  5470. return nil
  5471. case batchmsg.FieldTaskName:
  5472. m.ResetTaskName()
  5473. return nil
  5474. case batchmsg.FieldFromwxid:
  5475. m.ResetFromwxid()
  5476. return nil
  5477. case batchmsg.FieldMsg:
  5478. m.ResetMsg()
  5479. return nil
  5480. case batchmsg.FieldTag:
  5481. m.ResetTag()
  5482. return nil
  5483. case batchmsg.FieldTagids:
  5484. m.ResetTagids()
  5485. return nil
  5486. case batchmsg.FieldTotal:
  5487. m.ResetTotal()
  5488. return nil
  5489. case batchmsg.FieldSuccess:
  5490. m.ResetSuccess()
  5491. return nil
  5492. case batchmsg.FieldFail:
  5493. m.ResetFail()
  5494. return nil
  5495. case batchmsg.FieldStartTime:
  5496. m.ResetStartTime()
  5497. return nil
  5498. case batchmsg.FieldStopTime:
  5499. m.ResetStopTime()
  5500. return nil
  5501. case batchmsg.FieldSendTime:
  5502. m.ResetSendTime()
  5503. return nil
  5504. case batchmsg.FieldType:
  5505. m.ResetType()
  5506. return nil
  5507. case batchmsg.FieldOrganizationID:
  5508. m.ResetOrganizationID()
  5509. return nil
  5510. }
  5511. return fmt.Errorf("unknown BatchMsg field %s", name)
  5512. }
  5513. // AddedEdges returns all edge names that were set/added in this mutation.
  5514. func (m *BatchMsgMutation) AddedEdges() []string {
  5515. edges := make([]string, 0, 0)
  5516. return edges
  5517. }
  5518. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5519. // name in this mutation.
  5520. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5521. return nil
  5522. }
  5523. // RemovedEdges returns all edge names that were removed in this mutation.
  5524. func (m *BatchMsgMutation) RemovedEdges() []string {
  5525. edges := make([]string, 0, 0)
  5526. return edges
  5527. }
  5528. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5529. // the given name in this mutation.
  5530. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5531. return nil
  5532. }
  5533. // ClearedEdges returns all edge names that were cleared in this mutation.
  5534. func (m *BatchMsgMutation) ClearedEdges() []string {
  5535. edges := make([]string, 0, 0)
  5536. return edges
  5537. }
  5538. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5539. // was cleared in this mutation.
  5540. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5541. return false
  5542. }
  5543. // ClearEdge clears the value of the edge with the given name. It returns an error
  5544. // if that edge is not defined in the schema.
  5545. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5546. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5547. }
  5548. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5549. // It returns an error if the edge is not defined in the schema.
  5550. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5551. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5552. }
  5553. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5554. type CategoryMutation struct {
  5555. config
  5556. op Op
  5557. typ string
  5558. id *uint64
  5559. created_at *time.Time
  5560. updated_at *time.Time
  5561. deleted_at *time.Time
  5562. name *string
  5563. organization_id *uint64
  5564. addorganization_id *int64
  5565. clearedFields map[string]struct{}
  5566. done bool
  5567. oldValue func(context.Context) (*Category, error)
  5568. predicates []predicate.Category
  5569. }
  5570. var _ ent.Mutation = (*CategoryMutation)(nil)
  5571. // categoryOption allows management of the mutation configuration using functional options.
  5572. type categoryOption func(*CategoryMutation)
  5573. // newCategoryMutation creates new mutation for the Category entity.
  5574. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5575. m := &CategoryMutation{
  5576. config: c,
  5577. op: op,
  5578. typ: TypeCategory,
  5579. clearedFields: make(map[string]struct{}),
  5580. }
  5581. for _, opt := range opts {
  5582. opt(m)
  5583. }
  5584. return m
  5585. }
  5586. // withCategoryID sets the ID field of the mutation.
  5587. func withCategoryID(id uint64) categoryOption {
  5588. return func(m *CategoryMutation) {
  5589. var (
  5590. err error
  5591. once sync.Once
  5592. value *Category
  5593. )
  5594. m.oldValue = func(ctx context.Context) (*Category, error) {
  5595. once.Do(func() {
  5596. if m.done {
  5597. err = errors.New("querying old values post mutation is not allowed")
  5598. } else {
  5599. value, err = m.Client().Category.Get(ctx, id)
  5600. }
  5601. })
  5602. return value, err
  5603. }
  5604. m.id = &id
  5605. }
  5606. }
  5607. // withCategory sets the old Category of the mutation.
  5608. func withCategory(node *Category) categoryOption {
  5609. return func(m *CategoryMutation) {
  5610. m.oldValue = func(context.Context) (*Category, error) {
  5611. return node, nil
  5612. }
  5613. m.id = &node.ID
  5614. }
  5615. }
  5616. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5617. // executed in a transaction (ent.Tx), a transactional client is returned.
  5618. func (m CategoryMutation) Client() *Client {
  5619. client := &Client{config: m.config}
  5620. client.init()
  5621. return client
  5622. }
  5623. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5624. // it returns an error otherwise.
  5625. func (m CategoryMutation) Tx() (*Tx, error) {
  5626. if _, ok := m.driver.(*txDriver); !ok {
  5627. return nil, errors.New("ent: mutation is not running in a transaction")
  5628. }
  5629. tx := &Tx{config: m.config}
  5630. tx.init()
  5631. return tx, nil
  5632. }
  5633. // SetID sets the value of the id field. Note that this
  5634. // operation is only accepted on creation of Category entities.
  5635. func (m *CategoryMutation) SetID(id uint64) {
  5636. m.id = &id
  5637. }
  5638. // ID returns the ID value in the mutation. Note that the ID is only available
  5639. // if it was provided to the builder or after it was returned from the database.
  5640. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5641. if m.id == nil {
  5642. return
  5643. }
  5644. return *m.id, true
  5645. }
  5646. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5647. // That means, if the mutation is applied within a transaction with an isolation level such
  5648. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5649. // or updated by the mutation.
  5650. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5651. switch {
  5652. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5653. id, exists := m.ID()
  5654. if exists {
  5655. return []uint64{id}, nil
  5656. }
  5657. fallthrough
  5658. case m.op.Is(OpUpdate | OpDelete):
  5659. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5660. default:
  5661. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5662. }
  5663. }
  5664. // SetCreatedAt sets the "created_at" field.
  5665. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5666. m.created_at = &t
  5667. }
  5668. // CreatedAt returns the value of the "created_at" field in the mutation.
  5669. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5670. v := m.created_at
  5671. if v == nil {
  5672. return
  5673. }
  5674. return *v, true
  5675. }
  5676. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5677. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5679. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5680. if !m.op.Is(OpUpdateOne) {
  5681. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5682. }
  5683. if m.id == nil || m.oldValue == nil {
  5684. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5685. }
  5686. oldValue, err := m.oldValue(ctx)
  5687. if err != nil {
  5688. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5689. }
  5690. return oldValue.CreatedAt, nil
  5691. }
  5692. // ResetCreatedAt resets all changes to the "created_at" field.
  5693. func (m *CategoryMutation) ResetCreatedAt() {
  5694. m.created_at = nil
  5695. }
  5696. // SetUpdatedAt sets the "updated_at" field.
  5697. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5698. m.updated_at = &t
  5699. }
  5700. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5701. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5702. v := m.updated_at
  5703. if v == nil {
  5704. return
  5705. }
  5706. return *v, true
  5707. }
  5708. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5709. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5711. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5712. if !m.op.Is(OpUpdateOne) {
  5713. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5714. }
  5715. if m.id == nil || m.oldValue == nil {
  5716. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5717. }
  5718. oldValue, err := m.oldValue(ctx)
  5719. if err != nil {
  5720. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5721. }
  5722. return oldValue.UpdatedAt, nil
  5723. }
  5724. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5725. func (m *CategoryMutation) ResetUpdatedAt() {
  5726. m.updated_at = nil
  5727. }
  5728. // SetDeletedAt sets the "deleted_at" field.
  5729. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5730. m.deleted_at = &t
  5731. }
  5732. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5733. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5734. v := m.deleted_at
  5735. if v == nil {
  5736. return
  5737. }
  5738. return *v, true
  5739. }
  5740. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5741. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5743. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5744. if !m.op.Is(OpUpdateOne) {
  5745. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5746. }
  5747. if m.id == nil || m.oldValue == nil {
  5748. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5749. }
  5750. oldValue, err := m.oldValue(ctx)
  5751. if err != nil {
  5752. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5753. }
  5754. return oldValue.DeletedAt, nil
  5755. }
  5756. // ClearDeletedAt clears the value of the "deleted_at" field.
  5757. func (m *CategoryMutation) ClearDeletedAt() {
  5758. m.deleted_at = nil
  5759. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5760. }
  5761. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5762. func (m *CategoryMutation) DeletedAtCleared() bool {
  5763. _, ok := m.clearedFields[category.FieldDeletedAt]
  5764. return ok
  5765. }
  5766. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5767. func (m *CategoryMutation) ResetDeletedAt() {
  5768. m.deleted_at = nil
  5769. delete(m.clearedFields, category.FieldDeletedAt)
  5770. }
  5771. // SetName sets the "name" field.
  5772. func (m *CategoryMutation) SetName(s string) {
  5773. m.name = &s
  5774. }
  5775. // Name returns the value of the "name" field in the mutation.
  5776. func (m *CategoryMutation) Name() (r string, exists bool) {
  5777. v := m.name
  5778. if v == nil {
  5779. return
  5780. }
  5781. return *v, true
  5782. }
  5783. // OldName returns the old "name" field's value of the Category entity.
  5784. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5786. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5787. if !m.op.Is(OpUpdateOne) {
  5788. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5789. }
  5790. if m.id == nil || m.oldValue == nil {
  5791. return v, errors.New("OldName requires an ID field in the mutation")
  5792. }
  5793. oldValue, err := m.oldValue(ctx)
  5794. if err != nil {
  5795. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5796. }
  5797. return oldValue.Name, nil
  5798. }
  5799. // ResetName resets all changes to the "name" field.
  5800. func (m *CategoryMutation) ResetName() {
  5801. m.name = nil
  5802. }
  5803. // SetOrganizationID sets the "organization_id" field.
  5804. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5805. m.organization_id = &u
  5806. m.addorganization_id = nil
  5807. }
  5808. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5809. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5810. v := m.organization_id
  5811. if v == nil {
  5812. return
  5813. }
  5814. return *v, true
  5815. }
  5816. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5817. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5819. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5820. if !m.op.Is(OpUpdateOne) {
  5821. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5822. }
  5823. if m.id == nil || m.oldValue == nil {
  5824. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5825. }
  5826. oldValue, err := m.oldValue(ctx)
  5827. if err != nil {
  5828. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5829. }
  5830. return oldValue.OrganizationID, nil
  5831. }
  5832. // AddOrganizationID adds u to the "organization_id" field.
  5833. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5834. if m.addorganization_id != nil {
  5835. *m.addorganization_id += u
  5836. } else {
  5837. m.addorganization_id = &u
  5838. }
  5839. }
  5840. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5841. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5842. v := m.addorganization_id
  5843. if v == nil {
  5844. return
  5845. }
  5846. return *v, true
  5847. }
  5848. // ResetOrganizationID resets all changes to the "organization_id" field.
  5849. func (m *CategoryMutation) ResetOrganizationID() {
  5850. m.organization_id = nil
  5851. m.addorganization_id = nil
  5852. }
  5853. // Where appends a list predicates to the CategoryMutation builder.
  5854. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5855. m.predicates = append(m.predicates, ps...)
  5856. }
  5857. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5858. // users can use type-assertion to append predicates that do not depend on any generated package.
  5859. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5860. p := make([]predicate.Category, len(ps))
  5861. for i := range ps {
  5862. p[i] = ps[i]
  5863. }
  5864. m.Where(p...)
  5865. }
  5866. // Op returns the operation name.
  5867. func (m *CategoryMutation) Op() Op {
  5868. return m.op
  5869. }
  5870. // SetOp allows setting the mutation operation.
  5871. func (m *CategoryMutation) SetOp(op Op) {
  5872. m.op = op
  5873. }
  5874. // Type returns the node type of this mutation (Category).
  5875. func (m *CategoryMutation) Type() string {
  5876. return m.typ
  5877. }
  5878. // Fields returns all fields that were changed during this mutation. Note that in
  5879. // order to get all numeric fields that were incremented/decremented, call
  5880. // AddedFields().
  5881. func (m *CategoryMutation) Fields() []string {
  5882. fields := make([]string, 0, 5)
  5883. if m.created_at != nil {
  5884. fields = append(fields, category.FieldCreatedAt)
  5885. }
  5886. if m.updated_at != nil {
  5887. fields = append(fields, category.FieldUpdatedAt)
  5888. }
  5889. if m.deleted_at != nil {
  5890. fields = append(fields, category.FieldDeletedAt)
  5891. }
  5892. if m.name != nil {
  5893. fields = append(fields, category.FieldName)
  5894. }
  5895. if m.organization_id != nil {
  5896. fields = append(fields, category.FieldOrganizationID)
  5897. }
  5898. return fields
  5899. }
  5900. // Field returns the value of a field with the given name. The second boolean
  5901. // return value indicates that this field was not set, or was not defined in the
  5902. // schema.
  5903. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5904. switch name {
  5905. case category.FieldCreatedAt:
  5906. return m.CreatedAt()
  5907. case category.FieldUpdatedAt:
  5908. return m.UpdatedAt()
  5909. case category.FieldDeletedAt:
  5910. return m.DeletedAt()
  5911. case category.FieldName:
  5912. return m.Name()
  5913. case category.FieldOrganizationID:
  5914. return m.OrganizationID()
  5915. }
  5916. return nil, false
  5917. }
  5918. // OldField returns the old value of the field from the database. An error is
  5919. // returned if the mutation operation is not UpdateOne, or the query to the
  5920. // database failed.
  5921. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5922. switch name {
  5923. case category.FieldCreatedAt:
  5924. return m.OldCreatedAt(ctx)
  5925. case category.FieldUpdatedAt:
  5926. return m.OldUpdatedAt(ctx)
  5927. case category.FieldDeletedAt:
  5928. return m.OldDeletedAt(ctx)
  5929. case category.FieldName:
  5930. return m.OldName(ctx)
  5931. case category.FieldOrganizationID:
  5932. return m.OldOrganizationID(ctx)
  5933. }
  5934. return nil, fmt.Errorf("unknown Category field %s", name)
  5935. }
  5936. // SetField sets the value of a field with the given name. It returns an error if
  5937. // the field is not defined in the schema, or if the type mismatched the field
  5938. // type.
  5939. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5940. switch name {
  5941. case category.FieldCreatedAt:
  5942. v, ok := value.(time.Time)
  5943. if !ok {
  5944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5945. }
  5946. m.SetCreatedAt(v)
  5947. return nil
  5948. case category.FieldUpdatedAt:
  5949. v, ok := value.(time.Time)
  5950. if !ok {
  5951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5952. }
  5953. m.SetUpdatedAt(v)
  5954. return nil
  5955. case category.FieldDeletedAt:
  5956. v, ok := value.(time.Time)
  5957. if !ok {
  5958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5959. }
  5960. m.SetDeletedAt(v)
  5961. return nil
  5962. case category.FieldName:
  5963. v, ok := value.(string)
  5964. if !ok {
  5965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5966. }
  5967. m.SetName(v)
  5968. return nil
  5969. case category.FieldOrganizationID:
  5970. v, ok := value.(uint64)
  5971. if !ok {
  5972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5973. }
  5974. m.SetOrganizationID(v)
  5975. return nil
  5976. }
  5977. return fmt.Errorf("unknown Category field %s", name)
  5978. }
  5979. // AddedFields returns all numeric fields that were incremented/decremented during
  5980. // this mutation.
  5981. func (m *CategoryMutation) AddedFields() []string {
  5982. var fields []string
  5983. if m.addorganization_id != nil {
  5984. fields = append(fields, category.FieldOrganizationID)
  5985. }
  5986. return fields
  5987. }
  5988. // AddedField returns the numeric value that was incremented/decremented on a field
  5989. // with the given name. The second boolean return value indicates that this field
  5990. // was not set, or was not defined in the schema.
  5991. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5992. switch name {
  5993. case category.FieldOrganizationID:
  5994. return m.AddedOrganizationID()
  5995. }
  5996. return nil, false
  5997. }
  5998. // AddField adds the value to the field with the given name. It returns an error if
  5999. // the field is not defined in the schema, or if the type mismatched the field
  6000. // type.
  6001. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6002. switch name {
  6003. case category.FieldOrganizationID:
  6004. v, ok := value.(int64)
  6005. if !ok {
  6006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6007. }
  6008. m.AddOrganizationID(v)
  6009. return nil
  6010. }
  6011. return fmt.Errorf("unknown Category numeric field %s", name)
  6012. }
  6013. // ClearedFields returns all nullable fields that were cleared during this
  6014. // mutation.
  6015. func (m *CategoryMutation) ClearedFields() []string {
  6016. var fields []string
  6017. if m.FieldCleared(category.FieldDeletedAt) {
  6018. fields = append(fields, category.FieldDeletedAt)
  6019. }
  6020. return fields
  6021. }
  6022. // FieldCleared returns a boolean indicating if a field with the given name was
  6023. // cleared in this mutation.
  6024. func (m *CategoryMutation) FieldCleared(name string) bool {
  6025. _, ok := m.clearedFields[name]
  6026. return ok
  6027. }
  6028. // ClearField clears the value of the field with the given name. It returns an
  6029. // error if the field is not defined in the schema.
  6030. func (m *CategoryMutation) ClearField(name string) error {
  6031. switch name {
  6032. case category.FieldDeletedAt:
  6033. m.ClearDeletedAt()
  6034. return nil
  6035. }
  6036. return fmt.Errorf("unknown Category nullable field %s", name)
  6037. }
  6038. // ResetField resets all changes in the mutation for the field with the given name.
  6039. // It returns an error if the field is not defined in the schema.
  6040. func (m *CategoryMutation) ResetField(name string) error {
  6041. switch name {
  6042. case category.FieldCreatedAt:
  6043. m.ResetCreatedAt()
  6044. return nil
  6045. case category.FieldUpdatedAt:
  6046. m.ResetUpdatedAt()
  6047. return nil
  6048. case category.FieldDeletedAt:
  6049. m.ResetDeletedAt()
  6050. return nil
  6051. case category.FieldName:
  6052. m.ResetName()
  6053. return nil
  6054. case category.FieldOrganizationID:
  6055. m.ResetOrganizationID()
  6056. return nil
  6057. }
  6058. return fmt.Errorf("unknown Category field %s", name)
  6059. }
  6060. // AddedEdges returns all edge names that were set/added in this mutation.
  6061. func (m *CategoryMutation) AddedEdges() []string {
  6062. edges := make([]string, 0, 0)
  6063. return edges
  6064. }
  6065. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6066. // name in this mutation.
  6067. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6068. return nil
  6069. }
  6070. // RemovedEdges returns all edge names that were removed in this mutation.
  6071. func (m *CategoryMutation) RemovedEdges() []string {
  6072. edges := make([]string, 0, 0)
  6073. return edges
  6074. }
  6075. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6076. // the given name in this mutation.
  6077. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6078. return nil
  6079. }
  6080. // ClearedEdges returns all edge names that were cleared in this mutation.
  6081. func (m *CategoryMutation) ClearedEdges() []string {
  6082. edges := make([]string, 0, 0)
  6083. return edges
  6084. }
  6085. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6086. // was cleared in this mutation.
  6087. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6088. return false
  6089. }
  6090. // ClearEdge clears the value of the edge with the given name. It returns an error
  6091. // if that edge is not defined in the schema.
  6092. func (m *CategoryMutation) ClearEdge(name string) error {
  6093. return fmt.Errorf("unknown Category unique edge %s", name)
  6094. }
  6095. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6096. // It returns an error if the edge is not defined in the schema.
  6097. func (m *CategoryMutation) ResetEdge(name string) error {
  6098. return fmt.Errorf("unknown Category edge %s", name)
  6099. }
  6100. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6101. type ChatRecordsMutation struct {
  6102. config
  6103. op Op
  6104. typ string
  6105. id *uint64
  6106. created_at *time.Time
  6107. updated_at *time.Time
  6108. deleted_at *time.Time
  6109. content *string
  6110. content_type *uint8
  6111. addcontent_type *int8
  6112. session_id *uint64
  6113. addsession_id *int64
  6114. user_id *uint64
  6115. adduser_id *int64
  6116. bot_id *uint64
  6117. addbot_id *int64
  6118. bot_type *uint8
  6119. addbot_type *int8
  6120. clearedFields map[string]struct{}
  6121. done bool
  6122. oldValue func(context.Context) (*ChatRecords, error)
  6123. predicates []predicate.ChatRecords
  6124. }
  6125. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6126. // chatrecordsOption allows management of the mutation configuration using functional options.
  6127. type chatrecordsOption func(*ChatRecordsMutation)
  6128. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6129. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6130. m := &ChatRecordsMutation{
  6131. config: c,
  6132. op: op,
  6133. typ: TypeChatRecords,
  6134. clearedFields: make(map[string]struct{}),
  6135. }
  6136. for _, opt := range opts {
  6137. opt(m)
  6138. }
  6139. return m
  6140. }
  6141. // withChatRecordsID sets the ID field of the mutation.
  6142. func withChatRecordsID(id uint64) chatrecordsOption {
  6143. return func(m *ChatRecordsMutation) {
  6144. var (
  6145. err error
  6146. once sync.Once
  6147. value *ChatRecords
  6148. )
  6149. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6150. once.Do(func() {
  6151. if m.done {
  6152. err = errors.New("querying old values post mutation is not allowed")
  6153. } else {
  6154. value, err = m.Client().ChatRecords.Get(ctx, id)
  6155. }
  6156. })
  6157. return value, err
  6158. }
  6159. m.id = &id
  6160. }
  6161. }
  6162. // withChatRecords sets the old ChatRecords of the mutation.
  6163. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6164. return func(m *ChatRecordsMutation) {
  6165. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6166. return node, nil
  6167. }
  6168. m.id = &node.ID
  6169. }
  6170. }
  6171. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6172. // executed in a transaction (ent.Tx), a transactional client is returned.
  6173. func (m ChatRecordsMutation) Client() *Client {
  6174. client := &Client{config: m.config}
  6175. client.init()
  6176. return client
  6177. }
  6178. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6179. // it returns an error otherwise.
  6180. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6181. if _, ok := m.driver.(*txDriver); !ok {
  6182. return nil, errors.New("ent: mutation is not running in a transaction")
  6183. }
  6184. tx := &Tx{config: m.config}
  6185. tx.init()
  6186. return tx, nil
  6187. }
  6188. // SetID sets the value of the id field. Note that this
  6189. // operation is only accepted on creation of ChatRecords entities.
  6190. func (m *ChatRecordsMutation) SetID(id uint64) {
  6191. m.id = &id
  6192. }
  6193. // ID returns the ID value in the mutation. Note that the ID is only available
  6194. // if it was provided to the builder or after it was returned from the database.
  6195. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6196. if m.id == nil {
  6197. return
  6198. }
  6199. return *m.id, true
  6200. }
  6201. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6202. // That means, if the mutation is applied within a transaction with an isolation level such
  6203. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6204. // or updated by the mutation.
  6205. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6206. switch {
  6207. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6208. id, exists := m.ID()
  6209. if exists {
  6210. return []uint64{id}, nil
  6211. }
  6212. fallthrough
  6213. case m.op.Is(OpUpdate | OpDelete):
  6214. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6215. default:
  6216. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6217. }
  6218. }
  6219. // SetCreatedAt sets the "created_at" field.
  6220. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6221. m.created_at = &t
  6222. }
  6223. // CreatedAt returns the value of the "created_at" field in the mutation.
  6224. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6225. v := m.created_at
  6226. if v == nil {
  6227. return
  6228. }
  6229. return *v, true
  6230. }
  6231. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6232. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6234. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6235. if !m.op.Is(OpUpdateOne) {
  6236. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6237. }
  6238. if m.id == nil || m.oldValue == nil {
  6239. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6240. }
  6241. oldValue, err := m.oldValue(ctx)
  6242. if err != nil {
  6243. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6244. }
  6245. return oldValue.CreatedAt, nil
  6246. }
  6247. // ResetCreatedAt resets all changes to the "created_at" field.
  6248. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6249. m.created_at = nil
  6250. }
  6251. // SetUpdatedAt sets the "updated_at" field.
  6252. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6253. m.updated_at = &t
  6254. }
  6255. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6256. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6257. v := m.updated_at
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6264. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6276. }
  6277. return oldValue.UpdatedAt, nil
  6278. }
  6279. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6280. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6281. m.updated_at = nil
  6282. }
  6283. // SetDeletedAt sets the "deleted_at" field.
  6284. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6285. m.deleted_at = &t
  6286. }
  6287. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6288. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6289. v := m.deleted_at
  6290. if v == nil {
  6291. return
  6292. }
  6293. return *v, true
  6294. }
  6295. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6296. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6298. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6299. if !m.op.Is(OpUpdateOne) {
  6300. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6301. }
  6302. if m.id == nil || m.oldValue == nil {
  6303. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6304. }
  6305. oldValue, err := m.oldValue(ctx)
  6306. if err != nil {
  6307. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6308. }
  6309. return oldValue.DeletedAt, nil
  6310. }
  6311. // ClearDeletedAt clears the value of the "deleted_at" field.
  6312. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6313. m.deleted_at = nil
  6314. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6315. }
  6316. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6317. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6318. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6319. return ok
  6320. }
  6321. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6322. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6323. m.deleted_at = nil
  6324. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6325. }
  6326. // SetContent sets the "content" field.
  6327. func (m *ChatRecordsMutation) SetContent(s string) {
  6328. m.content = &s
  6329. }
  6330. // Content returns the value of the "content" field in the mutation.
  6331. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6332. v := m.content
  6333. if v == nil {
  6334. return
  6335. }
  6336. return *v, true
  6337. }
  6338. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6339. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6341. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6342. if !m.op.Is(OpUpdateOne) {
  6343. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6344. }
  6345. if m.id == nil || m.oldValue == nil {
  6346. return v, errors.New("OldContent requires an ID field in the mutation")
  6347. }
  6348. oldValue, err := m.oldValue(ctx)
  6349. if err != nil {
  6350. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6351. }
  6352. return oldValue.Content, nil
  6353. }
  6354. // ResetContent resets all changes to the "content" field.
  6355. func (m *ChatRecordsMutation) ResetContent() {
  6356. m.content = nil
  6357. }
  6358. // SetContentType sets the "content_type" field.
  6359. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6360. m.content_type = &u
  6361. m.addcontent_type = nil
  6362. }
  6363. // ContentType returns the value of the "content_type" field in the mutation.
  6364. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6365. v := m.content_type
  6366. if v == nil {
  6367. return
  6368. }
  6369. return *v, true
  6370. }
  6371. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6372. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6374. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6375. if !m.op.Is(OpUpdateOne) {
  6376. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6377. }
  6378. if m.id == nil || m.oldValue == nil {
  6379. return v, errors.New("OldContentType requires an ID field in the mutation")
  6380. }
  6381. oldValue, err := m.oldValue(ctx)
  6382. if err != nil {
  6383. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6384. }
  6385. return oldValue.ContentType, nil
  6386. }
  6387. // AddContentType adds u to the "content_type" field.
  6388. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6389. if m.addcontent_type != nil {
  6390. *m.addcontent_type += u
  6391. } else {
  6392. m.addcontent_type = &u
  6393. }
  6394. }
  6395. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6396. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6397. v := m.addcontent_type
  6398. if v == nil {
  6399. return
  6400. }
  6401. return *v, true
  6402. }
  6403. // ResetContentType resets all changes to the "content_type" field.
  6404. func (m *ChatRecordsMutation) ResetContentType() {
  6405. m.content_type = nil
  6406. m.addcontent_type = nil
  6407. }
  6408. // SetSessionID sets the "session_id" field.
  6409. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6410. m.session_id = &u
  6411. m.addsession_id = nil
  6412. }
  6413. // SessionID returns the value of the "session_id" field in the mutation.
  6414. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6415. v := m.session_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6422. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6424. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6425. if !m.op.Is(OpUpdateOne) {
  6426. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6427. }
  6428. if m.id == nil || m.oldValue == nil {
  6429. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6430. }
  6431. oldValue, err := m.oldValue(ctx)
  6432. if err != nil {
  6433. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6434. }
  6435. return oldValue.SessionID, nil
  6436. }
  6437. // AddSessionID adds u to the "session_id" field.
  6438. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6439. if m.addsession_id != nil {
  6440. *m.addsession_id += u
  6441. } else {
  6442. m.addsession_id = &u
  6443. }
  6444. }
  6445. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6446. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6447. v := m.addsession_id
  6448. if v == nil {
  6449. return
  6450. }
  6451. return *v, true
  6452. }
  6453. // ResetSessionID resets all changes to the "session_id" field.
  6454. func (m *ChatRecordsMutation) ResetSessionID() {
  6455. m.session_id = nil
  6456. m.addsession_id = nil
  6457. }
  6458. // SetUserID sets the "user_id" field.
  6459. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6460. m.user_id = &u
  6461. m.adduser_id = nil
  6462. }
  6463. // UserID returns the value of the "user_id" field in the mutation.
  6464. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6465. v := m.user_id
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6472. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6474. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6475. if !m.op.Is(OpUpdateOne) {
  6476. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6477. }
  6478. if m.id == nil || m.oldValue == nil {
  6479. return v, errors.New("OldUserID requires an ID field in the mutation")
  6480. }
  6481. oldValue, err := m.oldValue(ctx)
  6482. if err != nil {
  6483. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6484. }
  6485. return oldValue.UserID, nil
  6486. }
  6487. // AddUserID adds u to the "user_id" field.
  6488. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6489. if m.adduser_id != nil {
  6490. *m.adduser_id += u
  6491. } else {
  6492. m.adduser_id = &u
  6493. }
  6494. }
  6495. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6496. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6497. v := m.adduser_id
  6498. if v == nil {
  6499. return
  6500. }
  6501. return *v, true
  6502. }
  6503. // ResetUserID resets all changes to the "user_id" field.
  6504. func (m *ChatRecordsMutation) ResetUserID() {
  6505. m.user_id = nil
  6506. m.adduser_id = nil
  6507. }
  6508. // SetBotID sets the "bot_id" field.
  6509. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6510. m.bot_id = &u
  6511. m.addbot_id = nil
  6512. }
  6513. // BotID returns the value of the "bot_id" field in the mutation.
  6514. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6515. v := m.bot_id
  6516. if v == nil {
  6517. return
  6518. }
  6519. return *v, true
  6520. }
  6521. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6522. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6524. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6525. if !m.op.Is(OpUpdateOne) {
  6526. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6527. }
  6528. if m.id == nil || m.oldValue == nil {
  6529. return v, errors.New("OldBotID requires an ID field in the mutation")
  6530. }
  6531. oldValue, err := m.oldValue(ctx)
  6532. if err != nil {
  6533. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6534. }
  6535. return oldValue.BotID, nil
  6536. }
  6537. // AddBotID adds u to the "bot_id" field.
  6538. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6539. if m.addbot_id != nil {
  6540. *m.addbot_id += u
  6541. } else {
  6542. m.addbot_id = &u
  6543. }
  6544. }
  6545. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6546. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6547. v := m.addbot_id
  6548. if v == nil {
  6549. return
  6550. }
  6551. return *v, true
  6552. }
  6553. // ResetBotID resets all changes to the "bot_id" field.
  6554. func (m *ChatRecordsMutation) ResetBotID() {
  6555. m.bot_id = nil
  6556. m.addbot_id = nil
  6557. }
  6558. // SetBotType sets the "bot_type" field.
  6559. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6560. m.bot_type = &u
  6561. m.addbot_type = nil
  6562. }
  6563. // BotType returns the value of the "bot_type" field in the mutation.
  6564. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6565. v := m.bot_type
  6566. if v == nil {
  6567. return
  6568. }
  6569. return *v, true
  6570. }
  6571. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6572. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6574. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6575. if !m.op.Is(OpUpdateOne) {
  6576. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6577. }
  6578. if m.id == nil || m.oldValue == nil {
  6579. return v, errors.New("OldBotType requires an ID field in the mutation")
  6580. }
  6581. oldValue, err := m.oldValue(ctx)
  6582. if err != nil {
  6583. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6584. }
  6585. return oldValue.BotType, nil
  6586. }
  6587. // AddBotType adds u to the "bot_type" field.
  6588. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6589. if m.addbot_type != nil {
  6590. *m.addbot_type += u
  6591. } else {
  6592. m.addbot_type = &u
  6593. }
  6594. }
  6595. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6596. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6597. v := m.addbot_type
  6598. if v == nil {
  6599. return
  6600. }
  6601. return *v, true
  6602. }
  6603. // ResetBotType resets all changes to the "bot_type" field.
  6604. func (m *ChatRecordsMutation) ResetBotType() {
  6605. m.bot_type = nil
  6606. m.addbot_type = nil
  6607. }
  6608. // Where appends a list predicates to the ChatRecordsMutation builder.
  6609. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6610. m.predicates = append(m.predicates, ps...)
  6611. }
  6612. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6613. // users can use type-assertion to append predicates that do not depend on any generated package.
  6614. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6615. p := make([]predicate.ChatRecords, len(ps))
  6616. for i := range ps {
  6617. p[i] = ps[i]
  6618. }
  6619. m.Where(p...)
  6620. }
  6621. // Op returns the operation name.
  6622. func (m *ChatRecordsMutation) Op() Op {
  6623. return m.op
  6624. }
  6625. // SetOp allows setting the mutation operation.
  6626. func (m *ChatRecordsMutation) SetOp(op Op) {
  6627. m.op = op
  6628. }
  6629. // Type returns the node type of this mutation (ChatRecords).
  6630. func (m *ChatRecordsMutation) Type() string {
  6631. return m.typ
  6632. }
  6633. // Fields returns all fields that were changed during this mutation. Note that in
  6634. // order to get all numeric fields that were incremented/decremented, call
  6635. // AddedFields().
  6636. func (m *ChatRecordsMutation) Fields() []string {
  6637. fields := make([]string, 0, 9)
  6638. if m.created_at != nil {
  6639. fields = append(fields, chatrecords.FieldCreatedAt)
  6640. }
  6641. if m.updated_at != nil {
  6642. fields = append(fields, chatrecords.FieldUpdatedAt)
  6643. }
  6644. if m.deleted_at != nil {
  6645. fields = append(fields, chatrecords.FieldDeletedAt)
  6646. }
  6647. if m.content != nil {
  6648. fields = append(fields, chatrecords.FieldContent)
  6649. }
  6650. if m.content_type != nil {
  6651. fields = append(fields, chatrecords.FieldContentType)
  6652. }
  6653. if m.session_id != nil {
  6654. fields = append(fields, chatrecords.FieldSessionID)
  6655. }
  6656. if m.user_id != nil {
  6657. fields = append(fields, chatrecords.FieldUserID)
  6658. }
  6659. if m.bot_id != nil {
  6660. fields = append(fields, chatrecords.FieldBotID)
  6661. }
  6662. if m.bot_type != nil {
  6663. fields = append(fields, chatrecords.FieldBotType)
  6664. }
  6665. return fields
  6666. }
  6667. // Field returns the value of a field with the given name. The second boolean
  6668. // return value indicates that this field was not set, or was not defined in the
  6669. // schema.
  6670. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6671. switch name {
  6672. case chatrecords.FieldCreatedAt:
  6673. return m.CreatedAt()
  6674. case chatrecords.FieldUpdatedAt:
  6675. return m.UpdatedAt()
  6676. case chatrecords.FieldDeletedAt:
  6677. return m.DeletedAt()
  6678. case chatrecords.FieldContent:
  6679. return m.Content()
  6680. case chatrecords.FieldContentType:
  6681. return m.ContentType()
  6682. case chatrecords.FieldSessionID:
  6683. return m.SessionID()
  6684. case chatrecords.FieldUserID:
  6685. return m.UserID()
  6686. case chatrecords.FieldBotID:
  6687. return m.BotID()
  6688. case chatrecords.FieldBotType:
  6689. return m.BotType()
  6690. }
  6691. return nil, false
  6692. }
  6693. // OldField returns the old value of the field from the database. An error is
  6694. // returned if the mutation operation is not UpdateOne, or the query to the
  6695. // database failed.
  6696. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6697. switch name {
  6698. case chatrecords.FieldCreatedAt:
  6699. return m.OldCreatedAt(ctx)
  6700. case chatrecords.FieldUpdatedAt:
  6701. return m.OldUpdatedAt(ctx)
  6702. case chatrecords.FieldDeletedAt:
  6703. return m.OldDeletedAt(ctx)
  6704. case chatrecords.FieldContent:
  6705. return m.OldContent(ctx)
  6706. case chatrecords.FieldContentType:
  6707. return m.OldContentType(ctx)
  6708. case chatrecords.FieldSessionID:
  6709. return m.OldSessionID(ctx)
  6710. case chatrecords.FieldUserID:
  6711. return m.OldUserID(ctx)
  6712. case chatrecords.FieldBotID:
  6713. return m.OldBotID(ctx)
  6714. case chatrecords.FieldBotType:
  6715. return m.OldBotType(ctx)
  6716. }
  6717. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6718. }
  6719. // SetField sets the value of a field with the given name. It returns an error if
  6720. // the field is not defined in the schema, or if the type mismatched the field
  6721. // type.
  6722. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6723. switch name {
  6724. case chatrecords.FieldCreatedAt:
  6725. v, ok := value.(time.Time)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCreatedAt(v)
  6730. return nil
  6731. case chatrecords.FieldUpdatedAt:
  6732. v, ok := value.(time.Time)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetUpdatedAt(v)
  6737. return nil
  6738. case chatrecords.FieldDeletedAt:
  6739. v, ok := value.(time.Time)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetDeletedAt(v)
  6744. return nil
  6745. case chatrecords.FieldContent:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetContent(v)
  6751. return nil
  6752. case chatrecords.FieldContentType:
  6753. v, ok := value.(uint8)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetContentType(v)
  6758. return nil
  6759. case chatrecords.FieldSessionID:
  6760. v, ok := value.(uint64)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.SetSessionID(v)
  6765. return nil
  6766. case chatrecords.FieldUserID:
  6767. v, ok := value.(uint64)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.SetUserID(v)
  6772. return nil
  6773. case chatrecords.FieldBotID:
  6774. v, ok := value.(uint64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.SetBotID(v)
  6779. return nil
  6780. case chatrecords.FieldBotType:
  6781. v, ok := value.(uint8)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.SetBotType(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown ChatRecords field %s", name)
  6789. }
  6790. // AddedFields returns all numeric fields that were incremented/decremented during
  6791. // this mutation.
  6792. func (m *ChatRecordsMutation) AddedFields() []string {
  6793. var fields []string
  6794. if m.addcontent_type != nil {
  6795. fields = append(fields, chatrecords.FieldContentType)
  6796. }
  6797. if m.addsession_id != nil {
  6798. fields = append(fields, chatrecords.FieldSessionID)
  6799. }
  6800. if m.adduser_id != nil {
  6801. fields = append(fields, chatrecords.FieldUserID)
  6802. }
  6803. if m.addbot_id != nil {
  6804. fields = append(fields, chatrecords.FieldBotID)
  6805. }
  6806. if m.addbot_type != nil {
  6807. fields = append(fields, chatrecords.FieldBotType)
  6808. }
  6809. return fields
  6810. }
  6811. // AddedField returns the numeric value that was incremented/decremented on a field
  6812. // with the given name. The second boolean return value indicates that this field
  6813. // was not set, or was not defined in the schema.
  6814. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6815. switch name {
  6816. case chatrecords.FieldContentType:
  6817. return m.AddedContentType()
  6818. case chatrecords.FieldSessionID:
  6819. return m.AddedSessionID()
  6820. case chatrecords.FieldUserID:
  6821. return m.AddedUserID()
  6822. case chatrecords.FieldBotID:
  6823. return m.AddedBotID()
  6824. case chatrecords.FieldBotType:
  6825. return m.AddedBotType()
  6826. }
  6827. return nil, false
  6828. }
  6829. // AddField adds the value to the field with the given name. It returns an error if
  6830. // the field is not defined in the schema, or if the type mismatched the field
  6831. // type.
  6832. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6833. switch name {
  6834. case chatrecords.FieldContentType:
  6835. v, ok := value.(int8)
  6836. if !ok {
  6837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6838. }
  6839. m.AddContentType(v)
  6840. return nil
  6841. case chatrecords.FieldSessionID:
  6842. v, ok := value.(int64)
  6843. if !ok {
  6844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6845. }
  6846. m.AddSessionID(v)
  6847. return nil
  6848. case chatrecords.FieldUserID:
  6849. v, ok := value.(int64)
  6850. if !ok {
  6851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6852. }
  6853. m.AddUserID(v)
  6854. return nil
  6855. case chatrecords.FieldBotID:
  6856. v, ok := value.(int64)
  6857. if !ok {
  6858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6859. }
  6860. m.AddBotID(v)
  6861. return nil
  6862. case chatrecords.FieldBotType:
  6863. v, ok := value.(int8)
  6864. if !ok {
  6865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6866. }
  6867. m.AddBotType(v)
  6868. return nil
  6869. }
  6870. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6871. }
  6872. // ClearedFields returns all nullable fields that were cleared during this
  6873. // mutation.
  6874. func (m *ChatRecordsMutation) ClearedFields() []string {
  6875. var fields []string
  6876. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6877. fields = append(fields, chatrecords.FieldDeletedAt)
  6878. }
  6879. return fields
  6880. }
  6881. // FieldCleared returns a boolean indicating if a field with the given name was
  6882. // cleared in this mutation.
  6883. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6884. _, ok := m.clearedFields[name]
  6885. return ok
  6886. }
  6887. // ClearField clears the value of the field with the given name. It returns an
  6888. // error if the field is not defined in the schema.
  6889. func (m *ChatRecordsMutation) ClearField(name string) error {
  6890. switch name {
  6891. case chatrecords.FieldDeletedAt:
  6892. m.ClearDeletedAt()
  6893. return nil
  6894. }
  6895. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6896. }
  6897. // ResetField resets all changes in the mutation for the field with the given name.
  6898. // It returns an error if the field is not defined in the schema.
  6899. func (m *ChatRecordsMutation) ResetField(name string) error {
  6900. switch name {
  6901. case chatrecords.FieldCreatedAt:
  6902. m.ResetCreatedAt()
  6903. return nil
  6904. case chatrecords.FieldUpdatedAt:
  6905. m.ResetUpdatedAt()
  6906. return nil
  6907. case chatrecords.FieldDeletedAt:
  6908. m.ResetDeletedAt()
  6909. return nil
  6910. case chatrecords.FieldContent:
  6911. m.ResetContent()
  6912. return nil
  6913. case chatrecords.FieldContentType:
  6914. m.ResetContentType()
  6915. return nil
  6916. case chatrecords.FieldSessionID:
  6917. m.ResetSessionID()
  6918. return nil
  6919. case chatrecords.FieldUserID:
  6920. m.ResetUserID()
  6921. return nil
  6922. case chatrecords.FieldBotID:
  6923. m.ResetBotID()
  6924. return nil
  6925. case chatrecords.FieldBotType:
  6926. m.ResetBotType()
  6927. return nil
  6928. }
  6929. return fmt.Errorf("unknown ChatRecords field %s", name)
  6930. }
  6931. // AddedEdges returns all edge names that were set/added in this mutation.
  6932. func (m *ChatRecordsMutation) AddedEdges() []string {
  6933. edges := make([]string, 0, 0)
  6934. return edges
  6935. }
  6936. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6937. // name in this mutation.
  6938. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6939. return nil
  6940. }
  6941. // RemovedEdges returns all edge names that were removed in this mutation.
  6942. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6943. edges := make([]string, 0, 0)
  6944. return edges
  6945. }
  6946. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6947. // the given name in this mutation.
  6948. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6949. return nil
  6950. }
  6951. // ClearedEdges returns all edge names that were cleared in this mutation.
  6952. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6953. edges := make([]string, 0, 0)
  6954. return edges
  6955. }
  6956. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6957. // was cleared in this mutation.
  6958. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6959. return false
  6960. }
  6961. // ClearEdge clears the value of the edge with the given name. It returns an error
  6962. // if that edge is not defined in the schema.
  6963. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6964. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6965. }
  6966. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6967. // It returns an error if the edge is not defined in the schema.
  6968. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6969. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6970. }
  6971. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6972. type ChatSessionMutation struct {
  6973. config
  6974. op Op
  6975. typ string
  6976. id *uint64
  6977. created_at *time.Time
  6978. updated_at *time.Time
  6979. deleted_at *time.Time
  6980. name *string
  6981. user_id *uint64
  6982. adduser_id *int64
  6983. bot_id *uint64
  6984. addbot_id *int64
  6985. bot_type *uint8
  6986. addbot_type *int8
  6987. clearedFields map[string]struct{}
  6988. done bool
  6989. oldValue func(context.Context) (*ChatSession, error)
  6990. predicates []predicate.ChatSession
  6991. }
  6992. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6993. // chatsessionOption allows management of the mutation configuration using functional options.
  6994. type chatsessionOption func(*ChatSessionMutation)
  6995. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6996. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6997. m := &ChatSessionMutation{
  6998. config: c,
  6999. op: op,
  7000. typ: TypeChatSession,
  7001. clearedFields: make(map[string]struct{}),
  7002. }
  7003. for _, opt := range opts {
  7004. opt(m)
  7005. }
  7006. return m
  7007. }
  7008. // withChatSessionID sets the ID field of the mutation.
  7009. func withChatSessionID(id uint64) chatsessionOption {
  7010. return func(m *ChatSessionMutation) {
  7011. var (
  7012. err error
  7013. once sync.Once
  7014. value *ChatSession
  7015. )
  7016. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7017. once.Do(func() {
  7018. if m.done {
  7019. err = errors.New("querying old values post mutation is not allowed")
  7020. } else {
  7021. value, err = m.Client().ChatSession.Get(ctx, id)
  7022. }
  7023. })
  7024. return value, err
  7025. }
  7026. m.id = &id
  7027. }
  7028. }
  7029. // withChatSession sets the old ChatSession of the mutation.
  7030. func withChatSession(node *ChatSession) chatsessionOption {
  7031. return func(m *ChatSessionMutation) {
  7032. m.oldValue = func(context.Context) (*ChatSession, error) {
  7033. return node, nil
  7034. }
  7035. m.id = &node.ID
  7036. }
  7037. }
  7038. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7039. // executed in a transaction (ent.Tx), a transactional client is returned.
  7040. func (m ChatSessionMutation) Client() *Client {
  7041. client := &Client{config: m.config}
  7042. client.init()
  7043. return client
  7044. }
  7045. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7046. // it returns an error otherwise.
  7047. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7048. if _, ok := m.driver.(*txDriver); !ok {
  7049. return nil, errors.New("ent: mutation is not running in a transaction")
  7050. }
  7051. tx := &Tx{config: m.config}
  7052. tx.init()
  7053. return tx, nil
  7054. }
  7055. // SetID sets the value of the id field. Note that this
  7056. // operation is only accepted on creation of ChatSession entities.
  7057. func (m *ChatSessionMutation) SetID(id uint64) {
  7058. m.id = &id
  7059. }
  7060. // ID returns the ID value in the mutation. Note that the ID is only available
  7061. // if it was provided to the builder or after it was returned from the database.
  7062. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7063. if m.id == nil {
  7064. return
  7065. }
  7066. return *m.id, true
  7067. }
  7068. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7069. // That means, if the mutation is applied within a transaction with an isolation level such
  7070. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7071. // or updated by the mutation.
  7072. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7073. switch {
  7074. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7075. id, exists := m.ID()
  7076. if exists {
  7077. return []uint64{id}, nil
  7078. }
  7079. fallthrough
  7080. case m.op.Is(OpUpdate | OpDelete):
  7081. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7082. default:
  7083. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7084. }
  7085. }
  7086. // SetCreatedAt sets the "created_at" field.
  7087. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7088. m.created_at = &t
  7089. }
  7090. // CreatedAt returns the value of the "created_at" field in the mutation.
  7091. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7092. v := m.created_at
  7093. if v == nil {
  7094. return
  7095. }
  7096. return *v, true
  7097. }
  7098. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7099. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7101. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7102. if !m.op.Is(OpUpdateOne) {
  7103. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7104. }
  7105. if m.id == nil || m.oldValue == nil {
  7106. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7107. }
  7108. oldValue, err := m.oldValue(ctx)
  7109. if err != nil {
  7110. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7111. }
  7112. return oldValue.CreatedAt, nil
  7113. }
  7114. // ResetCreatedAt resets all changes to the "created_at" field.
  7115. func (m *ChatSessionMutation) ResetCreatedAt() {
  7116. m.created_at = nil
  7117. }
  7118. // SetUpdatedAt sets the "updated_at" field.
  7119. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7120. m.updated_at = &t
  7121. }
  7122. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7123. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7124. v := m.updated_at
  7125. if v == nil {
  7126. return
  7127. }
  7128. return *v, true
  7129. }
  7130. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7131. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7133. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7134. if !m.op.Is(OpUpdateOne) {
  7135. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7136. }
  7137. if m.id == nil || m.oldValue == nil {
  7138. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7139. }
  7140. oldValue, err := m.oldValue(ctx)
  7141. if err != nil {
  7142. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7143. }
  7144. return oldValue.UpdatedAt, nil
  7145. }
  7146. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7147. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7148. m.updated_at = nil
  7149. }
  7150. // SetDeletedAt sets the "deleted_at" field.
  7151. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7152. m.deleted_at = &t
  7153. }
  7154. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7155. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7156. v := m.deleted_at
  7157. if v == nil {
  7158. return
  7159. }
  7160. return *v, true
  7161. }
  7162. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7163. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7165. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7166. if !m.op.Is(OpUpdateOne) {
  7167. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7168. }
  7169. if m.id == nil || m.oldValue == nil {
  7170. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7171. }
  7172. oldValue, err := m.oldValue(ctx)
  7173. if err != nil {
  7174. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7175. }
  7176. return oldValue.DeletedAt, nil
  7177. }
  7178. // ClearDeletedAt clears the value of the "deleted_at" field.
  7179. func (m *ChatSessionMutation) ClearDeletedAt() {
  7180. m.deleted_at = nil
  7181. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7182. }
  7183. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7184. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7185. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7186. return ok
  7187. }
  7188. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7189. func (m *ChatSessionMutation) ResetDeletedAt() {
  7190. m.deleted_at = nil
  7191. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7192. }
  7193. // SetName sets the "name" field.
  7194. func (m *ChatSessionMutation) SetName(s string) {
  7195. m.name = &s
  7196. }
  7197. // Name returns the value of the "name" field in the mutation.
  7198. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7199. v := m.name
  7200. if v == nil {
  7201. return
  7202. }
  7203. return *v, true
  7204. }
  7205. // OldName returns the old "name" field's value of the ChatSession entity.
  7206. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7208. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7209. if !m.op.Is(OpUpdateOne) {
  7210. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7211. }
  7212. if m.id == nil || m.oldValue == nil {
  7213. return v, errors.New("OldName requires an ID field in the mutation")
  7214. }
  7215. oldValue, err := m.oldValue(ctx)
  7216. if err != nil {
  7217. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7218. }
  7219. return oldValue.Name, nil
  7220. }
  7221. // ResetName resets all changes to the "name" field.
  7222. func (m *ChatSessionMutation) ResetName() {
  7223. m.name = nil
  7224. }
  7225. // SetUserID sets the "user_id" field.
  7226. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7227. m.user_id = &u
  7228. m.adduser_id = nil
  7229. }
  7230. // UserID returns the value of the "user_id" field in the mutation.
  7231. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7232. v := m.user_id
  7233. if v == nil {
  7234. return
  7235. }
  7236. return *v, true
  7237. }
  7238. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7239. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7241. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7242. if !m.op.Is(OpUpdateOne) {
  7243. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7244. }
  7245. if m.id == nil || m.oldValue == nil {
  7246. return v, errors.New("OldUserID requires an ID field in the mutation")
  7247. }
  7248. oldValue, err := m.oldValue(ctx)
  7249. if err != nil {
  7250. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7251. }
  7252. return oldValue.UserID, nil
  7253. }
  7254. // AddUserID adds u to the "user_id" field.
  7255. func (m *ChatSessionMutation) AddUserID(u int64) {
  7256. if m.adduser_id != nil {
  7257. *m.adduser_id += u
  7258. } else {
  7259. m.adduser_id = &u
  7260. }
  7261. }
  7262. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7263. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7264. v := m.adduser_id
  7265. if v == nil {
  7266. return
  7267. }
  7268. return *v, true
  7269. }
  7270. // ResetUserID resets all changes to the "user_id" field.
  7271. func (m *ChatSessionMutation) ResetUserID() {
  7272. m.user_id = nil
  7273. m.adduser_id = nil
  7274. }
  7275. // SetBotID sets the "bot_id" field.
  7276. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7277. m.bot_id = &u
  7278. m.addbot_id = nil
  7279. }
  7280. // BotID returns the value of the "bot_id" field in the mutation.
  7281. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7282. v := m.bot_id
  7283. if v == nil {
  7284. return
  7285. }
  7286. return *v, true
  7287. }
  7288. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7289. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7291. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7292. if !m.op.Is(OpUpdateOne) {
  7293. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7294. }
  7295. if m.id == nil || m.oldValue == nil {
  7296. return v, errors.New("OldBotID requires an ID field in the mutation")
  7297. }
  7298. oldValue, err := m.oldValue(ctx)
  7299. if err != nil {
  7300. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7301. }
  7302. return oldValue.BotID, nil
  7303. }
  7304. // AddBotID adds u to the "bot_id" field.
  7305. func (m *ChatSessionMutation) AddBotID(u int64) {
  7306. if m.addbot_id != nil {
  7307. *m.addbot_id += u
  7308. } else {
  7309. m.addbot_id = &u
  7310. }
  7311. }
  7312. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7313. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7314. v := m.addbot_id
  7315. if v == nil {
  7316. return
  7317. }
  7318. return *v, true
  7319. }
  7320. // ResetBotID resets all changes to the "bot_id" field.
  7321. func (m *ChatSessionMutation) ResetBotID() {
  7322. m.bot_id = nil
  7323. m.addbot_id = nil
  7324. }
  7325. // SetBotType sets the "bot_type" field.
  7326. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7327. m.bot_type = &u
  7328. m.addbot_type = nil
  7329. }
  7330. // BotType returns the value of the "bot_type" field in the mutation.
  7331. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7332. v := m.bot_type
  7333. if v == nil {
  7334. return
  7335. }
  7336. return *v, true
  7337. }
  7338. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7339. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7341. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7342. if !m.op.Is(OpUpdateOne) {
  7343. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7344. }
  7345. if m.id == nil || m.oldValue == nil {
  7346. return v, errors.New("OldBotType requires an ID field in the mutation")
  7347. }
  7348. oldValue, err := m.oldValue(ctx)
  7349. if err != nil {
  7350. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7351. }
  7352. return oldValue.BotType, nil
  7353. }
  7354. // AddBotType adds u to the "bot_type" field.
  7355. func (m *ChatSessionMutation) AddBotType(u int8) {
  7356. if m.addbot_type != nil {
  7357. *m.addbot_type += u
  7358. } else {
  7359. m.addbot_type = &u
  7360. }
  7361. }
  7362. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7363. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7364. v := m.addbot_type
  7365. if v == nil {
  7366. return
  7367. }
  7368. return *v, true
  7369. }
  7370. // ResetBotType resets all changes to the "bot_type" field.
  7371. func (m *ChatSessionMutation) ResetBotType() {
  7372. m.bot_type = nil
  7373. m.addbot_type = nil
  7374. }
  7375. // Where appends a list predicates to the ChatSessionMutation builder.
  7376. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7377. m.predicates = append(m.predicates, ps...)
  7378. }
  7379. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7380. // users can use type-assertion to append predicates that do not depend on any generated package.
  7381. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7382. p := make([]predicate.ChatSession, len(ps))
  7383. for i := range ps {
  7384. p[i] = ps[i]
  7385. }
  7386. m.Where(p...)
  7387. }
  7388. // Op returns the operation name.
  7389. func (m *ChatSessionMutation) Op() Op {
  7390. return m.op
  7391. }
  7392. // SetOp allows setting the mutation operation.
  7393. func (m *ChatSessionMutation) SetOp(op Op) {
  7394. m.op = op
  7395. }
  7396. // Type returns the node type of this mutation (ChatSession).
  7397. func (m *ChatSessionMutation) Type() string {
  7398. return m.typ
  7399. }
  7400. // Fields returns all fields that were changed during this mutation. Note that in
  7401. // order to get all numeric fields that were incremented/decremented, call
  7402. // AddedFields().
  7403. func (m *ChatSessionMutation) Fields() []string {
  7404. fields := make([]string, 0, 7)
  7405. if m.created_at != nil {
  7406. fields = append(fields, chatsession.FieldCreatedAt)
  7407. }
  7408. if m.updated_at != nil {
  7409. fields = append(fields, chatsession.FieldUpdatedAt)
  7410. }
  7411. if m.deleted_at != nil {
  7412. fields = append(fields, chatsession.FieldDeletedAt)
  7413. }
  7414. if m.name != nil {
  7415. fields = append(fields, chatsession.FieldName)
  7416. }
  7417. if m.user_id != nil {
  7418. fields = append(fields, chatsession.FieldUserID)
  7419. }
  7420. if m.bot_id != nil {
  7421. fields = append(fields, chatsession.FieldBotID)
  7422. }
  7423. if m.bot_type != nil {
  7424. fields = append(fields, chatsession.FieldBotType)
  7425. }
  7426. return fields
  7427. }
  7428. // Field returns the value of a field with the given name. The second boolean
  7429. // return value indicates that this field was not set, or was not defined in the
  7430. // schema.
  7431. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7432. switch name {
  7433. case chatsession.FieldCreatedAt:
  7434. return m.CreatedAt()
  7435. case chatsession.FieldUpdatedAt:
  7436. return m.UpdatedAt()
  7437. case chatsession.FieldDeletedAt:
  7438. return m.DeletedAt()
  7439. case chatsession.FieldName:
  7440. return m.Name()
  7441. case chatsession.FieldUserID:
  7442. return m.UserID()
  7443. case chatsession.FieldBotID:
  7444. return m.BotID()
  7445. case chatsession.FieldBotType:
  7446. return m.BotType()
  7447. }
  7448. return nil, false
  7449. }
  7450. // OldField returns the old value of the field from the database. An error is
  7451. // returned if the mutation operation is not UpdateOne, or the query to the
  7452. // database failed.
  7453. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7454. switch name {
  7455. case chatsession.FieldCreatedAt:
  7456. return m.OldCreatedAt(ctx)
  7457. case chatsession.FieldUpdatedAt:
  7458. return m.OldUpdatedAt(ctx)
  7459. case chatsession.FieldDeletedAt:
  7460. return m.OldDeletedAt(ctx)
  7461. case chatsession.FieldName:
  7462. return m.OldName(ctx)
  7463. case chatsession.FieldUserID:
  7464. return m.OldUserID(ctx)
  7465. case chatsession.FieldBotID:
  7466. return m.OldBotID(ctx)
  7467. case chatsession.FieldBotType:
  7468. return m.OldBotType(ctx)
  7469. }
  7470. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7471. }
  7472. // SetField sets the value of a field with the given name. It returns an error if
  7473. // the field is not defined in the schema, or if the type mismatched the field
  7474. // type.
  7475. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7476. switch name {
  7477. case chatsession.FieldCreatedAt:
  7478. v, ok := value.(time.Time)
  7479. if !ok {
  7480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7481. }
  7482. m.SetCreatedAt(v)
  7483. return nil
  7484. case chatsession.FieldUpdatedAt:
  7485. v, ok := value.(time.Time)
  7486. if !ok {
  7487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7488. }
  7489. m.SetUpdatedAt(v)
  7490. return nil
  7491. case chatsession.FieldDeletedAt:
  7492. v, ok := value.(time.Time)
  7493. if !ok {
  7494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7495. }
  7496. m.SetDeletedAt(v)
  7497. return nil
  7498. case chatsession.FieldName:
  7499. v, ok := value.(string)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.SetName(v)
  7504. return nil
  7505. case chatsession.FieldUserID:
  7506. v, ok := value.(uint64)
  7507. if !ok {
  7508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7509. }
  7510. m.SetUserID(v)
  7511. return nil
  7512. case chatsession.FieldBotID:
  7513. v, ok := value.(uint64)
  7514. if !ok {
  7515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7516. }
  7517. m.SetBotID(v)
  7518. return nil
  7519. case chatsession.FieldBotType:
  7520. v, ok := value.(uint8)
  7521. if !ok {
  7522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7523. }
  7524. m.SetBotType(v)
  7525. return nil
  7526. }
  7527. return fmt.Errorf("unknown ChatSession field %s", name)
  7528. }
  7529. // AddedFields returns all numeric fields that were incremented/decremented during
  7530. // this mutation.
  7531. func (m *ChatSessionMutation) AddedFields() []string {
  7532. var fields []string
  7533. if m.adduser_id != nil {
  7534. fields = append(fields, chatsession.FieldUserID)
  7535. }
  7536. if m.addbot_id != nil {
  7537. fields = append(fields, chatsession.FieldBotID)
  7538. }
  7539. if m.addbot_type != nil {
  7540. fields = append(fields, chatsession.FieldBotType)
  7541. }
  7542. return fields
  7543. }
  7544. // AddedField returns the numeric value that was incremented/decremented on a field
  7545. // with the given name. The second boolean return value indicates that this field
  7546. // was not set, or was not defined in the schema.
  7547. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7548. switch name {
  7549. case chatsession.FieldUserID:
  7550. return m.AddedUserID()
  7551. case chatsession.FieldBotID:
  7552. return m.AddedBotID()
  7553. case chatsession.FieldBotType:
  7554. return m.AddedBotType()
  7555. }
  7556. return nil, false
  7557. }
  7558. // AddField adds the value to the field with the given name. It returns an error if
  7559. // the field is not defined in the schema, or if the type mismatched the field
  7560. // type.
  7561. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7562. switch name {
  7563. case chatsession.FieldUserID:
  7564. v, ok := value.(int64)
  7565. if !ok {
  7566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7567. }
  7568. m.AddUserID(v)
  7569. return nil
  7570. case chatsession.FieldBotID:
  7571. v, ok := value.(int64)
  7572. if !ok {
  7573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7574. }
  7575. m.AddBotID(v)
  7576. return nil
  7577. case chatsession.FieldBotType:
  7578. v, ok := value.(int8)
  7579. if !ok {
  7580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7581. }
  7582. m.AddBotType(v)
  7583. return nil
  7584. }
  7585. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7586. }
  7587. // ClearedFields returns all nullable fields that were cleared during this
  7588. // mutation.
  7589. func (m *ChatSessionMutation) ClearedFields() []string {
  7590. var fields []string
  7591. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7592. fields = append(fields, chatsession.FieldDeletedAt)
  7593. }
  7594. return fields
  7595. }
  7596. // FieldCleared returns a boolean indicating if a field with the given name was
  7597. // cleared in this mutation.
  7598. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7599. _, ok := m.clearedFields[name]
  7600. return ok
  7601. }
  7602. // ClearField clears the value of the field with the given name. It returns an
  7603. // error if the field is not defined in the schema.
  7604. func (m *ChatSessionMutation) ClearField(name string) error {
  7605. switch name {
  7606. case chatsession.FieldDeletedAt:
  7607. m.ClearDeletedAt()
  7608. return nil
  7609. }
  7610. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7611. }
  7612. // ResetField resets all changes in the mutation for the field with the given name.
  7613. // It returns an error if the field is not defined in the schema.
  7614. func (m *ChatSessionMutation) ResetField(name string) error {
  7615. switch name {
  7616. case chatsession.FieldCreatedAt:
  7617. m.ResetCreatedAt()
  7618. return nil
  7619. case chatsession.FieldUpdatedAt:
  7620. m.ResetUpdatedAt()
  7621. return nil
  7622. case chatsession.FieldDeletedAt:
  7623. m.ResetDeletedAt()
  7624. return nil
  7625. case chatsession.FieldName:
  7626. m.ResetName()
  7627. return nil
  7628. case chatsession.FieldUserID:
  7629. m.ResetUserID()
  7630. return nil
  7631. case chatsession.FieldBotID:
  7632. m.ResetBotID()
  7633. return nil
  7634. case chatsession.FieldBotType:
  7635. m.ResetBotType()
  7636. return nil
  7637. }
  7638. return fmt.Errorf("unknown ChatSession field %s", name)
  7639. }
  7640. // AddedEdges returns all edge names that were set/added in this mutation.
  7641. func (m *ChatSessionMutation) AddedEdges() []string {
  7642. edges := make([]string, 0, 0)
  7643. return edges
  7644. }
  7645. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7646. // name in this mutation.
  7647. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7648. return nil
  7649. }
  7650. // RemovedEdges returns all edge names that were removed in this mutation.
  7651. func (m *ChatSessionMutation) RemovedEdges() []string {
  7652. edges := make([]string, 0, 0)
  7653. return edges
  7654. }
  7655. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7656. // the given name in this mutation.
  7657. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7658. return nil
  7659. }
  7660. // ClearedEdges returns all edge names that were cleared in this mutation.
  7661. func (m *ChatSessionMutation) ClearedEdges() []string {
  7662. edges := make([]string, 0, 0)
  7663. return edges
  7664. }
  7665. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7666. // was cleared in this mutation.
  7667. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7668. return false
  7669. }
  7670. // ClearEdge clears the value of the edge with the given name. It returns an error
  7671. // if that edge is not defined in the schema.
  7672. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7673. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7674. }
  7675. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7676. // It returns an error if the edge is not defined in the schema.
  7677. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7678. return fmt.Errorf("unknown ChatSession edge %s", name)
  7679. }
  7680. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7681. type ContactMutation struct {
  7682. config
  7683. op Op
  7684. typ string
  7685. id *uint64
  7686. created_at *time.Time
  7687. updated_at *time.Time
  7688. status *uint8
  7689. addstatus *int8
  7690. deleted_at *time.Time
  7691. wx_wxid *string
  7692. _type *int
  7693. add_type *int
  7694. wxid *string
  7695. account *string
  7696. nickname *string
  7697. markname *string
  7698. headimg *string
  7699. sex *int
  7700. addsex *int
  7701. starrole *string
  7702. dontseeit *int
  7703. adddontseeit *int
  7704. dontseeme *int
  7705. adddontseeme *int
  7706. lag *string
  7707. gid *string
  7708. gname *string
  7709. v3 *string
  7710. organization_id *uint64
  7711. addorganization_id *int64
  7712. clearedFields map[string]struct{}
  7713. contact_relationships map[uint64]struct{}
  7714. removedcontact_relationships map[uint64]struct{}
  7715. clearedcontact_relationships bool
  7716. contact_messages map[uint64]struct{}
  7717. removedcontact_messages map[uint64]struct{}
  7718. clearedcontact_messages bool
  7719. done bool
  7720. oldValue func(context.Context) (*Contact, error)
  7721. predicates []predicate.Contact
  7722. }
  7723. var _ ent.Mutation = (*ContactMutation)(nil)
  7724. // contactOption allows management of the mutation configuration using functional options.
  7725. type contactOption func(*ContactMutation)
  7726. // newContactMutation creates new mutation for the Contact entity.
  7727. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7728. m := &ContactMutation{
  7729. config: c,
  7730. op: op,
  7731. typ: TypeContact,
  7732. clearedFields: make(map[string]struct{}),
  7733. }
  7734. for _, opt := range opts {
  7735. opt(m)
  7736. }
  7737. return m
  7738. }
  7739. // withContactID sets the ID field of the mutation.
  7740. func withContactID(id uint64) contactOption {
  7741. return func(m *ContactMutation) {
  7742. var (
  7743. err error
  7744. once sync.Once
  7745. value *Contact
  7746. )
  7747. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7748. once.Do(func() {
  7749. if m.done {
  7750. err = errors.New("querying old values post mutation is not allowed")
  7751. } else {
  7752. value, err = m.Client().Contact.Get(ctx, id)
  7753. }
  7754. })
  7755. return value, err
  7756. }
  7757. m.id = &id
  7758. }
  7759. }
  7760. // withContact sets the old Contact of the mutation.
  7761. func withContact(node *Contact) contactOption {
  7762. return func(m *ContactMutation) {
  7763. m.oldValue = func(context.Context) (*Contact, error) {
  7764. return node, nil
  7765. }
  7766. m.id = &node.ID
  7767. }
  7768. }
  7769. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7770. // executed in a transaction (ent.Tx), a transactional client is returned.
  7771. func (m ContactMutation) Client() *Client {
  7772. client := &Client{config: m.config}
  7773. client.init()
  7774. return client
  7775. }
  7776. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7777. // it returns an error otherwise.
  7778. func (m ContactMutation) Tx() (*Tx, error) {
  7779. if _, ok := m.driver.(*txDriver); !ok {
  7780. return nil, errors.New("ent: mutation is not running in a transaction")
  7781. }
  7782. tx := &Tx{config: m.config}
  7783. tx.init()
  7784. return tx, nil
  7785. }
  7786. // SetID sets the value of the id field. Note that this
  7787. // operation is only accepted on creation of Contact entities.
  7788. func (m *ContactMutation) SetID(id uint64) {
  7789. m.id = &id
  7790. }
  7791. // ID returns the ID value in the mutation. Note that the ID is only available
  7792. // if it was provided to the builder or after it was returned from the database.
  7793. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7794. if m.id == nil {
  7795. return
  7796. }
  7797. return *m.id, true
  7798. }
  7799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7800. // That means, if the mutation is applied within a transaction with an isolation level such
  7801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7802. // or updated by the mutation.
  7803. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7804. switch {
  7805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7806. id, exists := m.ID()
  7807. if exists {
  7808. return []uint64{id}, nil
  7809. }
  7810. fallthrough
  7811. case m.op.Is(OpUpdate | OpDelete):
  7812. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7813. default:
  7814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7815. }
  7816. }
  7817. // SetCreatedAt sets the "created_at" field.
  7818. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7819. m.created_at = &t
  7820. }
  7821. // CreatedAt returns the value of the "created_at" field in the mutation.
  7822. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7823. v := m.created_at
  7824. if v == nil {
  7825. return
  7826. }
  7827. return *v, true
  7828. }
  7829. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7830. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7832. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7833. if !m.op.Is(OpUpdateOne) {
  7834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7835. }
  7836. if m.id == nil || m.oldValue == nil {
  7837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7838. }
  7839. oldValue, err := m.oldValue(ctx)
  7840. if err != nil {
  7841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7842. }
  7843. return oldValue.CreatedAt, nil
  7844. }
  7845. // ResetCreatedAt resets all changes to the "created_at" field.
  7846. func (m *ContactMutation) ResetCreatedAt() {
  7847. m.created_at = nil
  7848. }
  7849. // SetUpdatedAt sets the "updated_at" field.
  7850. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7851. m.updated_at = &t
  7852. }
  7853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7854. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7855. v := m.updated_at
  7856. if v == nil {
  7857. return
  7858. }
  7859. return *v, true
  7860. }
  7861. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7862. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7864. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7865. if !m.op.Is(OpUpdateOne) {
  7866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7867. }
  7868. if m.id == nil || m.oldValue == nil {
  7869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7870. }
  7871. oldValue, err := m.oldValue(ctx)
  7872. if err != nil {
  7873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7874. }
  7875. return oldValue.UpdatedAt, nil
  7876. }
  7877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7878. func (m *ContactMutation) ResetUpdatedAt() {
  7879. m.updated_at = nil
  7880. }
  7881. // SetStatus sets the "status" field.
  7882. func (m *ContactMutation) SetStatus(u uint8) {
  7883. m.status = &u
  7884. m.addstatus = nil
  7885. }
  7886. // Status returns the value of the "status" field in the mutation.
  7887. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7888. v := m.status
  7889. if v == nil {
  7890. return
  7891. }
  7892. return *v, true
  7893. }
  7894. // OldStatus returns the old "status" field's value of the Contact entity.
  7895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7897. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7898. if !m.op.Is(OpUpdateOne) {
  7899. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7900. }
  7901. if m.id == nil || m.oldValue == nil {
  7902. return v, errors.New("OldStatus requires an ID field in the mutation")
  7903. }
  7904. oldValue, err := m.oldValue(ctx)
  7905. if err != nil {
  7906. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7907. }
  7908. return oldValue.Status, nil
  7909. }
  7910. // AddStatus adds u to the "status" field.
  7911. func (m *ContactMutation) AddStatus(u int8) {
  7912. if m.addstatus != nil {
  7913. *m.addstatus += u
  7914. } else {
  7915. m.addstatus = &u
  7916. }
  7917. }
  7918. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7919. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7920. v := m.addstatus
  7921. if v == nil {
  7922. return
  7923. }
  7924. return *v, true
  7925. }
  7926. // ClearStatus clears the value of the "status" field.
  7927. func (m *ContactMutation) ClearStatus() {
  7928. m.status = nil
  7929. m.addstatus = nil
  7930. m.clearedFields[contact.FieldStatus] = struct{}{}
  7931. }
  7932. // StatusCleared returns if the "status" field was cleared in this mutation.
  7933. func (m *ContactMutation) StatusCleared() bool {
  7934. _, ok := m.clearedFields[contact.FieldStatus]
  7935. return ok
  7936. }
  7937. // ResetStatus resets all changes to the "status" field.
  7938. func (m *ContactMutation) ResetStatus() {
  7939. m.status = nil
  7940. m.addstatus = nil
  7941. delete(m.clearedFields, contact.FieldStatus)
  7942. }
  7943. // SetDeletedAt sets the "deleted_at" field.
  7944. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7945. m.deleted_at = &t
  7946. }
  7947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7948. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7949. v := m.deleted_at
  7950. if v == nil {
  7951. return
  7952. }
  7953. return *v, true
  7954. }
  7955. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7956. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7958. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7959. if !m.op.Is(OpUpdateOne) {
  7960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7961. }
  7962. if m.id == nil || m.oldValue == nil {
  7963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7964. }
  7965. oldValue, err := m.oldValue(ctx)
  7966. if err != nil {
  7967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7968. }
  7969. return oldValue.DeletedAt, nil
  7970. }
  7971. // ClearDeletedAt clears the value of the "deleted_at" field.
  7972. func (m *ContactMutation) ClearDeletedAt() {
  7973. m.deleted_at = nil
  7974. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7975. }
  7976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7977. func (m *ContactMutation) DeletedAtCleared() bool {
  7978. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7979. return ok
  7980. }
  7981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7982. func (m *ContactMutation) ResetDeletedAt() {
  7983. m.deleted_at = nil
  7984. delete(m.clearedFields, contact.FieldDeletedAt)
  7985. }
  7986. // SetWxWxid sets the "wx_wxid" field.
  7987. func (m *ContactMutation) SetWxWxid(s string) {
  7988. m.wx_wxid = &s
  7989. }
  7990. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7991. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7992. v := m.wx_wxid
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7999. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8001. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8002. if !m.op.Is(OpUpdateOne) {
  8003. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8004. }
  8005. if m.id == nil || m.oldValue == nil {
  8006. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8007. }
  8008. oldValue, err := m.oldValue(ctx)
  8009. if err != nil {
  8010. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8011. }
  8012. return oldValue.WxWxid, nil
  8013. }
  8014. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8015. func (m *ContactMutation) ResetWxWxid() {
  8016. m.wx_wxid = nil
  8017. }
  8018. // SetType sets the "type" field.
  8019. func (m *ContactMutation) SetType(i int) {
  8020. m._type = &i
  8021. m.add_type = nil
  8022. }
  8023. // GetType returns the value of the "type" field in the mutation.
  8024. func (m *ContactMutation) GetType() (r int, exists bool) {
  8025. v := m._type
  8026. if v == nil {
  8027. return
  8028. }
  8029. return *v, true
  8030. }
  8031. // OldType returns the old "type" field's value of the Contact entity.
  8032. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8034. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8035. if !m.op.Is(OpUpdateOne) {
  8036. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8037. }
  8038. if m.id == nil || m.oldValue == nil {
  8039. return v, errors.New("OldType requires an ID field in the mutation")
  8040. }
  8041. oldValue, err := m.oldValue(ctx)
  8042. if err != nil {
  8043. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8044. }
  8045. return oldValue.Type, nil
  8046. }
  8047. // AddType adds i to the "type" field.
  8048. func (m *ContactMutation) AddType(i int) {
  8049. if m.add_type != nil {
  8050. *m.add_type += i
  8051. } else {
  8052. m.add_type = &i
  8053. }
  8054. }
  8055. // AddedType returns the value that was added to the "type" field in this mutation.
  8056. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8057. v := m.add_type
  8058. if v == nil {
  8059. return
  8060. }
  8061. return *v, true
  8062. }
  8063. // ClearType clears the value of the "type" field.
  8064. func (m *ContactMutation) ClearType() {
  8065. m._type = nil
  8066. m.add_type = nil
  8067. m.clearedFields[contact.FieldType] = struct{}{}
  8068. }
  8069. // TypeCleared returns if the "type" field was cleared in this mutation.
  8070. func (m *ContactMutation) TypeCleared() bool {
  8071. _, ok := m.clearedFields[contact.FieldType]
  8072. return ok
  8073. }
  8074. // ResetType resets all changes to the "type" field.
  8075. func (m *ContactMutation) ResetType() {
  8076. m._type = nil
  8077. m.add_type = nil
  8078. delete(m.clearedFields, contact.FieldType)
  8079. }
  8080. // SetWxid sets the "wxid" field.
  8081. func (m *ContactMutation) SetWxid(s string) {
  8082. m.wxid = &s
  8083. }
  8084. // Wxid returns the value of the "wxid" field in the mutation.
  8085. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8086. v := m.wxid
  8087. if v == nil {
  8088. return
  8089. }
  8090. return *v, true
  8091. }
  8092. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8093. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8095. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8096. if !m.op.Is(OpUpdateOne) {
  8097. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8098. }
  8099. if m.id == nil || m.oldValue == nil {
  8100. return v, errors.New("OldWxid requires an ID field in the mutation")
  8101. }
  8102. oldValue, err := m.oldValue(ctx)
  8103. if err != nil {
  8104. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8105. }
  8106. return oldValue.Wxid, nil
  8107. }
  8108. // ResetWxid resets all changes to the "wxid" field.
  8109. func (m *ContactMutation) ResetWxid() {
  8110. m.wxid = nil
  8111. }
  8112. // SetAccount sets the "account" field.
  8113. func (m *ContactMutation) SetAccount(s string) {
  8114. m.account = &s
  8115. }
  8116. // Account returns the value of the "account" field in the mutation.
  8117. func (m *ContactMutation) Account() (r string, exists bool) {
  8118. v := m.account
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // OldAccount returns the old "account" field's value of the Contact entity.
  8125. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8127. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8128. if !m.op.Is(OpUpdateOne) {
  8129. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8130. }
  8131. if m.id == nil || m.oldValue == nil {
  8132. return v, errors.New("OldAccount requires an ID field in the mutation")
  8133. }
  8134. oldValue, err := m.oldValue(ctx)
  8135. if err != nil {
  8136. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8137. }
  8138. return oldValue.Account, nil
  8139. }
  8140. // ResetAccount resets all changes to the "account" field.
  8141. func (m *ContactMutation) ResetAccount() {
  8142. m.account = nil
  8143. }
  8144. // SetNickname sets the "nickname" field.
  8145. func (m *ContactMutation) SetNickname(s string) {
  8146. m.nickname = &s
  8147. }
  8148. // Nickname returns the value of the "nickname" field in the mutation.
  8149. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8150. v := m.nickname
  8151. if v == nil {
  8152. return
  8153. }
  8154. return *v, true
  8155. }
  8156. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8157. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8159. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8160. if !m.op.Is(OpUpdateOne) {
  8161. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8162. }
  8163. if m.id == nil || m.oldValue == nil {
  8164. return v, errors.New("OldNickname requires an ID field in the mutation")
  8165. }
  8166. oldValue, err := m.oldValue(ctx)
  8167. if err != nil {
  8168. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8169. }
  8170. return oldValue.Nickname, nil
  8171. }
  8172. // ResetNickname resets all changes to the "nickname" field.
  8173. func (m *ContactMutation) ResetNickname() {
  8174. m.nickname = nil
  8175. }
  8176. // SetMarkname sets the "markname" field.
  8177. func (m *ContactMutation) SetMarkname(s string) {
  8178. m.markname = &s
  8179. }
  8180. // Markname returns the value of the "markname" field in the mutation.
  8181. func (m *ContactMutation) Markname() (r string, exists bool) {
  8182. v := m.markname
  8183. if v == nil {
  8184. return
  8185. }
  8186. return *v, true
  8187. }
  8188. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8189. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8191. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8192. if !m.op.Is(OpUpdateOne) {
  8193. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8194. }
  8195. if m.id == nil || m.oldValue == nil {
  8196. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8197. }
  8198. oldValue, err := m.oldValue(ctx)
  8199. if err != nil {
  8200. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8201. }
  8202. return oldValue.Markname, nil
  8203. }
  8204. // ResetMarkname resets all changes to the "markname" field.
  8205. func (m *ContactMutation) ResetMarkname() {
  8206. m.markname = nil
  8207. }
  8208. // SetHeadimg sets the "headimg" field.
  8209. func (m *ContactMutation) SetHeadimg(s string) {
  8210. m.headimg = &s
  8211. }
  8212. // Headimg returns the value of the "headimg" field in the mutation.
  8213. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8214. v := m.headimg
  8215. if v == nil {
  8216. return
  8217. }
  8218. return *v, true
  8219. }
  8220. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8221. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8223. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8224. if !m.op.Is(OpUpdateOne) {
  8225. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8226. }
  8227. if m.id == nil || m.oldValue == nil {
  8228. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8229. }
  8230. oldValue, err := m.oldValue(ctx)
  8231. if err != nil {
  8232. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8233. }
  8234. return oldValue.Headimg, nil
  8235. }
  8236. // ResetHeadimg resets all changes to the "headimg" field.
  8237. func (m *ContactMutation) ResetHeadimg() {
  8238. m.headimg = nil
  8239. }
  8240. // SetSex sets the "sex" field.
  8241. func (m *ContactMutation) SetSex(i int) {
  8242. m.sex = &i
  8243. m.addsex = nil
  8244. }
  8245. // Sex returns the value of the "sex" field in the mutation.
  8246. func (m *ContactMutation) Sex() (r int, exists bool) {
  8247. v := m.sex
  8248. if v == nil {
  8249. return
  8250. }
  8251. return *v, true
  8252. }
  8253. // OldSex returns the old "sex" field's value of the Contact entity.
  8254. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8256. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8257. if !m.op.Is(OpUpdateOne) {
  8258. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8259. }
  8260. if m.id == nil || m.oldValue == nil {
  8261. return v, errors.New("OldSex requires an ID field in the mutation")
  8262. }
  8263. oldValue, err := m.oldValue(ctx)
  8264. if err != nil {
  8265. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8266. }
  8267. return oldValue.Sex, nil
  8268. }
  8269. // AddSex adds i to the "sex" field.
  8270. func (m *ContactMutation) AddSex(i int) {
  8271. if m.addsex != nil {
  8272. *m.addsex += i
  8273. } else {
  8274. m.addsex = &i
  8275. }
  8276. }
  8277. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8278. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8279. v := m.addsex
  8280. if v == nil {
  8281. return
  8282. }
  8283. return *v, true
  8284. }
  8285. // ResetSex resets all changes to the "sex" field.
  8286. func (m *ContactMutation) ResetSex() {
  8287. m.sex = nil
  8288. m.addsex = nil
  8289. }
  8290. // SetStarrole sets the "starrole" field.
  8291. func (m *ContactMutation) SetStarrole(s string) {
  8292. m.starrole = &s
  8293. }
  8294. // Starrole returns the value of the "starrole" field in the mutation.
  8295. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8296. v := m.starrole
  8297. if v == nil {
  8298. return
  8299. }
  8300. return *v, true
  8301. }
  8302. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8303. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8305. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8306. if !m.op.Is(OpUpdateOne) {
  8307. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8308. }
  8309. if m.id == nil || m.oldValue == nil {
  8310. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8311. }
  8312. oldValue, err := m.oldValue(ctx)
  8313. if err != nil {
  8314. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8315. }
  8316. return oldValue.Starrole, nil
  8317. }
  8318. // ResetStarrole resets all changes to the "starrole" field.
  8319. func (m *ContactMutation) ResetStarrole() {
  8320. m.starrole = nil
  8321. }
  8322. // SetDontseeit sets the "dontseeit" field.
  8323. func (m *ContactMutation) SetDontseeit(i int) {
  8324. m.dontseeit = &i
  8325. m.adddontseeit = nil
  8326. }
  8327. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8328. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8329. v := m.dontseeit
  8330. if v == nil {
  8331. return
  8332. }
  8333. return *v, true
  8334. }
  8335. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8336. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8338. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8339. if !m.op.Is(OpUpdateOne) {
  8340. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8341. }
  8342. if m.id == nil || m.oldValue == nil {
  8343. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8344. }
  8345. oldValue, err := m.oldValue(ctx)
  8346. if err != nil {
  8347. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8348. }
  8349. return oldValue.Dontseeit, nil
  8350. }
  8351. // AddDontseeit adds i to the "dontseeit" field.
  8352. func (m *ContactMutation) AddDontseeit(i int) {
  8353. if m.adddontseeit != nil {
  8354. *m.adddontseeit += i
  8355. } else {
  8356. m.adddontseeit = &i
  8357. }
  8358. }
  8359. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8360. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8361. v := m.adddontseeit
  8362. if v == nil {
  8363. return
  8364. }
  8365. return *v, true
  8366. }
  8367. // ResetDontseeit resets all changes to the "dontseeit" field.
  8368. func (m *ContactMutation) ResetDontseeit() {
  8369. m.dontseeit = nil
  8370. m.adddontseeit = nil
  8371. }
  8372. // SetDontseeme sets the "dontseeme" field.
  8373. func (m *ContactMutation) SetDontseeme(i int) {
  8374. m.dontseeme = &i
  8375. m.adddontseeme = nil
  8376. }
  8377. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8378. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8379. v := m.dontseeme
  8380. if v == nil {
  8381. return
  8382. }
  8383. return *v, true
  8384. }
  8385. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8388. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8389. if !m.op.Is(OpUpdateOne) {
  8390. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8391. }
  8392. if m.id == nil || m.oldValue == nil {
  8393. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8394. }
  8395. oldValue, err := m.oldValue(ctx)
  8396. if err != nil {
  8397. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8398. }
  8399. return oldValue.Dontseeme, nil
  8400. }
  8401. // AddDontseeme adds i to the "dontseeme" field.
  8402. func (m *ContactMutation) AddDontseeme(i int) {
  8403. if m.adddontseeme != nil {
  8404. *m.adddontseeme += i
  8405. } else {
  8406. m.adddontseeme = &i
  8407. }
  8408. }
  8409. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8410. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8411. v := m.adddontseeme
  8412. if v == nil {
  8413. return
  8414. }
  8415. return *v, true
  8416. }
  8417. // ResetDontseeme resets all changes to the "dontseeme" field.
  8418. func (m *ContactMutation) ResetDontseeme() {
  8419. m.dontseeme = nil
  8420. m.adddontseeme = nil
  8421. }
  8422. // SetLag sets the "lag" field.
  8423. func (m *ContactMutation) SetLag(s string) {
  8424. m.lag = &s
  8425. }
  8426. // Lag returns the value of the "lag" field in the mutation.
  8427. func (m *ContactMutation) Lag() (r string, exists bool) {
  8428. v := m.lag
  8429. if v == nil {
  8430. return
  8431. }
  8432. return *v, true
  8433. }
  8434. // OldLag returns the old "lag" field's value of the Contact entity.
  8435. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8437. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8438. if !m.op.Is(OpUpdateOne) {
  8439. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8440. }
  8441. if m.id == nil || m.oldValue == nil {
  8442. return v, errors.New("OldLag requires an ID field in the mutation")
  8443. }
  8444. oldValue, err := m.oldValue(ctx)
  8445. if err != nil {
  8446. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8447. }
  8448. return oldValue.Lag, nil
  8449. }
  8450. // ResetLag resets all changes to the "lag" field.
  8451. func (m *ContactMutation) ResetLag() {
  8452. m.lag = nil
  8453. }
  8454. // SetGid sets the "gid" field.
  8455. func (m *ContactMutation) SetGid(s string) {
  8456. m.gid = &s
  8457. }
  8458. // Gid returns the value of the "gid" field in the mutation.
  8459. func (m *ContactMutation) Gid() (r string, exists bool) {
  8460. v := m.gid
  8461. if v == nil {
  8462. return
  8463. }
  8464. return *v, true
  8465. }
  8466. // OldGid returns the old "gid" field's value of the Contact entity.
  8467. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8469. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8470. if !m.op.Is(OpUpdateOne) {
  8471. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8472. }
  8473. if m.id == nil || m.oldValue == nil {
  8474. return v, errors.New("OldGid requires an ID field in the mutation")
  8475. }
  8476. oldValue, err := m.oldValue(ctx)
  8477. if err != nil {
  8478. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8479. }
  8480. return oldValue.Gid, nil
  8481. }
  8482. // ResetGid resets all changes to the "gid" field.
  8483. func (m *ContactMutation) ResetGid() {
  8484. m.gid = nil
  8485. }
  8486. // SetGname sets the "gname" field.
  8487. func (m *ContactMutation) SetGname(s string) {
  8488. m.gname = &s
  8489. }
  8490. // Gname returns the value of the "gname" field in the mutation.
  8491. func (m *ContactMutation) Gname() (r string, exists bool) {
  8492. v := m.gname
  8493. if v == nil {
  8494. return
  8495. }
  8496. return *v, true
  8497. }
  8498. // OldGname returns the old "gname" field's value of the Contact entity.
  8499. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8501. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8502. if !m.op.Is(OpUpdateOne) {
  8503. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8504. }
  8505. if m.id == nil || m.oldValue == nil {
  8506. return v, errors.New("OldGname requires an ID field in the mutation")
  8507. }
  8508. oldValue, err := m.oldValue(ctx)
  8509. if err != nil {
  8510. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8511. }
  8512. return oldValue.Gname, nil
  8513. }
  8514. // ResetGname resets all changes to the "gname" field.
  8515. func (m *ContactMutation) ResetGname() {
  8516. m.gname = nil
  8517. }
  8518. // SetV3 sets the "v3" field.
  8519. func (m *ContactMutation) SetV3(s string) {
  8520. m.v3 = &s
  8521. }
  8522. // V3 returns the value of the "v3" field in the mutation.
  8523. func (m *ContactMutation) V3() (r string, exists bool) {
  8524. v := m.v3
  8525. if v == nil {
  8526. return
  8527. }
  8528. return *v, true
  8529. }
  8530. // OldV3 returns the old "v3" field's value of the Contact entity.
  8531. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8533. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8534. if !m.op.Is(OpUpdateOne) {
  8535. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8536. }
  8537. if m.id == nil || m.oldValue == nil {
  8538. return v, errors.New("OldV3 requires an ID field in the mutation")
  8539. }
  8540. oldValue, err := m.oldValue(ctx)
  8541. if err != nil {
  8542. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8543. }
  8544. return oldValue.V3, nil
  8545. }
  8546. // ResetV3 resets all changes to the "v3" field.
  8547. func (m *ContactMutation) ResetV3() {
  8548. m.v3 = nil
  8549. }
  8550. // SetOrganizationID sets the "organization_id" field.
  8551. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8552. m.organization_id = &u
  8553. m.addorganization_id = nil
  8554. }
  8555. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8556. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8557. v := m.organization_id
  8558. if v == nil {
  8559. return
  8560. }
  8561. return *v, true
  8562. }
  8563. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8564. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8566. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8567. if !m.op.Is(OpUpdateOne) {
  8568. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8569. }
  8570. if m.id == nil || m.oldValue == nil {
  8571. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8572. }
  8573. oldValue, err := m.oldValue(ctx)
  8574. if err != nil {
  8575. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8576. }
  8577. return oldValue.OrganizationID, nil
  8578. }
  8579. // AddOrganizationID adds u to the "organization_id" field.
  8580. func (m *ContactMutation) AddOrganizationID(u int64) {
  8581. if m.addorganization_id != nil {
  8582. *m.addorganization_id += u
  8583. } else {
  8584. m.addorganization_id = &u
  8585. }
  8586. }
  8587. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8588. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8589. v := m.addorganization_id
  8590. if v == nil {
  8591. return
  8592. }
  8593. return *v, true
  8594. }
  8595. // ClearOrganizationID clears the value of the "organization_id" field.
  8596. func (m *ContactMutation) ClearOrganizationID() {
  8597. m.organization_id = nil
  8598. m.addorganization_id = nil
  8599. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8600. }
  8601. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8602. func (m *ContactMutation) OrganizationIDCleared() bool {
  8603. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8604. return ok
  8605. }
  8606. // ResetOrganizationID resets all changes to the "organization_id" field.
  8607. func (m *ContactMutation) ResetOrganizationID() {
  8608. m.organization_id = nil
  8609. m.addorganization_id = nil
  8610. delete(m.clearedFields, contact.FieldOrganizationID)
  8611. }
  8612. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8613. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8614. if m.contact_relationships == nil {
  8615. m.contact_relationships = make(map[uint64]struct{})
  8616. }
  8617. for i := range ids {
  8618. m.contact_relationships[ids[i]] = struct{}{}
  8619. }
  8620. }
  8621. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8622. func (m *ContactMutation) ClearContactRelationships() {
  8623. m.clearedcontact_relationships = true
  8624. }
  8625. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8626. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8627. return m.clearedcontact_relationships
  8628. }
  8629. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8630. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8631. if m.removedcontact_relationships == nil {
  8632. m.removedcontact_relationships = make(map[uint64]struct{})
  8633. }
  8634. for i := range ids {
  8635. delete(m.contact_relationships, ids[i])
  8636. m.removedcontact_relationships[ids[i]] = struct{}{}
  8637. }
  8638. }
  8639. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8640. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8641. for id := range m.removedcontact_relationships {
  8642. ids = append(ids, id)
  8643. }
  8644. return
  8645. }
  8646. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8647. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8648. for id := range m.contact_relationships {
  8649. ids = append(ids, id)
  8650. }
  8651. return
  8652. }
  8653. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8654. func (m *ContactMutation) ResetContactRelationships() {
  8655. m.contact_relationships = nil
  8656. m.clearedcontact_relationships = false
  8657. m.removedcontact_relationships = nil
  8658. }
  8659. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8660. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8661. if m.contact_messages == nil {
  8662. m.contact_messages = make(map[uint64]struct{})
  8663. }
  8664. for i := range ids {
  8665. m.contact_messages[ids[i]] = struct{}{}
  8666. }
  8667. }
  8668. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8669. func (m *ContactMutation) ClearContactMessages() {
  8670. m.clearedcontact_messages = true
  8671. }
  8672. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8673. func (m *ContactMutation) ContactMessagesCleared() bool {
  8674. return m.clearedcontact_messages
  8675. }
  8676. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8677. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8678. if m.removedcontact_messages == nil {
  8679. m.removedcontact_messages = make(map[uint64]struct{})
  8680. }
  8681. for i := range ids {
  8682. delete(m.contact_messages, ids[i])
  8683. m.removedcontact_messages[ids[i]] = struct{}{}
  8684. }
  8685. }
  8686. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8687. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8688. for id := range m.removedcontact_messages {
  8689. ids = append(ids, id)
  8690. }
  8691. return
  8692. }
  8693. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8694. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8695. for id := range m.contact_messages {
  8696. ids = append(ids, id)
  8697. }
  8698. return
  8699. }
  8700. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8701. func (m *ContactMutation) ResetContactMessages() {
  8702. m.contact_messages = nil
  8703. m.clearedcontact_messages = false
  8704. m.removedcontact_messages = nil
  8705. }
  8706. // Where appends a list predicates to the ContactMutation builder.
  8707. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8708. m.predicates = append(m.predicates, ps...)
  8709. }
  8710. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8711. // users can use type-assertion to append predicates that do not depend on any generated package.
  8712. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8713. p := make([]predicate.Contact, len(ps))
  8714. for i := range ps {
  8715. p[i] = ps[i]
  8716. }
  8717. m.Where(p...)
  8718. }
  8719. // Op returns the operation name.
  8720. func (m *ContactMutation) Op() Op {
  8721. return m.op
  8722. }
  8723. // SetOp allows setting the mutation operation.
  8724. func (m *ContactMutation) SetOp(op Op) {
  8725. m.op = op
  8726. }
  8727. // Type returns the node type of this mutation (Contact).
  8728. func (m *ContactMutation) Type() string {
  8729. return m.typ
  8730. }
  8731. // Fields returns all fields that were changed during this mutation. Note that in
  8732. // order to get all numeric fields that were incremented/decremented, call
  8733. // AddedFields().
  8734. func (m *ContactMutation) Fields() []string {
  8735. fields := make([]string, 0, 20)
  8736. if m.created_at != nil {
  8737. fields = append(fields, contact.FieldCreatedAt)
  8738. }
  8739. if m.updated_at != nil {
  8740. fields = append(fields, contact.FieldUpdatedAt)
  8741. }
  8742. if m.status != nil {
  8743. fields = append(fields, contact.FieldStatus)
  8744. }
  8745. if m.deleted_at != nil {
  8746. fields = append(fields, contact.FieldDeletedAt)
  8747. }
  8748. if m.wx_wxid != nil {
  8749. fields = append(fields, contact.FieldWxWxid)
  8750. }
  8751. if m._type != nil {
  8752. fields = append(fields, contact.FieldType)
  8753. }
  8754. if m.wxid != nil {
  8755. fields = append(fields, contact.FieldWxid)
  8756. }
  8757. if m.account != nil {
  8758. fields = append(fields, contact.FieldAccount)
  8759. }
  8760. if m.nickname != nil {
  8761. fields = append(fields, contact.FieldNickname)
  8762. }
  8763. if m.markname != nil {
  8764. fields = append(fields, contact.FieldMarkname)
  8765. }
  8766. if m.headimg != nil {
  8767. fields = append(fields, contact.FieldHeadimg)
  8768. }
  8769. if m.sex != nil {
  8770. fields = append(fields, contact.FieldSex)
  8771. }
  8772. if m.starrole != nil {
  8773. fields = append(fields, contact.FieldStarrole)
  8774. }
  8775. if m.dontseeit != nil {
  8776. fields = append(fields, contact.FieldDontseeit)
  8777. }
  8778. if m.dontseeme != nil {
  8779. fields = append(fields, contact.FieldDontseeme)
  8780. }
  8781. if m.lag != nil {
  8782. fields = append(fields, contact.FieldLag)
  8783. }
  8784. if m.gid != nil {
  8785. fields = append(fields, contact.FieldGid)
  8786. }
  8787. if m.gname != nil {
  8788. fields = append(fields, contact.FieldGname)
  8789. }
  8790. if m.v3 != nil {
  8791. fields = append(fields, contact.FieldV3)
  8792. }
  8793. if m.organization_id != nil {
  8794. fields = append(fields, contact.FieldOrganizationID)
  8795. }
  8796. return fields
  8797. }
  8798. // Field returns the value of a field with the given name. The second boolean
  8799. // return value indicates that this field was not set, or was not defined in the
  8800. // schema.
  8801. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8802. switch name {
  8803. case contact.FieldCreatedAt:
  8804. return m.CreatedAt()
  8805. case contact.FieldUpdatedAt:
  8806. return m.UpdatedAt()
  8807. case contact.FieldStatus:
  8808. return m.Status()
  8809. case contact.FieldDeletedAt:
  8810. return m.DeletedAt()
  8811. case contact.FieldWxWxid:
  8812. return m.WxWxid()
  8813. case contact.FieldType:
  8814. return m.GetType()
  8815. case contact.FieldWxid:
  8816. return m.Wxid()
  8817. case contact.FieldAccount:
  8818. return m.Account()
  8819. case contact.FieldNickname:
  8820. return m.Nickname()
  8821. case contact.FieldMarkname:
  8822. return m.Markname()
  8823. case contact.FieldHeadimg:
  8824. return m.Headimg()
  8825. case contact.FieldSex:
  8826. return m.Sex()
  8827. case contact.FieldStarrole:
  8828. return m.Starrole()
  8829. case contact.FieldDontseeit:
  8830. return m.Dontseeit()
  8831. case contact.FieldDontseeme:
  8832. return m.Dontseeme()
  8833. case contact.FieldLag:
  8834. return m.Lag()
  8835. case contact.FieldGid:
  8836. return m.Gid()
  8837. case contact.FieldGname:
  8838. return m.Gname()
  8839. case contact.FieldV3:
  8840. return m.V3()
  8841. case contact.FieldOrganizationID:
  8842. return m.OrganizationID()
  8843. }
  8844. return nil, false
  8845. }
  8846. // OldField returns the old value of the field from the database. An error is
  8847. // returned if the mutation operation is not UpdateOne, or the query to the
  8848. // database failed.
  8849. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8850. switch name {
  8851. case contact.FieldCreatedAt:
  8852. return m.OldCreatedAt(ctx)
  8853. case contact.FieldUpdatedAt:
  8854. return m.OldUpdatedAt(ctx)
  8855. case contact.FieldStatus:
  8856. return m.OldStatus(ctx)
  8857. case contact.FieldDeletedAt:
  8858. return m.OldDeletedAt(ctx)
  8859. case contact.FieldWxWxid:
  8860. return m.OldWxWxid(ctx)
  8861. case contact.FieldType:
  8862. return m.OldType(ctx)
  8863. case contact.FieldWxid:
  8864. return m.OldWxid(ctx)
  8865. case contact.FieldAccount:
  8866. return m.OldAccount(ctx)
  8867. case contact.FieldNickname:
  8868. return m.OldNickname(ctx)
  8869. case contact.FieldMarkname:
  8870. return m.OldMarkname(ctx)
  8871. case contact.FieldHeadimg:
  8872. return m.OldHeadimg(ctx)
  8873. case contact.FieldSex:
  8874. return m.OldSex(ctx)
  8875. case contact.FieldStarrole:
  8876. return m.OldStarrole(ctx)
  8877. case contact.FieldDontseeit:
  8878. return m.OldDontseeit(ctx)
  8879. case contact.FieldDontseeme:
  8880. return m.OldDontseeme(ctx)
  8881. case contact.FieldLag:
  8882. return m.OldLag(ctx)
  8883. case contact.FieldGid:
  8884. return m.OldGid(ctx)
  8885. case contact.FieldGname:
  8886. return m.OldGname(ctx)
  8887. case contact.FieldV3:
  8888. return m.OldV3(ctx)
  8889. case contact.FieldOrganizationID:
  8890. return m.OldOrganizationID(ctx)
  8891. }
  8892. return nil, fmt.Errorf("unknown Contact field %s", name)
  8893. }
  8894. // SetField sets the value of a field with the given name. It returns an error if
  8895. // the field is not defined in the schema, or if the type mismatched the field
  8896. // type.
  8897. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8898. switch name {
  8899. case contact.FieldCreatedAt:
  8900. v, ok := value.(time.Time)
  8901. if !ok {
  8902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8903. }
  8904. m.SetCreatedAt(v)
  8905. return nil
  8906. case contact.FieldUpdatedAt:
  8907. v, ok := value.(time.Time)
  8908. if !ok {
  8909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8910. }
  8911. m.SetUpdatedAt(v)
  8912. return nil
  8913. case contact.FieldStatus:
  8914. v, ok := value.(uint8)
  8915. if !ok {
  8916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8917. }
  8918. m.SetStatus(v)
  8919. return nil
  8920. case contact.FieldDeletedAt:
  8921. v, ok := value.(time.Time)
  8922. if !ok {
  8923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8924. }
  8925. m.SetDeletedAt(v)
  8926. return nil
  8927. case contact.FieldWxWxid:
  8928. v, ok := value.(string)
  8929. if !ok {
  8930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8931. }
  8932. m.SetWxWxid(v)
  8933. return nil
  8934. case contact.FieldType:
  8935. v, ok := value.(int)
  8936. if !ok {
  8937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8938. }
  8939. m.SetType(v)
  8940. return nil
  8941. case contact.FieldWxid:
  8942. v, ok := value.(string)
  8943. if !ok {
  8944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8945. }
  8946. m.SetWxid(v)
  8947. return nil
  8948. case contact.FieldAccount:
  8949. v, ok := value.(string)
  8950. if !ok {
  8951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8952. }
  8953. m.SetAccount(v)
  8954. return nil
  8955. case contact.FieldNickname:
  8956. v, ok := value.(string)
  8957. if !ok {
  8958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8959. }
  8960. m.SetNickname(v)
  8961. return nil
  8962. case contact.FieldMarkname:
  8963. v, ok := value.(string)
  8964. if !ok {
  8965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8966. }
  8967. m.SetMarkname(v)
  8968. return nil
  8969. case contact.FieldHeadimg:
  8970. v, ok := value.(string)
  8971. if !ok {
  8972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8973. }
  8974. m.SetHeadimg(v)
  8975. return nil
  8976. case contact.FieldSex:
  8977. v, ok := value.(int)
  8978. if !ok {
  8979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8980. }
  8981. m.SetSex(v)
  8982. return nil
  8983. case contact.FieldStarrole:
  8984. v, ok := value.(string)
  8985. if !ok {
  8986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8987. }
  8988. m.SetStarrole(v)
  8989. return nil
  8990. case contact.FieldDontseeit:
  8991. v, ok := value.(int)
  8992. if !ok {
  8993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8994. }
  8995. m.SetDontseeit(v)
  8996. return nil
  8997. case contact.FieldDontseeme:
  8998. v, ok := value.(int)
  8999. if !ok {
  9000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9001. }
  9002. m.SetDontseeme(v)
  9003. return nil
  9004. case contact.FieldLag:
  9005. v, ok := value.(string)
  9006. if !ok {
  9007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9008. }
  9009. m.SetLag(v)
  9010. return nil
  9011. case contact.FieldGid:
  9012. v, ok := value.(string)
  9013. if !ok {
  9014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9015. }
  9016. m.SetGid(v)
  9017. return nil
  9018. case contact.FieldGname:
  9019. v, ok := value.(string)
  9020. if !ok {
  9021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9022. }
  9023. m.SetGname(v)
  9024. return nil
  9025. case contact.FieldV3:
  9026. v, ok := value.(string)
  9027. if !ok {
  9028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9029. }
  9030. m.SetV3(v)
  9031. return nil
  9032. case contact.FieldOrganizationID:
  9033. v, ok := value.(uint64)
  9034. if !ok {
  9035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9036. }
  9037. m.SetOrganizationID(v)
  9038. return nil
  9039. }
  9040. return fmt.Errorf("unknown Contact field %s", name)
  9041. }
  9042. // AddedFields returns all numeric fields that were incremented/decremented during
  9043. // this mutation.
  9044. func (m *ContactMutation) AddedFields() []string {
  9045. var fields []string
  9046. if m.addstatus != nil {
  9047. fields = append(fields, contact.FieldStatus)
  9048. }
  9049. if m.add_type != nil {
  9050. fields = append(fields, contact.FieldType)
  9051. }
  9052. if m.addsex != nil {
  9053. fields = append(fields, contact.FieldSex)
  9054. }
  9055. if m.adddontseeit != nil {
  9056. fields = append(fields, contact.FieldDontseeit)
  9057. }
  9058. if m.adddontseeme != nil {
  9059. fields = append(fields, contact.FieldDontseeme)
  9060. }
  9061. if m.addorganization_id != nil {
  9062. fields = append(fields, contact.FieldOrganizationID)
  9063. }
  9064. return fields
  9065. }
  9066. // AddedField returns the numeric value that was incremented/decremented on a field
  9067. // with the given name. The second boolean return value indicates that this field
  9068. // was not set, or was not defined in the schema.
  9069. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9070. switch name {
  9071. case contact.FieldStatus:
  9072. return m.AddedStatus()
  9073. case contact.FieldType:
  9074. return m.AddedType()
  9075. case contact.FieldSex:
  9076. return m.AddedSex()
  9077. case contact.FieldDontseeit:
  9078. return m.AddedDontseeit()
  9079. case contact.FieldDontseeme:
  9080. return m.AddedDontseeme()
  9081. case contact.FieldOrganizationID:
  9082. return m.AddedOrganizationID()
  9083. }
  9084. return nil, false
  9085. }
  9086. // AddField adds the value to the field with the given name. It returns an error if
  9087. // the field is not defined in the schema, or if the type mismatched the field
  9088. // type.
  9089. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9090. switch name {
  9091. case contact.FieldStatus:
  9092. v, ok := value.(int8)
  9093. if !ok {
  9094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9095. }
  9096. m.AddStatus(v)
  9097. return nil
  9098. case contact.FieldType:
  9099. v, ok := value.(int)
  9100. if !ok {
  9101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9102. }
  9103. m.AddType(v)
  9104. return nil
  9105. case contact.FieldSex:
  9106. v, ok := value.(int)
  9107. if !ok {
  9108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9109. }
  9110. m.AddSex(v)
  9111. return nil
  9112. case contact.FieldDontseeit:
  9113. v, ok := value.(int)
  9114. if !ok {
  9115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9116. }
  9117. m.AddDontseeit(v)
  9118. return nil
  9119. case contact.FieldDontseeme:
  9120. v, ok := value.(int)
  9121. if !ok {
  9122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9123. }
  9124. m.AddDontseeme(v)
  9125. return nil
  9126. case contact.FieldOrganizationID:
  9127. v, ok := value.(int64)
  9128. if !ok {
  9129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9130. }
  9131. m.AddOrganizationID(v)
  9132. return nil
  9133. }
  9134. return fmt.Errorf("unknown Contact numeric field %s", name)
  9135. }
  9136. // ClearedFields returns all nullable fields that were cleared during this
  9137. // mutation.
  9138. func (m *ContactMutation) ClearedFields() []string {
  9139. var fields []string
  9140. if m.FieldCleared(contact.FieldStatus) {
  9141. fields = append(fields, contact.FieldStatus)
  9142. }
  9143. if m.FieldCleared(contact.FieldDeletedAt) {
  9144. fields = append(fields, contact.FieldDeletedAt)
  9145. }
  9146. if m.FieldCleared(contact.FieldType) {
  9147. fields = append(fields, contact.FieldType)
  9148. }
  9149. if m.FieldCleared(contact.FieldOrganizationID) {
  9150. fields = append(fields, contact.FieldOrganizationID)
  9151. }
  9152. return fields
  9153. }
  9154. // FieldCleared returns a boolean indicating if a field with the given name was
  9155. // cleared in this mutation.
  9156. func (m *ContactMutation) FieldCleared(name string) bool {
  9157. _, ok := m.clearedFields[name]
  9158. return ok
  9159. }
  9160. // ClearField clears the value of the field with the given name. It returns an
  9161. // error if the field is not defined in the schema.
  9162. func (m *ContactMutation) ClearField(name string) error {
  9163. switch name {
  9164. case contact.FieldStatus:
  9165. m.ClearStatus()
  9166. return nil
  9167. case contact.FieldDeletedAt:
  9168. m.ClearDeletedAt()
  9169. return nil
  9170. case contact.FieldType:
  9171. m.ClearType()
  9172. return nil
  9173. case contact.FieldOrganizationID:
  9174. m.ClearOrganizationID()
  9175. return nil
  9176. }
  9177. return fmt.Errorf("unknown Contact nullable field %s", name)
  9178. }
  9179. // ResetField resets all changes in the mutation for the field with the given name.
  9180. // It returns an error if the field is not defined in the schema.
  9181. func (m *ContactMutation) ResetField(name string) error {
  9182. switch name {
  9183. case contact.FieldCreatedAt:
  9184. m.ResetCreatedAt()
  9185. return nil
  9186. case contact.FieldUpdatedAt:
  9187. m.ResetUpdatedAt()
  9188. return nil
  9189. case contact.FieldStatus:
  9190. m.ResetStatus()
  9191. return nil
  9192. case contact.FieldDeletedAt:
  9193. m.ResetDeletedAt()
  9194. return nil
  9195. case contact.FieldWxWxid:
  9196. m.ResetWxWxid()
  9197. return nil
  9198. case contact.FieldType:
  9199. m.ResetType()
  9200. return nil
  9201. case contact.FieldWxid:
  9202. m.ResetWxid()
  9203. return nil
  9204. case contact.FieldAccount:
  9205. m.ResetAccount()
  9206. return nil
  9207. case contact.FieldNickname:
  9208. m.ResetNickname()
  9209. return nil
  9210. case contact.FieldMarkname:
  9211. m.ResetMarkname()
  9212. return nil
  9213. case contact.FieldHeadimg:
  9214. m.ResetHeadimg()
  9215. return nil
  9216. case contact.FieldSex:
  9217. m.ResetSex()
  9218. return nil
  9219. case contact.FieldStarrole:
  9220. m.ResetStarrole()
  9221. return nil
  9222. case contact.FieldDontseeit:
  9223. m.ResetDontseeit()
  9224. return nil
  9225. case contact.FieldDontseeme:
  9226. m.ResetDontseeme()
  9227. return nil
  9228. case contact.FieldLag:
  9229. m.ResetLag()
  9230. return nil
  9231. case contact.FieldGid:
  9232. m.ResetGid()
  9233. return nil
  9234. case contact.FieldGname:
  9235. m.ResetGname()
  9236. return nil
  9237. case contact.FieldV3:
  9238. m.ResetV3()
  9239. return nil
  9240. case contact.FieldOrganizationID:
  9241. m.ResetOrganizationID()
  9242. return nil
  9243. }
  9244. return fmt.Errorf("unknown Contact field %s", name)
  9245. }
  9246. // AddedEdges returns all edge names that were set/added in this mutation.
  9247. func (m *ContactMutation) AddedEdges() []string {
  9248. edges := make([]string, 0, 2)
  9249. if m.contact_relationships != nil {
  9250. edges = append(edges, contact.EdgeContactRelationships)
  9251. }
  9252. if m.contact_messages != nil {
  9253. edges = append(edges, contact.EdgeContactMessages)
  9254. }
  9255. return edges
  9256. }
  9257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9258. // name in this mutation.
  9259. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9260. switch name {
  9261. case contact.EdgeContactRelationships:
  9262. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9263. for id := range m.contact_relationships {
  9264. ids = append(ids, id)
  9265. }
  9266. return ids
  9267. case contact.EdgeContactMessages:
  9268. ids := make([]ent.Value, 0, len(m.contact_messages))
  9269. for id := range m.contact_messages {
  9270. ids = append(ids, id)
  9271. }
  9272. return ids
  9273. }
  9274. return nil
  9275. }
  9276. // RemovedEdges returns all edge names that were removed in this mutation.
  9277. func (m *ContactMutation) RemovedEdges() []string {
  9278. edges := make([]string, 0, 2)
  9279. if m.removedcontact_relationships != nil {
  9280. edges = append(edges, contact.EdgeContactRelationships)
  9281. }
  9282. if m.removedcontact_messages != nil {
  9283. edges = append(edges, contact.EdgeContactMessages)
  9284. }
  9285. return edges
  9286. }
  9287. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9288. // the given name in this mutation.
  9289. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9290. switch name {
  9291. case contact.EdgeContactRelationships:
  9292. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9293. for id := range m.removedcontact_relationships {
  9294. ids = append(ids, id)
  9295. }
  9296. return ids
  9297. case contact.EdgeContactMessages:
  9298. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9299. for id := range m.removedcontact_messages {
  9300. ids = append(ids, id)
  9301. }
  9302. return ids
  9303. }
  9304. return nil
  9305. }
  9306. // ClearedEdges returns all edge names that were cleared in this mutation.
  9307. func (m *ContactMutation) ClearedEdges() []string {
  9308. edges := make([]string, 0, 2)
  9309. if m.clearedcontact_relationships {
  9310. edges = append(edges, contact.EdgeContactRelationships)
  9311. }
  9312. if m.clearedcontact_messages {
  9313. edges = append(edges, contact.EdgeContactMessages)
  9314. }
  9315. return edges
  9316. }
  9317. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9318. // was cleared in this mutation.
  9319. func (m *ContactMutation) EdgeCleared(name string) bool {
  9320. switch name {
  9321. case contact.EdgeContactRelationships:
  9322. return m.clearedcontact_relationships
  9323. case contact.EdgeContactMessages:
  9324. return m.clearedcontact_messages
  9325. }
  9326. return false
  9327. }
  9328. // ClearEdge clears the value of the edge with the given name. It returns an error
  9329. // if that edge is not defined in the schema.
  9330. func (m *ContactMutation) ClearEdge(name string) error {
  9331. switch name {
  9332. }
  9333. return fmt.Errorf("unknown Contact unique edge %s", name)
  9334. }
  9335. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9336. // It returns an error if the edge is not defined in the schema.
  9337. func (m *ContactMutation) ResetEdge(name string) error {
  9338. switch name {
  9339. case contact.EdgeContactRelationships:
  9340. m.ResetContactRelationships()
  9341. return nil
  9342. case contact.EdgeContactMessages:
  9343. m.ResetContactMessages()
  9344. return nil
  9345. }
  9346. return fmt.Errorf("unknown Contact edge %s", name)
  9347. }
  9348. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9349. type CreditBalanceMutation struct {
  9350. config
  9351. op Op
  9352. typ string
  9353. id *uint64
  9354. created_at *time.Time
  9355. updated_at *time.Time
  9356. deleted_at *time.Time
  9357. user_id *string
  9358. balance *float32
  9359. addbalance *float32
  9360. status *int
  9361. addstatus *int
  9362. organization_id *uint64
  9363. addorganization_id *int64
  9364. clearedFields map[string]struct{}
  9365. done bool
  9366. oldValue func(context.Context) (*CreditBalance, error)
  9367. predicates []predicate.CreditBalance
  9368. }
  9369. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9370. // creditbalanceOption allows management of the mutation configuration using functional options.
  9371. type creditbalanceOption func(*CreditBalanceMutation)
  9372. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9373. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9374. m := &CreditBalanceMutation{
  9375. config: c,
  9376. op: op,
  9377. typ: TypeCreditBalance,
  9378. clearedFields: make(map[string]struct{}),
  9379. }
  9380. for _, opt := range opts {
  9381. opt(m)
  9382. }
  9383. return m
  9384. }
  9385. // withCreditBalanceID sets the ID field of the mutation.
  9386. func withCreditBalanceID(id uint64) creditbalanceOption {
  9387. return func(m *CreditBalanceMutation) {
  9388. var (
  9389. err error
  9390. once sync.Once
  9391. value *CreditBalance
  9392. )
  9393. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9394. once.Do(func() {
  9395. if m.done {
  9396. err = errors.New("querying old values post mutation is not allowed")
  9397. } else {
  9398. value, err = m.Client().CreditBalance.Get(ctx, id)
  9399. }
  9400. })
  9401. return value, err
  9402. }
  9403. m.id = &id
  9404. }
  9405. }
  9406. // withCreditBalance sets the old CreditBalance of the mutation.
  9407. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9408. return func(m *CreditBalanceMutation) {
  9409. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9410. return node, nil
  9411. }
  9412. m.id = &node.ID
  9413. }
  9414. }
  9415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9416. // executed in a transaction (ent.Tx), a transactional client is returned.
  9417. func (m CreditBalanceMutation) Client() *Client {
  9418. client := &Client{config: m.config}
  9419. client.init()
  9420. return client
  9421. }
  9422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9423. // it returns an error otherwise.
  9424. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9425. if _, ok := m.driver.(*txDriver); !ok {
  9426. return nil, errors.New("ent: mutation is not running in a transaction")
  9427. }
  9428. tx := &Tx{config: m.config}
  9429. tx.init()
  9430. return tx, nil
  9431. }
  9432. // SetID sets the value of the id field. Note that this
  9433. // operation is only accepted on creation of CreditBalance entities.
  9434. func (m *CreditBalanceMutation) SetID(id uint64) {
  9435. m.id = &id
  9436. }
  9437. // ID returns the ID value in the mutation. Note that the ID is only available
  9438. // if it was provided to the builder or after it was returned from the database.
  9439. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9440. if m.id == nil {
  9441. return
  9442. }
  9443. return *m.id, true
  9444. }
  9445. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9446. // That means, if the mutation is applied within a transaction with an isolation level such
  9447. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9448. // or updated by the mutation.
  9449. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9450. switch {
  9451. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9452. id, exists := m.ID()
  9453. if exists {
  9454. return []uint64{id}, nil
  9455. }
  9456. fallthrough
  9457. case m.op.Is(OpUpdate | OpDelete):
  9458. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9459. default:
  9460. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9461. }
  9462. }
  9463. // SetCreatedAt sets the "created_at" field.
  9464. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9465. m.created_at = &t
  9466. }
  9467. // CreatedAt returns the value of the "created_at" field in the mutation.
  9468. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9469. v := m.created_at
  9470. if v == nil {
  9471. return
  9472. }
  9473. return *v, true
  9474. }
  9475. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9476. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9478. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9479. if !m.op.Is(OpUpdateOne) {
  9480. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9481. }
  9482. if m.id == nil || m.oldValue == nil {
  9483. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9484. }
  9485. oldValue, err := m.oldValue(ctx)
  9486. if err != nil {
  9487. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9488. }
  9489. return oldValue.CreatedAt, nil
  9490. }
  9491. // ResetCreatedAt resets all changes to the "created_at" field.
  9492. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9493. m.created_at = nil
  9494. }
  9495. // SetUpdatedAt sets the "updated_at" field.
  9496. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9497. m.updated_at = &t
  9498. }
  9499. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9500. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9501. v := m.updated_at
  9502. if v == nil {
  9503. return
  9504. }
  9505. return *v, true
  9506. }
  9507. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9508. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9510. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9511. if !m.op.Is(OpUpdateOne) {
  9512. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9513. }
  9514. if m.id == nil || m.oldValue == nil {
  9515. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9516. }
  9517. oldValue, err := m.oldValue(ctx)
  9518. if err != nil {
  9519. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9520. }
  9521. return oldValue.UpdatedAt, nil
  9522. }
  9523. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9524. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9525. m.updated_at = nil
  9526. }
  9527. // SetDeletedAt sets the "deleted_at" field.
  9528. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9529. m.deleted_at = &t
  9530. }
  9531. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9532. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9533. v := m.deleted_at
  9534. if v == nil {
  9535. return
  9536. }
  9537. return *v, true
  9538. }
  9539. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9540. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9542. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9543. if !m.op.Is(OpUpdateOne) {
  9544. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9545. }
  9546. if m.id == nil || m.oldValue == nil {
  9547. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9548. }
  9549. oldValue, err := m.oldValue(ctx)
  9550. if err != nil {
  9551. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9552. }
  9553. return oldValue.DeletedAt, nil
  9554. }
  9555. // ClearDeletedAt clears the value of the "deleted_at" field.
  9556. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9557. m.deleted_at = nil
  9558. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9559. }
  9560. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9561. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9562. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9563. return ok
  9564. }
  9565. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9566. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9567. m.deleted_at = nil
  9568. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9569. }
  9570. // SetUserID sets the "user_id" field.
  9571. func (m *CreditBalanceMutation) SetUserID(s string) {
  9572. m.user_id = &s
  9573. }
  9574. // UserID returns the value of the "user_id" field in the mutation.
  9575. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9576. v := m.user_id
  9577. if v == nil {
  9578. return
  9579. }
  9580. return *v, true
  9581. }
  9582. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9583. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9585. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9586. if !m.op.Is(OpUpdateOne) {
  9587. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9588. }
  9589. if m.id == nil || m.oldValue == nil {
  9590. return v, errors.New("OldUserID requires an ID field in the mutation")
  9591. }
  9592. oldValue, err := m.oldValue(ctx)
  9593. if err != nil {
  9594. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9595. }
  9596. return oldValue.UserID, nil
  9597. }
  9598. // ClearUserID clears the value of the "user_id" field.
  9599. func (m *CreditBalanceMutation) ClearUserID() {
  9600. m.user_id = nil
  9601. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  9602. }
  9603. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  9604. func (m *CreditBalanceMutation) UserIDCleared() bool {
  9605. _, ok := m.clearedFields[creditbalance.FieldUserID]
  9606. return ok
  9607. }
  9608. // ResetUserID resets all changes to the "user_id" field.
  9609. func (m *CreditBalanceMutation) ResetUserID() {
  9610. m.user_id = nil
  9611. delete(m.clearedFields, creditbalance.FieldUserID)
  9612. }
  9613. // SetBalance sets the "balance" field.
  9614. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9615. m.balance = &f
  9616. m.addbalance = nil
  9617. }
  9618. // Balance returns the value of the "balance" field in the mutation.
  9619. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9620. v := m.balance
  9621. if v == nil {
  9622. return
  9623. }
  9624. return *v, true
  9625. }
  9626. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9627. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9629. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9630. if !m.op.Is(OpUpdateOne) {
  9631. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9632. }
  9633. if m.id == nil || m.oldValue == nil {
  9634. return v, errors.New("OldBalance requires an ID field in the mutation")
  9635. }
  9636. oldValue, err := m.oldValue(ctx)
  9637. if err != nil {
  9638. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9639. }
  9640. return oldValue.Balance, nil
  9641. }
  9642. // AddBalance adds f to the "balance" field.
  9643. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9644. if m.addbalance != nil {
  9645. *m.addbalance += f
  9646. } else {
  9647. m.addbalance = &f
  9648. }
  9649. }
  9650. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9651. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9652. v := m.addbalance
  9653. if v == nil {
  9654. return
  9655. }
  9656. return *v, true
  9657. }
  9658. // ResetBalance resets all changes to the "balance" field.
  9659. func (m *CreditBalanceMutation) ResetBalance() {
  9660. m.balance = nil
  9661. m.addbalance = nil
  9662. }
  9663. // SetStatus sets the "status" field.
  9664. func (m *CreditBalanceMutation) SetStatus(i int) {
  9665. m.status = &i
  9666. m.addstatus = nil
  9667. }
  9668. // Status returns the value of the "status" field in the mutation.
  9669. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9670. v := m.status
  9671. if v == nil {
  9672. return
  9673. }
  9674. return *v, true
  9675. }
  9676. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9677. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9679. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9680. if !m.op.Is(OpUpdateOne) {
  9681. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9682. }
  9683. if m.id == nil || m.oldValue == nil {
  9684. return v, errors.New("OldStatus requires an ID field in the mutation")
  9685. }
  9686. oldValue, err := m.oldValue(ctx)
  9687. if err != nil {
  9688. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9689. }
  9690. return oldValue.Status, nil
  9691. }
  9692. // AddStatus adds i to the "status" field.
  9693. func (m *CreditBalanceMutation) AddStatus(i int) {
  9694. if m.addstatus != nil {
  9695. *m.addstatus += i
  9696. } else {
  9697. m.addstatus = &i
  9698. }
  9699. }
  9700. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9701. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9702. v := m.addstatus
  9703. if v == nil {
  9704. return
  9705. }
  9706. return *v, true
  9707. }
  9708. // ClearStatus clears the value of the "status" field.
  9709. func (m *CreditBalanceMutation) ClearStatus() {
  9710. m.status = nil
  9711. m.addstatus = nil
  9712. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9713. }
  9714. // StatusCleared returns if the "status" field was cleared in this mutation.
  9715. func (m *CreditBalanceMutation) StatusCleared() bool {
  9716. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9717. return ok
  9718. }
  9719. // ResetStatus resets all changes to the "status" field.
  9720. func (m *CreditBalanceMutation) ResetStatus() {
  9721. m.status = nil
  9722. m.addstatus = nil
  9723. delete(m.clearedFields, creditbalance.FieldStatus)
  9724. }
  9725. // SetOrganizationID sets the "organization_id" field.
  9726. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9727. m.organization_id = &u
  9728. m.addorganization_id = nil
  9729. }
  9730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9731. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9732. v := m.organization_id
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9739. // If the CreditBalance 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 *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9742. if !m.op.Is(OpUpdateOne) {
  9743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9744. }
  9745. if m.id == nil || m.oldValue == nil {
  9746. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  9751. }
  9752. return oldValue.OrganizationID, nil
  9753. }
  9754. // AddOrganizationID adds u to the "organization_id" field.
  9755. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9756. if m.addorganization_id != nil {
  9757. *m.addorganization_id += u
  9758. } else {
  9759. m.addorganization_id = &u
  9760. }
  9761. }
  9762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9763. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9764. v := m.addorganization_id
  9765. if v == nil {
  9766. return
  9767. }
  9768. return *v, true
  9769. }
  9770. // ClearOrganizationID clears the value of the "organization_id" field.
  9771. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9772. m.organization_id = nil
  9773. m.addorganization_id = nil
  9774. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9775. }
  9776. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9777. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9778. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9779. return ok
  9780. }
  9781. // ResetOrganizationID resets all changes to the "organization_id" field.
  9782. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9783. m.organization_id = nil
  9784. m.addorganization_id = nil
  9785. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9786. }
  9787. // Where appends a list predicates to the CreditBalanceMutation builder.
  9788. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9789. m.predicates = append(m.predicates, ps...)
  9790. }
  9791. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9792. // users can use type-assertion to append predicates that do not depend on any generated package.
  9793. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9794. p := make([]predicate.CreditBalance, len(ps))
  9795. for i := range ps {
  9796. p[i] = ps[i]
  9797. }
  9798. m.Where(p...)
  9799. }
  9800. // Op returns the operation name.
  9801. func (m *CreditBalanceMutation) Op() Op {
  9802. return m.op
  9803. }
  9804. // SetOp allows setting the mutation operation.
  9805. func (m *CreditBalanceMutation) SetOp(op Op) {
  9806. m.op = op
  9807. }
  9808. // Type returns the node type of this mutation (CreditBalance).
  9809. func (m *CreditBalanceMutation) Type() string {
  9810. return m.typ
  9811. }
  9812. // Fields returns all fields that were changed during this mutation. Note that in
  9813. // order to get all numeric fields that were incremented/decremented, call
  9814. // AddedFields().
  9815. func (m *CreditBalanceMutation) Fields() []string {
  9816. fields := make([]string, 0, 7)
  9817. if m.created_at != nil {
  9818. fields = append(fields, creditbalance.FieldCreatedAt)
  9819. }
  9820. if m.updated_at != nil {
  9821. fields = append(fields, creditbalance.FieldUpdatedAt)
  9822. }
  9823. if m.deleted_at != nil {
  9824. fields = append(fields, creditbalance.FieldDeletedAt)
  9825. }
  9826. if m.user_id != nil {
  9827. fields = append(fields, creditbalance.FieldUserID)
  9828. }
  9829. if m.balance != nil {
  9830. fields = append(fields, creditbalance.FieldBalance)
  9831. }
  9832. if m.status != nil {
  9833. fields = append(fields, creditbalance.FieldStatus)
  9834. }
  9835. if m.organization_id != nil {
  9836. fields = append(fields, creditbalance.FieldOrganizationID)
  9837. }
  9838. return fields
  9839. }
  9840. // Field returns the value of a field with the given name. The second boolean
  9841. // return value indicates that this field was not set, or was not defined in the
  9842. // schema.
  9843. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9844. switch name {
  9845. case creditbalance.FieldCreatedAt:
  9846. return m.CreatedAt()
  9847. case creditbalance.FieldUpdatedAt:
  9848. return m.UpdatedAt()
  9849. case creditbalance.FieldDeletedAt:
  9850. return m.DeletedAt()
  9851. case creditbalance.FieldUserID:
  9852. return m.UserID()
  9853. case creditbalance.FieldBalance:
  9854. return m.Balance()
  9855. case creditbalance.FieldStatus:
  9856. return m.Status()
  9857. case creditbalance.FieldOrganizationID:
  9858. return m.OrganizationID()
  9859. }
  9860. return nil, false
  9861. }
  9862. // OldField returns the old value of the field from the database. An error is
  9863. // returned if the mutation operation is not UpdateOne, or the query to the
  9864. // database failed.
  9865. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9866. switch name {
  9867. case creditbalance.FieldCreatedAt:
  9868. return m.OldCreatedAt(ctx)
  9869. case creditbalance.FieldUpdatedAt:
  9870. return m.OldUpdatedAt(ctx)
  9871. case creditbalance.FieldDeletedAt:
  9872. return m.OldDeletedAt(ctx)
  9873. case creditbalance.FieldUserID:
  9874. return m.OldUserID(ctx)
  9875. case creditbalance.FieldBalance:
  9876. return m.OldBalance(ctx)
  9877. case creditbalance.FieldStatus:
  9878. return m.OldStatus(ctx)
  9879. case creditbalance.FieldOrganizationID:
  9880. return m.OldOrganizationID(ctx)
  9881. }
  9882. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9883. }
  9884. // SetField sets the value of a field with the given name. It returns an error if
  9885. // the field is not defined in the schema, or if the type mismatched the field
  9886. // type.
  9887. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9888. switch name {
  9889. case creditbalance.FieldCreatedAt:
  9890. v, ok := value.(time.Time)
  9891. if !ok {
  9892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9893. }
  9894. m.SetCreatedAt(v)
  9895. return nil
  9896. case creditbalance.FieldUpdatedAt:
  9897. v, ok := value.(time.Time)
  9898. if !ok {
  9899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9900. }
  9901. m.SetUpdatedAt(v)
  9902. return nil
  9903. case creditbalance.FieldDeletedAt:
  9904. v, ok := value.(time.Time)
  9905. if !ok {
  9906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9907. }
  9908. m.SetDeletedAt(v)
  9909. return nil
  9910. case creditbalance.FieldUserID:
  9911. v, ok := value.(string)
  9912. if !ok {
  9913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9914. }
  9915. m.SetUserID(v)
  9916. return nil
  9917. case creditbalance.FieldBalance:
  9918. v, ok := value.(float32)
  9919. if !ok {
  9920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9921. }
  9922. m.SetBalance(v)
  9923. return nil
  9924. case creditbalance.FieldStatus:
  9925. v, ok := value.(int)
  9926. if !ok {
  9927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9928. }
  9929. m.SetStatus(v)
  9930. return nil
  9931. case creditbalance.FieldOrganizationID:
  9932. v, ok := value.(uint64)
  9933. if !ok {
  9934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9935. }
  9936. m.SetOrganizationID(v)
  9937. return nil
  9938. }
  9939. return fmt.Errorf("unknown CreditBalance field %s", name)
  9940. }
  9941. // AddedFields returns all numeric fields that were incremented/decremented during
  9942. // this mutation.
  9943. func (m *CreditBalanceMutation) AddedFields() []string {
  9944. var fields []string
  9945. if m.addbalance != nil {
  9946. fields = append(fields, creditbalance.FieldBalance)
  9947. }
  9948. if m.addstatus != nil {
  9949. fields = append(fields, creditbalance.FieldStatus)
  9950. }
  9951. if m.addorganization_id != nil {
  9952. fields = append(fields, creditbalance.FieldOrganizationID)
  9953. }
  9954. return fields
  9955. }
  9956. // AddedField returns the numeric value that was incremented/decremented on a field
  9957. // with the given name. The second boolean return value indicates that this field
  9958. // was not set, or was not defined in the schema.
  9959. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9960. switch name {
  9961. case creditbalance.FieldBalance:
  9962. return m.AddedBalance()
  9963. case creditbalance.FieldStatus:
  9964. return m.AddedStatus()
  9965. case creditbalance.FieldOrganizationID:
  9966. return m.AddedOrganizationID()
  9967. }
  9968. return nil, false
  9969. }
  9970. // AddField adds the value to the field with the given name. It returns an error if
  9971. // the field is not defined in the schema, or if the type mismatched the field
  9972. // type.
  9973. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9974. switch name {
  9975. case creditbalance.FieldBalance:
  9976. v, ok := value.(float32)
  9977. if !ok {
  9978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9979. }
  9980. m.AddBalance(v)
  9981. return nil
  9982. case creditbalance.FieldStatus:
  9983. v, ok := value.(int)
  9984. if !ok {
  9985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9986. }
  9987. m.AddStatus(v)
  9988. return nil
  9989. case creditbalance.FieldOrganizationID:
  9990. v, ok := value.(int64)
  9991. if !ok {
  9992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9993. }
  9994. m.AddOrganizationID(v)
  9995. return nil
  9996. }
  9997. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9998. }
  9999. // ClearedFields returns all nullable fields that were cleared during this
  10000. // mutation.
  10001. func (m *CreditBalanceMutation) ClearedFields() []string {
  10002. var fields []string
  10003. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10004. fields = append(fields, creditbalance.FieldDeletedAt)
  10005. }
  10006. if m.FieldCleared(creditbalance.FieldUserID) {
  10007. fields = append(fields, creditbalance.FieldUserID)
  10008. }
  10009. if m.FieldCleared(creditbalance.FieldStatus) {
  10010. fields = append(fields, creditbalance.FieldStatus)
  10011. }
  10012. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10013. fields = append(fields, creditbalance.FieldOrganizationID)
  10014. }
  10015. return fields
  10016. }
  10017. // FieldCleared returns a boolean indicating if a field with the given name was
  10018. // cleared in this mutation.
  10019. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10020. _, ok := m.clearedFields[name]
  10021. return ok
  10022. }
  10023. // ClearField clears the value of the field with the given name. It returns an
  10024. // error if the field is not defined in the schema.
  10025. func (m *CreditBalanceMutation) ClearField(name string) error {
  10026. switch name {
  10027. case creditbalance.FieldDeletedAt:
  10028. m.ClearDeletedAt()
  10029. return nil
  10030. case creditbalance.FieldUserID:
  10031. m.ClearUserID()
  10032. return nil
  10033. case creditbalance.FieldStatus:
  10034. m.ClearStatus()
  10035. return nil
  10036. case creditbalance.FieldOrganizationID:
  10037. m.ClearOrganizationID()
  10038. return nil
  10039. }
  10040. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10041. }
  10042. // ResetField resets all changes in the mutation for the field with the given name.
  10043. // It returns an error if the field is not defined in the schema.
  10044. func (m *CreditBalanceMutation) ResetField(name string) error {
  10045. switch name {
  10046. case creditbalance.FieldCreatedAt:
  10047. m.ResetCreatedAt()
  10048. return nil
  10049. case creditbalance.FieldUpdatedAt:
  10050. m.ResetUpdatedAt()
  10051. return nil
  10052. case creditbalance.FieldDeletedAt:
  10053. m.ResetDeletedAt()
  10054. return nil
  10055. case creditbalance.FieldUserID:
  10056. m.ResetUserID()
  10057. return nil
  10058. case creditbalance.FieldBalance:
  10059. m.ResetBalance()
  10060. return nil
  10061. case creditbalance.FieldStatus:
  10062. m.ResetStatus()
  10063. return nil
  10064. case creditbalance.FieldOrganizationID:
  10065. m.ResetOrganizationID()
  10066. return nil
  10067. }
  10068. return fmt.Errorf("unknown CreditBalance field %s", name)
  10069. }
  10070. // AddedEdges returns all edge names that were set/added in this mutation.
  10071. func (m *CreditBalanceMutation) AddedEdges() []string {
  10072. edges := make([]string, 0, 0)
  10073. return edges
  10074. }
  10075. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10076. // name in this mutation.
  10077. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10078. return nil
  10079. }
  10080. // RemovedEdges returns all edge names that were removed in this mutation.
  10081. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10082. edges := make([]string, 0, 0)
  10083. return edges
  10084. }
  10085. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10086. // the given name in this mutation.
  10087. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10088. return nil
  10089. }
  10090. // ClearedEdges returns all edge names that were cleared in this mutation.
  10091. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10092. edges := make([]string, 0, 0)
  10093. return edges
  10094. }
  10095. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10096. // was cleared in this mutation.
  10097. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10098. return false
  10099. }
  10100. // ClearEdge clears the value of the edge with the given name. It returns an error
  10101. // if that edge is not defined in the schema.
  10102. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10103. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10104. }
  10105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10106. // It returns an error if the edge is not defined in the schema.
  10107. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10108. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10109. }
  10110. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10111. type CreditUsageMutation struct {
  10112. config
  10113. op Op
  10114. typ string
  10115. id *uint64
  10116. created_at *time.Time
  10117. updated_at *time.Time
  10118. deleted_at *time.Time
  10119. user_id *string
  10120. number *float32
  10121. addnumber *float32
  10122. status *int
  10123. addstatus *int
  10124. ntype *int
  10125. addntype *int
  10126. table *string
  10127. organization_id *uint64
  10128. addorganization_id *int64
  10129. nid *uint64
  10130. addnid *int64
  10131. reason *string
  10132. operator *string
  10133. clearedFields map[string]struct{}
  10134. done bool
  10135. oldValue func(context.Context) (*CreditUsage, error)
  10136. predicates []predicate.CreditUsage
  10137. }
  10138. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10139. // creditusageOption allows management of the mutation configuration using functional options.
  10140. type creditusageOption func(*CreditUsageMutation)
  10141. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10142. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10143. m := &CreditUsageMutation{
  10144. config: c,
  10145. op: op,
  10146. typ: TypeCreditUsage,
  10147. clearedFields: make(map[string]struct{}),
  10148. }
  10149. for _, opt := range opts {
  10150. opt(m)
  10151. }
  10152. return m
  10153. }
  10154. // withCreditUsageID sets the ID field of the mutation.
  10155. func withCreditUsageID(id uint64) creditusageOption {
  10156. return func(m *CreditUsageMutation) {
  10157. var (
  10158. err error
  10159. once sync.Once
  10160. value *CreditUsage
  10161. )
  10162. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10163. once.Do(func() {
  10164. if m.done {
  10165. err = errors.New("querying old values post mutation is not allowed")
  10166. } else {
  10167. value, err = m.Client().CreditUsage.Get(ctx, id)
  10168. }
  10169. })
  10170. return value, err
  10171. }
  10172. m.id = &id
  10173. }
  10174. }
  10175. // withCreditUsage sets the old CreditUsage of the mutation.
  10176. func withCreditUsage(node *CreditUsage) creditusageOption {
  10177. return func(m *CreditUsageMutation) {
  10178. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10179. return node, nil
  10180. }
  10181. m.id = &node.ID
  10182. }
  10183. }
  10184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10185. // executed in a transaction (ent.Tx), a transactional client is returned.
  10186. func (m CreditUsageMutation) Client() *Client {
  10187. client := &Client{config: m.config}
  10188. client.init()
  10189. return client
  10190. }
  10191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10192. // it returns an error otherwise.
  10193. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10194. if _, ok := m.driver.(*txDriver); !ok {
  10195. return nil, errors.New("ent: mutation is not running in a transaction")
  10196. }
  10197. tx := &Tx{config: m.config}
  10198. tx.init()
  10199. return tx, nil
  10200. }
  10201. // SetID sets the value of the id field. Note that this
  10202. // operation is only accepted on creation of CreditUsage entities.
  10203. func (m *CreditUsageMutation) SetID(id uint64) {
  10204. m.id = &id
  10205. }
  10206. // ID returns the ID value in the mutation. Note that the ID is only available
  10207. // if it was provided to the builder or after it was returned from the database.
  10208. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10209. if m.id == nil {
  10210. return
  10211. }
  10212. return *m.id, true
  10213. }
  10214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10215. // That means, if the mutation is applied within a transaction with an isolation level such
  10216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10217. // or updated by the mutation.
  10218. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10219. switch {
  10220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10221. id, exists := m.ID()
  10222. if exists {
  10223. return []uint64{id}, nil
  10224. }
  10225. fallthrough
  10226. case m.op.Is(OpUpdate | OpDelete):
  10227. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10228. default:
  10229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10230. }
  10231. }
  10232. // SetCreatedAt sets the "created_at" field.
  10233. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10234. m.created_at = &t
  10235. }
  10236. // CreatedAt returns the value of the "created_at" field in the mutation.
  10237. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10238. v := m.created_at
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10245. // If the CreditUsage 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 *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10248. if !m.op.Is(OpUpdateOne) {
  10249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10250. }
  10251. if m.id == nil || m.oldValue == nil {
  10252. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  10257. }
  10258. return oldValue.CreatedAt, nil
  10259. }
  10260. // ResetCreatedAt resets all changes to the "created_at" field.
  10261. func (m *CreditUsageMutation) ResetCreatedAt() {
  10262. m.created_at = nil
  10263. }
  10264. // SetUpdatedAt sets the "updated_at" field.
  10265. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10266. m.updated_at = &t
  10267. }
  10268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10269. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10270. v := m.updated_at
  10271. if v == nil {
  10272. return
  10273. }
  10274. return *v, true
  10275. }
  10276. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10277. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10279. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10280. if !m.op.Is(OpUpdateOne) {
  10281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10282. }
  10283. if m.id == nil || m.oldValue == nil {
  10284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10285. }
  10286. oldValue, err := m.oldValue(ctx)
  10287. if err != nil {
  10288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10289. }
  10290. return oldValue.UpdatedAt, nil
  10291. }
  10292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10293. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10294. m.updated_at = nil
  10295. }
  10296. // SetDeletedAt sets the "deleted_at" field.
  10297. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10298. m.deleted_at = &t
  10299. }
  10300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10301. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10302. v := m.deleted_at
  10303. if v == nil {
  10304. return
  10305. }
  10306. return *v, true
  10307. }
  10308. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10309. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10311. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10312. if !m.op.Is(OpUpdateOne) {
  10313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10314. }
  10315. if m.id == nil || m.oldValue == nil {
  10316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10317. }
  10318. oldValue, err := m.oldValue(ctx)
  10319. if err != nil {
  10320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10321. }
  10322. return oldValue.DeletedAt, nil
  10323. }
  10324. // ClearDeletedAt clears the value of the "deleted_at" field.
  10325. func (m *CreditUsageMutation) ClearDeletedAt() {
  10326. m.deleted_at = nil
  10327. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10328. }
  10329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10330. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10331. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10332. return ok
  10333. }
  10334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10335. func (m *CreditUsageMutation) ResetDeletedAt() {
  10336. m.deleted_at = nil
  10337. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10338. }
  10339. // SetUserID sets the "user_id" field.
  10340. func (m *CreditUsageMutation) SetUserID(s string) {
  10341. m.user_id = &s
  10342. }
  10343. // UserID returns the value of the "user_id" field in the mutation.
  10344. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10345. v := m.user_id
  10346. if v == nil {
  10347. return
  10348. }
  10349. return *v, true
  10350. }
  10351. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10352. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10354. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10355. if !m.op.Is(OpUpdateOne) {
  10356. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10357. }
  10358. if m.id == nil || m.oldValue == nil {
  10359. return v, errors.New("OldUserID requires an ID field in the mutation")
  10360. }
  10361. oldValue, err := m.oldValue(ctx)
  10362. if err != nil {
  10363. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10364. }
  10365. return oldValue.UserID, nil
  10366. }
  10367. // ClearUserID clears the value of the "user_id" field.
  10368. func (m *CreditUsageMutation) ClearUserID() {
  10369. m.user_id = nil
  10370. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  10371. }
  10372. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  10373. func (m *CreditUsageMutation) UserIDCleared() bool {
  10374. _, ok := m.clearedFields[creditusage.FieldUserID]
  10375. return ok
  10376. }
  10377. // ResetUserID resets all changes to the "user_id" field.
  10378. func (m *CreditUsageMutation) ResetUserID() {
  10379. m.user_id = nil
  10380. delete(m.clearedFields, creditusage.FieldUserID)
  10381. }
  10382. // SetNumber sets the "number" field.
  10383. func (m *CreditUsageMutation) SetNumber(f float32) {
  10384. m.number = &f
  10385. m.addnumber = nil
  10386. }
  10387. // Number returns the value of the "number" field in the mutation.
  10388. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10389. v := m.number
  10390. if v == nil {
  10391. return
  10392. }
  10393. return *v, true
  10394. }
  10395. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10396. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10398. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10399. if !m.op.Is(OpUpdateOne) {
  10400. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10401. }
  10402. if m.id == nil || m.oldValue == nil {
  10403. return v, errors.New("OldNumber requires an ID field in the mutation")
  10404. }
  10405. oldValue, err := m.oldValue(ctx)
  10406. if err != nil {
  10407. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10408. }
  10409. return oldValue.Number, nil
  10410. }
  10411. // AddNumber adds f to the "number" field.
  10412. func (m *CreditUsageMutation) AddNumber(f float32) {
  10413. if m.addnumber != nil {
  10414. *m.addnumber += f
  10415. } else {
  10416. m.addnumber = &f
  10417. }
  10418. }
  10419. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10420. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10421. v := m.addnumber
  10422. if v == nil {
  10423. return
  10424. }
  10425. return *v, true
  10426. }
  10427. // ResetNumber resets all changes to the "number" field.
  10428. func (m *CreditUsageMutation) ResetNumber() {
  10429. m.number = nil
  10430. m.addnumber = nil
  10431. }
  10432. // SetStatus sets the "status" field.
  10433. func (m *CreditUsageMutation) SetStatus(i int) {
  10434. m.status = &i
  10435. m.addstatus = nil
  10436. }
  10437. // Status returns the value of the "status" field in the mutation.
  10438. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10439. v := m.status
  10440. if v == nil {
  10441. return
  10442. }
  10443. return *v, true
  10444. }
  10445. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10446. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10448. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10449. if !m.op.Is(OpUpdateOne) {
  10450. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10451. }
  10452. if m.id == nil || m.oldValue == nil {
  10453. return v, errors.New("OldStatus requires an ID field in the mutation")
  10454. }
  10455. oldValue, err := m.oldValue(ctx)
  10456. if err != nil {
  10457. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10458. }
  10459. return oldValue.Status, nil
  10460. }
  10461. // AddStatus adds i to the "status" field.
  10462. func (m *CreditUsageMutation) AddStatus(i int) {
  10463. if m.addstatus != nil {
  10464. *m.addstatus += i
  10465. } else {
  10466. m.addstatus = &i
  10467. }
  10468. }
  10469. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10470. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10471. v := m.addstatus
  10472. if v == nil {
  10473. return
  10474. }
  10475. return *v, true
  10476. }
  10477. // ClearStatus clears the value of the "status" field.
  10478. func (m *CreditUsageMutation) ClearStatus() {
  10479. m.status = nil
  10480. m.addstatus = nil
  10481. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10482. }
  10483. // StatusCleared returns if the "status" field was cleared in this mutation.
  10484. func (m *CreditUsageMutation) StatusCleared() bool {
  10485. _, ok := m.clearedFields[creditusage.FieldStatus]
  10486. return ok
  10487. }
  10488. // ResetStatus resets all changes to the "status" field.
  10489. func (m *CreditUsageMutation) ResetStatus() {
  10490. m.status = nil
  10491. m.addstatus = nil
  10492. delete(m.clearedFields, creditusage.FieldStatus)
  10493. }
  10494. // SetNtype sets the "ntype" field.
  10495. func (m *CreditUsageMutation) SetNtype(i int) {
  10496. m.ntype = &i
  10497. m.addntype = nil
  10498. }
  10499. // Ntype returns the value of the "ntype" field in the mutation.
  10500. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10501. v := m.ntype
  10502. if v == nil {
  10503. return
  10504. }
  10505. return *v, true
  10506. }
  10507. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10508. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10510. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10511. if !m.op.Is(OpUpdateOne) {
  10512. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10513. }
  10514. if m.id == nil || m.oldValue == nil {
  10515. return v, errors.New("OldNtype requires an ID field in the mutation")
  10516. }
  10517. oldValue, err := m.oldValue(ctx)
  10518. if err != nil {
  10519. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10520. }
  10521. return oldValue.Ntype, nil
  10522. }
  10523. // AddNtype adds i to the "ntype" field.
  10524. func (m *CreditUsageMutation) AddNtype(i int) {
  10525. if m.addntype != nil {
  10526. *m.addntype += i
  10527. } else {
  10528. m.addntype = &i
  10529. }
  10530. }
  10531. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10532. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10533. v := m.addntype
  10534. if v == nil {
  10535. return
  10536. }
  10537. return *v, true
  10538. }
  10539. // ResetNtype resets all changes to the "ntype" field.
  10540. func (m *CreditUsageMutation) ResetNtype() {
  10541. m.ntype = nil
  10542. m.addntype = nil
  10543. }
  10544. // SetTable sets the "table" field.
  10545. func (m *CreditUsageMutation) SetTable(s string) {
  10546. m.table = &s
  10547. }
  10548. // Table returns the value of the "table" field in the mutation.
  10549. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10550. v := m.table
  10551. if v == nil {
  10552. return
  10553. }
  10554. return *v, true
  10555. }
  10556. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10557. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10559. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10560. if !m.op.Is(OpUpdateOne) {
  10561. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10562. }
  10563. if m.id == nil || m.oldValue == nil {
  10564. return v, errors.New("OldTable requires an ID field in the mutation")
  10565. }
  10566. oldValue, err := m.oldValue(ctx)
  10567. if err != nil {
  10568. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10569. }
  10570. return oldValue.Table, nil
  10571. }
  10572. // ResetTable resets all changes to the "table" field.
  10573. func (m *CreditUsageMutation) ResetTable() {
  10574. m.table = nil
  10575. }
  10576. // SetOrganizationID sets the "organization_id" field.
  10577. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10578. m.organization_id = &u
  10579. m.addorganization_id = nil
  10580. }
  10581. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10582. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10583. v := m.organization_id
  10584. if v == nil {
  10585. return
  10586. }
  10587. return *v, true
  10588. }
  10589. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10590. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10592. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10593. if !m.op.Is(OpUpdateOne) {
  10594. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10595. }
  10596. if m.id == nil || m.oldValue == nil {
  10597. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10598. }
  10599. oldValue, err := m.oldValue(ctx)
  10600. if err != nil {
  10601. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10602. }
  10603. return oldValue.OrganizationID, nil
  10604. }
  10605. // AddOrganizationID adds u to the "organization_id" field.
  10606. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10607. if m.addorganization_id != nil {
  10608. *m.addorganization_id += u
  10609. } else {
  10610. m.addorganization_id = &u
  10611. }
  10612. }
  10613. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10614. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10615. v := m.addorganization_id
  10616. if v == nil {
  10617. return
  10618. }
  10619. return *v, true
  10620. }
  10621. // ClearOrganizationID clears the value of the "organization_id" field.
  10622. func (m *CreditUsageMutation) ClearOrganizationID() {
  10623. m.organization_id = nil
  10624. m.addorganization_id = nil
  10625. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10626. }
  10627. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10628. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10629. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10630. return ok
  10631. }
  10632. // ResetOrganizationID resets all changes to the "organization_id" field.
  10633. func (m *CreditUsageMutation) ResetOrganizationID() {
  10634. m.organization_id = nil
  10635. m.addorganization_id = nil
  10636. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10637. }
  10638. // SetNid sets the "nid" field.
  10639. func (m *CreditUsageMutation) SetNid(u uint64) {
  10640. m.nid = &u
  10641. m.addnid = nil
  10642. }
  10643. // Nid returns the value of the "nid" field in the mutation.
  10644. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10645. v := m.nid
  10646. if v == nil {
  10647. return
  10648. }
  10649. return *v, true
  10650. }
  10651. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10652. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10654. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10655. if !m.op.Is(OpUpdateOne) {
  10656. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10657. }
  10658. if m.id == nil || m.oldValue == nil {
  10659. return v, errors.New("OldNid requires an ID field in the mutation")
  10660. }
  10661. oldValue, err := m.oldValue(ctx)
  10662. if err != nil {
  10663. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10664. }
  10665. return oldValue.Nid, nil
  10666. }
  10667. // AddNid adds u to the "nid" field.
  10668. func (m *CreditUsageMutation) AddNid(u int64) {
  10669. if m.addnid != nil {
  10670. *m.addnid += u
  10671. } else {
  10672. m.addnid = &u
  10673. }
  10674. }
  10675. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10676. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10677. v := m.addnid
  10678. if v == nil {
  10679. return
  10680. }
  10681. return *v, true
  10682. }
  10683. // ResetNid resets all changes to the "nid" field.
  10684. func (m *CreditUsageMutation) ResetNid() {
  10685. m.nid = nil
  10686. m.addnid = nil
  10687. }
  10688. // SetReason sets the "reason" field.
  10689. func (m *CreditUsageMutation) SetReason(s string) {
  10690. m.reason = &s
  10691. }
  10692. // Reason returns the value of the "reason" field in the mutation.
  10693. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10694. v := m.reason
  10695. if v == nil {
  10696. return
  10697. }
  10698. return *v, true
  10699. }
  10700. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10701. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10703. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10704. if !m.op.Is(OpUpdateOne) {
  10705. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10706. }
  10707. if m.id == nil || m.oldValue == nil {
  10708. return v, errors.New("OldReason requires an ID field in the mutation")
  10709. }
  10710. oldValue, err := m.oldValue(ctx)
  10711. if err != nil {
  10712. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10713. }
  10714. return oldValue.Reason, nil
  10715. }
  10716. // ResetReason resets all changes to the "reason" field.
  10717. func (m *CreditUsageMutation) ResetReason() {
  10718. m.reason = nil
  10719. }
  10720. // SetOperator sets the "operator" field.
  10721. func (m *CreditUsageMutation) SetOperator(s string) {
  10722. m.operator = &s
  10723. }
  10724. // Operator returns the value of the "operator" field in the mutation.
  10725. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10726. v := m.operator
  10727. if v == nil {
  10728. return
  10729. }
  10730. return *v, true
  10731. }
  10732. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10733. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10735. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10736. if !m.op.Is(OpUpdateOne) {
  10737. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10738. }
  10739. if m.id == nil || m.oldValue == nil {
  10740. return v, errors.New("OldOperator requires an ID field in the mutation")
  10741. }
  10742. oldValue, err := m.oldValue(ctx)
  10743. if err != nil {
  10744. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10745. }
  10746. return oldValue.Operator, nil
  10747. }
  10748. // ResetOperator resets all changes to the "operator" field.
  10749. func (m *CreditUsageMutation) ResetOperator() {
  10750. m.operator = nil
  10751. }
  10752. // Where appends a list predicates to the CreditUsageMutation builder.
  10753. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10754. m.predicates = append(m.predicates, ps...)
  10755. }
  10756. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10757. // users can use type-assertion to append predicates that do not depend on any generated package.
  10758. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10759. p := make([]predicate.CreditUsage, len(ps))
  10760. for i := range ps {
  10761. p[i] = ps[i]
  10762. }
  10763. m.Where(p...)
  10764. }
  10765. // Op returns the operation name.
  10766. func (m *CreditUsageMutation) Op() Op {
  10767. return m.op
  10768. }
  10769. // SetOp allows setting the mutation operation.
  10770. func (m *CreditUsageMutation) SetOp(op Op) {
  10771. m.op = op
  10772. }
  10773. // Type returns the node type of this mutation (CreditUsage).
  10774. func (m *CreditUsageMutation) Type() string {
  10775. return m.typ
  10776. }
  10777. // Fields returns all fields that were changed during this mutation. Note that in
  10778. // order to get all numeric fields that were incremented/decremented, call
  10779. // AddedFields().
  10780. func (m *CreditUsageMutation) Fields() []string {
  10781. fields := make([]string, 0, 12)
  10782. if m.created_at != nil {
  10783. fields = append(fields, creditusage.FieldCreatedAt)
  10784. }
  10785. if m.updated_at != nil {
  10786. fields = append(fields, creditusage.FieldUpdatedAt)
  10787. }
  10788. if m.deleted_at != nil {
  10789. fields = append(fields, creditusage.FieldDeletedAt)
  10790. }
  10791. if m.user_id != nil {
  10792. fields = append(fields, creditusage.FieldUserID)
  10793. }
  10794. if m.number != nil {
  10795. fields = append(fields, creditusage.FieldNumber)
  10796. }
  10797. if m.status != nil {
  10798. fields = append(fields, creditusage.FieldStatus)
  10799. }
  10800. if m.ntype != nil {
  10801. fields = append(fields, creditusage.FieldNtype)
  10802. }
  10803. if m.table != nil {
  10804. fields = append(fields, creditusage.FieldTable)
  10805. }
  10806. if m.organization_id != nil {
  10807. fields = append(fields, creditusage.FieldOrganizationID)
  10808. }
  10809. if m.nid != nil {
  10810. fields = append(fields, creditusage.FieldNid)
  10811. }
  10812. if m.reason != nil {
  10813. fields = append(fields, creditusage.FieldReason)
  10814. }
  10815. if m.operator != nil {
  10816. fields = append(fields, creditusage.FieldOperator)
  10817. }
  10818. return fields
  10819. }
  10820. // Field returns the value of a field with the given name. The second boolean
  10821. // return value indicates that this field was not set, or was not defined in the
  10822. // schema.
  10823. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10824. switch name {
  10825. case creditusage.FieldCreatedAt:
  10826. return m.CreatedAt()
  10827. case creditusage.FieldUpdatedAt:
  10828. return m.UpdatedAt()
  10829. case creditusage.FieldDeletedAt:
  10830. return m.DeletedAt()
  10831. case creditusage.FieldUserID:
  10832. return m.UserID()
  10833. case creditusage.FieldNumber:
  10834. return m.Number()
  10835. case creditusage.FieldStatus:
  10836. return m.Status()
  10837. case creditusage.FieldNtype:
  10838. return m.Ntype()
  10839. case creditusage.FieldTable:
  10840. return m.Table()
  10841. case creditusage.FieldOrganizationID:
  10842. return m.OrganizationID()
  10843. case creditusage.FieldNid:
  10844. return m.Nid()
  10845. case creditusage.FieldReason:
  10846. return m.Reason()
  10847. case creditusage.FieldOperator:
  10848. return m.Operator()
  10849. }
  10850. return nil, false
  10851. }
  10852. // OldField returns the old value of the field from the database. An error is
  10853. // returned if the mutation operation is not UpdateOne, or the query to the
  10854. // database failed.
  10855. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10856. switch name {
  10857. case creditusage.FieldCreatedAt:
  10858. return m.OldCreatedAt(ctx)
  10859. case creditusage.FieldUpdatedAt:
  10860. return m.OldUpdatedAt(ctx)
  10861. case creditusage.FieldDeletedAt:
  10862. return m.OldDeletedAt(ctx)
  10863. case creditusage.FieldUserID:
  10864. return m.OldUserID(ctx)
  10865. case creditusage.FieldNumber:
  10866. return m.OldNumber(ctx)
  10867. case creditusage.FieldStatus:
  10868. return m.OldStatus(ctx)
  10869. case creditusage.FieldNtype:
  10870. return m.OldNtype(ctx)
  10871. case creditusage.FieldTable:
  10872. return m.OldTable(ctx)
  10873. case creditusage.FieldOrganizationID:
  10874. return m.OldOrganizationID(ctx)
  10875. case creditusage.FieldNid:
  10876. return m.OldNid(ctx)
  10877. case creditusage.FieldReason:
  10878. return m.OldReason(ctx)
  10879. case creditusage.FieldOperator:
  10880. return m.OldOperator(ctx)
  10881. }
  10882. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10883. }
  10884. // SetField sets the value of a field with the given name. It returns an error if
  10885. // the field is not defined in the schema, or if the type mismatched the field
  10886. // type.
  10887. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10888. switch name {
  10889. case creditusage.FieldCreatedAt:
  10890. v, ok := value.(time.Time)
  10891. if !ok {
  10892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10893. }
  10894. m.SetCreatedAt(v)
  10895. return nil
  10896. case creditusage.FieldUpdatedAt:
  10897. v, ok := value.(time.Time)
  10898. if !ok {
  10899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10900. }
  10901. m.SetUpdatedAt(v)
  10902. return nil
  10903. case creditusage.FieldDeletedAt:
  10904. v, ok := value.(time.Time)
  10905. if !ok {
  10906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10907. }
  10908. m.SetDeletedAt(v)
  10909. return nil
  10910. case creditusage.FieldUserID:
  10911. v, ok := value.(string)
  10912. if !ok {
  10913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10914. }
  10915. m.SetUserID(v)
  10916. return nil
  10917. case creditusage.FieldNumber:
  10918. v, ok := value.(float32)
  10919. if !ok {
  10920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10921. }
  10922. m.SetNumber(v)
  10923. return nil
  10924. case creditusage.FieldStatus:
  10925. v, ok := value.(int)
  10926. if !ok {
  10927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10928. }
  10929. m.SetStatus(v)
  10930. return nil
  10931. case creditusage.FieldNtype:
  10932. v, ok := value.(int)
  10933. if !ok {
  10934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10935. }
  10936. m.SetNtype(v)
  10937. return nil
  10938. case creditusage.FieldTable:
  10939. v, ok := value.(string)
  10940. if !ok {
  10941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10942. }
  10943. m.SetTable(v)
  10944. return nil
  10945. case creditusage.FieldOrganizationID:
  10946. v, ok := value.(uint64)
  10947. if !ok {
  10948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10949. }
  10950. m.SetOrganizationID(v)
  10951. return nil
  10952. case creditusage.FieldNid:
  10953. v, ok := value.(uint64)
  10954. if !ok {
  10955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10956. }
  10957. m.SetNid(v)
  10958. return nil
  10959. case creditusage.FieldReason:
  10960. v, ok := value.(string)
  10961. if !ok {
  10962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10963. }
  10964. m.SetReason(v)
  10965. return nil
  10966. case creditusage.FieldOperator:
  10967. v, ok := value.(string)
  10968. if !ok {
  10969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10970. }
  10971. m.SetOperator(v)
  10972. return nil
  10973. }
  10974. return fmt.Errorf("unknown CreditUsage field %s", name)
  10975. }
  10976. // AddedFields returns all numeric fields that were incremented/decremented during
  10977. // this mutation.
  10978. func (m *CreditUsageMutation) AddedFields() []string {
  10979. var fields []string
  10980. if m.addnumber != nil {
  10981. fields = append(fields, creditusage.FieldNumber)
  10982. }
  10983. if m.addstatus != nil {
  10984. fields = append(fields, creditusage.FieldStatus)
  10985. }
  10986. if m.addntype != nil {
  10987. fields = append(fields, creditusage.FieldNtype)
  10988. }
  10989. if m.addorganization_id != nil {
  10990. fields = append(fields, creditusage.FieldOrganizationID)
  10991. }
  10992. if m.addnid != nil {
  10993. fields = append(fields, creditusage.FieldNid)
  10994. }
  10995. return fields
  10996. }
  10997. // AddedField returns the numeric value that was incremented/decremented on a field
  10998. // with the given name. The second boolean return value indicates that this field
  10999. // was not set, or was not defined in the schema.
  11000. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  11001. switch name {
  11002. case creditusage.FieldNumber:
  11003. return m.AddedNumber()
  11004. case creditusage.FieldStatus:
  11005. return m.AddedStatus()
  11006. case creditusage.FieldNtype:
  11007. return m.AddedNtype()
  11008. case creditusage.FieldOrganizationID:
  11009. return m.AddedOrganizationID()
  11010. case creditusage.FieldNid:
  11011. return m.AddedNid()
  11012. }
  11013. return nil, false
  11014. }
  11015. // AddField adds the value to the field with the given name. It returns an error if
  11016. // the field is not defined in the schema, or if the type mismatched the field
  11017. // type.
  11018. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11019. switch name {
  11020. case creditusage.FieldNumber:
  11021. v, ok := value.(float32)
  11022. if !ok {
  11023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11024. }
  11025. m.AddNumber(v)
  11026. return nil
  11027. case creditusage.FieldStatus:
  11028. v, ok := value.(int)
  11029. if !ok {
  11030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11031. }
  11032. m.AddStatus(v)
  11033. return nil
  11034. case creditusage.FieldNtype:
  11035. v, ok := value.(int)
  11036. if !ok {
  11037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11038. }
  11039. m.AddNtype(v)
  11040. return nil
  11041. case creditusage.FieldOrganizationID:
  11042. v, ok := value.(int64)
  11043. if !ok {
  11044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11045. }
  11046. m.AddOrganizationID(v)
  11047. return nil
  11048. case creditusage.FieldNid:
  11049. v, ok := value.(int64)
  11050. if !ok {
  11051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11052. }
  11053. m.AddNid(v)
  11054. return nil
  11055. }
  11056. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11057. }
  11058. // ClearedFields returns all nullable fields that were cleared during this
  11059. // mutation.
  11060. func (m *CreditUsageMutation) ClearedFields() []string {
  11061. var fields []string
  11062. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11063. fields = append(fields, creditusage.FieldDeletedAt)
  11064. }
  11065. if m.FieldCleared(creditusage.FieldUserID) {
  11066. fields = append(fields, creditusage.FieldUserID)
  11067. }
  11068. if m.FieldCleared(creditusage.FieldStatus) {
  11069. fields = append(fields, creditusage.FieldStatus)
  11070. }
  11071. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11072. fields = append(fields, creditusage.FieldOrganizationID)
  11073. }
  11074. return fields
  11075. }
  11076. // FieldCleared returns a boolean indicating if a field with the given name was
  11077. // cleared in this mutation.
  11078. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11079. _, ok := m.clearedFields[name]
  11080. return ok
  11081. }
  11082. // ClearField clears the value of the field with the given name. It returns an
  11083. // error if the field is not defined in the schema.
  11084. func (m *CreditUsageMutation) ClearField(name string) error {
  11085. switch name {
  11086. case creditusage.FieldDeletedAt:
  11087. m.ClearDeletedAt()
  11088. return nil
  11089. case creditusage.FieldUserID:
  11090. m.ClearUserID()
  11091. return nil
  11092. case creditusage.FieldStatus:
  11093. m.ClearStatus()
  11094. return nil
  11095. case creditusage.FieldOrganizationID:
  11096. m.ClearOrganizationID()
  11097. return nil
  11098. }
  11099. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11100. }
  11101. // ResetField resets all changes in the mutation for the field with the given name.
  11102. // It returns an error if the field is not defined in the schema.
  11103. func (m *CreditUsageMutation) ResetField(name string) error {
  11104. switch name {
  11105. case creditusage.FieldCreatedAt:
  11106. m.ResetCreatedAt()
  11107. return nil
  11108. case creditusage.FieldUpdatedAt:
  11109. m.ResetUpdatedAt()
  11110. return nil
  11111. case creditusage.FieldDeletedAt:
  11112. m.ResetDeletedAt()
  11113. return nil
  11114. case creditusage.FieldUserID:
  11115. m.ResetUserID()
  11116. return nil
  11117. case creditusage.FieldNumber:
  11118. m.ResetNumber()
  11119. return nil
  11120. case creditusage.FieldStatus:
  11121. m.ResetStatus()
  11122. return nil
  11123. case creditusage.FieldNtype:
  11124. m.ResetNtype()
  11125. return nil
  11126. case creditusage.FieldTable:
  11127. m.ResetTable()
  11128. return nil
  11129. case creditusage.FieldOrganizationID:
  11130. m.ResetOrganizationID()
  11131. return nil
  11132. case creditusage.FieldNid:
  11133. m.ResetNid()
  11134. return nil
  11135. case creditusage.FieldReason:
  11136. m.ResetReason()
  11137. return nil
  11138. case creditusage.FieldOperator:
  11139. m.ResetOperator()
  11140. return nil
  11141. }
  11142. return fmt.Errorf("unknown CreditUsage field %s", name)
  11143. }
  11144. // AddedEdges returns all edge names that were set/added in this mutation.
  11145. func (m *CreditUsageMutation) AddedEdges() []string {
  11146. edges := make([]string, 0, 0)
  11147. return edges
  11148. }
  11149. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11150. // name in this mutation.
  11151. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11152. return nil
  11153. }
  11154. // RemovedEdges returns all edge names that were removed in this mutation.
  11155. func (m *CreditUsageMutation) RemovedEdges() []string {
  11156. edges := make([]string, 0, 0)
  11157. return edges
  11158. }
  11159. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11160. // the given name in this mutation.
  11161. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11162. return nil
  11163. }
  11164. // ClearedEdges returns all edge names that were cleared in this mutation.
  11165. func (m *CreditUsageMutation) ClearedEdges() []string {
  11166. edges := make([]string, 0, 0)
  11167. return edges
  11168. }
  11169. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11170. // was cleared in this mutation.
  11171. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11172. return false
  11173. }
  11174. // ClearEdge clears the value of the edge with the given name. It returns an error
  11175. // if that edge is not defined in the schema.
  11176. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11177. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11178. }
  11179. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11180. // It returns an error if the edge is not defined in the schema.
  11181. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11182. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11183. }
  11184. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11185. type EmployeeMutation struct {
  11186. config
  11187. op Op
  11188. typ string
  11189. id *uint64
  11190. created_at *time.Time
  11191. updated_at *time.Time
  11192. deleted_at *time.Time
  11193. title *string
  11194. avatar *string
  11195. tags *string
  11196. hire_count *int
  11197. addhire_count *int
  11198. service_count *int
  11199. addservice_count *int
  11200. achievement_count *int
  11201. addachievement_count *int
  11202. intro *string
  11203. estimate *string
  11204. skill *string
  11205. ability_type *string
  11206. scene *string
  11207. switch_in *string
  11208. video_url *string
  11209. organization_id *uint64
  11210. addorganization_id *int64
  11211. category_id *uint64
  11212. addcategory_id *int64
  11213. api_base *string
  11214. api_key *string
  11215. ai_info *string
  11216. is_vip *int
  11217. addis_vip *int
  11218. chat_url *string
  11219. clearedFields map[string]struct{}
  11220. em_work_experiences map[uint64]struct{}
  11221. removedem_work_experiences map[uint64]struct{}
  11222. clearedem_work_experiences bool
  11223. em_tutorial map[uint64]struct{}
  11224. removedem_tutorial map[uint64]struct{}
  11225. clearedem_tutorial bool
  11226. done bool
  11227. oldValue func(context.Context) (*Employee, error)
  11228. predicates []predicate.Employee
  11229. }
  11230. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11231. // employeeOption allows management of the mutation configuration using functional options.
  11232. type employeeOption func(*EmployeeMutation)
  11233. // newEmployeeMutation creates new mutation for the Employee entity.
  11234. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11235. m := &EmployeeMutation{
  11236. config: c,
  11237. op: op,
  11238. typ: TypeEmployee,
  11239. clearedFields: make(map[string]struct{}),
  11240. }
  11241. for _, opt := range opts {
  11242. opt(m)
  11243. }
  11244. return m
  11245. }
  11246. // withEmployeeID sets the ID field of the mutation.
  11247. func withEmployeeID(id uint64) employeeOption {
  11248. return func(m *EmployeeMutation) {
  11249. var (
  11250. err error
  11251. once sync.Once
  11252. value *Employee
  11253. )
  11254. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11255. once.Do(func() {
  11256. if m.done {
  11257. err = errors.New("querying old values post mutation is not allowed")
  11258. } else {
  11259. value, err = m.Client().Employee.Get(ctx, id)
  11260. }
  11261. })
  11262. return value, err
  11263. }
  11264. m.id = &id
  11265. }
  11266. }
  11267. // withEmployee sets the old Employee of the mutation.
  11268. func withEmployee(node *Employee) employeeOption {
  11269. return func(m *EmployeeMutation) {
  11270. m.oldValue = func(context.Context) (*Employee, error) {
  11271. return node, nil
  11272. }
  11273. m.id = &node.ID
  11274. }
  11275. }
  11276. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11277. // executed in a transaction (ent.Tx), a transactional client is returned.
  11278. func (m EmployeeMutation) Client() *Client {
  11279. client := &Client{config: m.config}
  11280. client.init()
  11281. return client
  11282. }
  11283. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11284. // it returns an error otherwise.
  11285. func (m EmployeeMutation) Tx() (*Tx, error) {
  11286. if _, ok := m.driver.(*txDriver); !ok {
  11287. return nil, errors.New("ent: mutation is not running in a transaction")
  11288. }
  11289. tx := &Tx{config: m.config}
  11290. tx.init()
  11291. return tx, nil
  11292. }
  11293. // SetID sets the value of the id field. Note that this
  11294. // operation is only accepted on creation of Employee entities.
  11295. func (m *EmployeeMutation) SetID(id uint64) {
  11296. m.id = &id
  11297. }
  11298. // ID returns the ID value in the mutation. Note that the ID is only available
  11299. // if it was provided to the builder or after it was returned from the database.
  11300. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11301. if m.id == nil {
  11302. return
  11303. }
  11304. return *m.id, true
  11305. }
  11306. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11307. // That means, if the mutation is applied within a transaction with an isolation level such
  11308. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11309. // or updated by the mutation.
  11310. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11311. switch {
  11312. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11313. id, exists := m.ID()
  11314. if exists {
  11315. return []uint64{id}, nil
  11316. }
  11317. fallthrough
  11318. case m.op.Is(OpUpdate | OpDelete):
  11319. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11320. default:
  11321. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11322. }
  11323. }
  11324. // SetCreatedAt sets the "created_at" field.
  11325. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11326. m.created_at = &t
  11327. }
  11328. // CreatedAt returns the value of the "created_at" field in the mutation.
  11329. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11330. v := m.created_at
  11331. if v == nil {
  11332. return
  11333. }
  11334. return *v, true
  11335. }
  11336. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11337. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11339. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11340. if !m.op.Is(OpUpdateOne) {
  11341. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11342. }
  11343. if m.id == nil || m.oldValue == nil {
  11344. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11345. }
  11346. oldValue, err := m.oldValue(ctx)
  11347. if err != nil {
  11348. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11349. }
  11350. return oldValue.CreatedAt, nil
  11351. }
  11352. // ResetCreatedAt resets all changes to the "created_at" field.
  11353. func (m *EmployeeMutation) ResetCreatedAt() {
  11354. m.created_at = nil
  11355. }
  11356. // SetUpdatedAt sets the "updated_at" field.
  11357. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11358. m.updated_at = &t
  11359. }
  11360. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11361. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11362. v := m.updated_at
  11363. if v == nil {
  11364. return
  11365. }
  11366. return *v, true
  11367. }
  11368. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11369. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11371. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11372. if !m.op.Is(OpUpdateOne) {
  11373. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11374. }
  11375. if m.id == nil || m.oldValue == nil {
  11376. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11377. }
  11378. oldValue, err := m.oldValue(ctx)
  11379. if err != nil {
  11380. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11381. }
  11382. return oldValue.UpdatedAt, nil
  11383. }
  11384. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11385. func (m *EmployeeMutation) ResetUpdatedAt() {
  11386. m.updated_at = nil
  11387. }
  11388. // SetDeletedAt sets the "deleted_at" field.
  11389. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11390. m.deleted_at = &t
  11391. }
  11392. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11393. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11394. v := m.deleted_at
  11395. if v == nil {
  11396. return
  11397. }
  11398. return *v, true
  11399. }
  11400. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11401. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11403. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11404. if !m.op.Is(OpUpdateOne) {
  11405. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11406. }
  11407. if m.id == nil || m.oldValue == nil {
  11408. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11409. }
  11410. oldValue, err := m.oldValue(ctx)
  11411. if err != nil {
  11412. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11413. }
  11414. return oldValue.DeletedAt, nil
  11415. }
  11416. // ClearDeletedAt clears the value of the "deleted_at" field.
  11417. func (m *EmployeeMutation) ClearDeletedAt() {
  11418. m.deleted_at = nil
  11419. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11420. }
  11421. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11422. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11423. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11424. return ok
  11425. }
  11426. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11427. func (m *EmployeeMutation) ResetDeletedAt() {
  11428. m.deleted_at = nil
  11429. delete(m.clearedFields, employee.FieldDeletedAt)
  11430. }
  11431. // SetTitle sets the "title" field.
  11432. func (m *EmployeeMutation) SetTitle(s string) {
  11433. m.title = &s
  11434. }
  11435. // Title returns the value of the "title" field in the mutation.
  11436. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11437. v := m.title
  11438. if v == nil {
  11439. return
  11440. }
  11441. return *v, true
  11442. }
  11443. // OldTitle returns the old "title" field's value of the Employee entity.
  11444. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11446. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11447. if !m.op.Is(OpUpdateOne) {
  11448. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11449. }
  11450. if m.id == nil || m.oldValue == nil {
  11451. return v, errors.New("OldTitle requires an ID field in the mutation")
  11452. }
  11453. oldValue, err := m.oldValue(ctx)
  11454. if err != nil {
  11455. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11456. }
  11457. return oldValue.Title, nil
  11458. }
  11459. // ResetTitle resets all changes to the "title" field.
  11460. func (m *EmployeeMutation) ResetTitle() {
  11461. m.title = nil
  11462. }
  11463. // SetAvatar sets the "avatar" field.
  11464. func (m *EmployeeMutation) SetAvatar(s string) {
  11465. m.avatar = &s
  11466. }
  11467. // Avatar returns the value of the "avatar" field in the mutation.
  11468. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11469. v := m.avatar
  11470. if v == nil {
  11471. return
  11472. }
  11473. return *v, true
  11474. }
  11475. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11476. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11478. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11479. if !m.op.Is(OpUpdateOne) {
  11480. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11481. }
  11482. if m.id == nil || m.oldValue == nil {
  11483. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11484. }
  11485. oldValue, err := m.oldValue(ctx)
  11486. if err != nil {
  11487. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11488. }
  11489. return oldValue.Avatar, nil
  11490. }
  11491. // ResetAvatar resets all changes to the "avatar" field.
  11492. func (m *EmployeeMutation) ResetAvatar() {
  11493. m.avatar = nil
  11494. }
  11495. // SetTags sets the "tags" field.
  11496. func (m *EmployeeMutation) SetTags(s string) {
  11497. m.tags = &s
  11498. }
  11499. // Tags returns the value of the "tags" field in the mutation.
  11500. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11501. v := m.tags
  11502. if v == nil {
  11503. return
  11504. }
  11505. return *v, true
  11506. }
  11507. // OldTags returns the old "tags" field's value of the Employee entity.
  11508. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11510. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11511. if !m.op.Is(OpUpdateOne) {
  11512. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11513. }
  11514. if m.id == nil || m.oldValue == nil {
  11515. return v, errors.New("OldTags requires an ID field in the mutation")
  11516. }
  11517. oldValue, err := m.oldValue(ctx)
  11518. if err != nil {
  11519. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11520. }
  11521. return oldValue.Tags, nil
  11522. }
  11523. // ResetTags resets all changes to the "tags" field.
  11524. func (m *EmployeeMutation) ResetTags() {
  11525. m.tags = nil
  11526. }
  11527. // SetHireCount sets the "hire_count" field.
  11528. func (m *EmployeeMutation) SetHireCount(i int) {
  11529. m.hire_count = &i
  11530. m.addhire_count = nil
  11531. }
  11532. // HireCount returns the value of the "hire_count" field in the mutation.
  11533. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11534. v := m.hire_count
  11535. if v == nil {
  11536. return
  11537. }
  11538. return *v, true
  11539. }
  11540. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11541. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11543. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11544. if !m.op.Is(OpUpdateOne) {
  11545. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11546. }
  11547. if m.id == nil || m.oldValue == nil {
  11548. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11549. }
  11550. oldValue, err := m.oldValue(ctx)
  11551. if err != nil {
  11552. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11553. }
  11554. return oldValue.HireCount, nil
  11555. }
  11556. // AddHireCount adds i to the "hire_count" field.
  11557. func (m *EmployeeMutation) AddHireCount(i int) {
  11558. if m.addhire_count != nil {
  11559. *m.addhire_count += i
  11560. } else {
  11561. m.addhire_count = &i
  11562. }
  11563. }
  11564. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11565. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11566. v := m.addhire_count
  11567. if v == nil {
  11568. return
  11569. }
  11570. return *v, true
  11571. }
  11572. // ResetHireCount resets all changes to the "hire_count" field.
  11573. func (m *EmployeeMutation) ResetHireCount() {
  11574. m.hire_count = nil
  11575. m.addhire_count = nil
  11576. }
  11577. // SetServiceCount sets the "service_count" field.
  11578. func (m *EmployeeMutation) SetServiceCount(i int) {
  11579. m.service_count = &i
  11580. m.addservice_count = nil
  11581. }
  11582. // ServiceCount returns the value of the "service_count" field in the mutation.
  11583. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11584. v := m.service_count
  11585. if v == nil {
  11586. return
  11587. }
  11588. return *v, true
  11589. }
  11590. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11591. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11593. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11594. if !m.op.Is(OpUpdateOne) {
  11595. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11596. }
  11597. if m.id == nil || m.oldValue == nil {
  11598. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11599. }
  11600. oldValue, err := m.oldValue(ctx)
  11601. if err != nil {
  11602. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11603. }
  11604. return oldValue.ServiceCount, nil
  11605. }
  11606. // AddServiceCount adds i to the "service_count" field.
  11607. func (m *EmployeeMutation) AddServiceCount(i int) {
  11608. if m.addservice_count != nil {
  11609. *m.addservice_count += i
  11610. } else {
  11611. m.addservice_count = &i
  11612. }
  11613. }
  11614. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11615. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11616. v := m.addservice_count
  11617. if v == nil {
  11618. return
  11619. }
  11620. return *v, true
  11621. }
  11622. // ResetServiceCount resets all changes to the "service_count" field.
  11623. func (m *EmployeeMutation) ResetServiceCount() {
  11624. m.service_count = nil
  11625. m.addservice_count = nil
  11626. }
  11627. // SetAchievementCount sets the "achievement_count" field.
  11628. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11629. m.achievement_count = &i
  11630. m.addachievement_count = nil
  11631. }
  11632. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11633. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11634. v := m.achievement_count
  11635. if v == nil {
  11636. return
  11637. }
  11638. return *v, true
  11639. }
  11640. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11641. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11643. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11644. if !m.op.Is(OpUpdateOne) {
  11645. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11646. }
  11647. if m.id == nil || m.oldValue == nil {
  11648. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11649. }
  11650. oldValue, err := m.oldValue(ctx)
  11651. if err != nil {
  11652. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11653. }
  11654. return oldValue.AchievementCount, nil
  11655. }
  11656. // AddAchievementCount adds i to the "achievement_count" field.
  11657. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11658. if m.addachievement_count != nil {
  11659. *m.addachievement_count += i
  11660. } else {
  11661. m.addachievement_count = &i
  11662. }
  11663. }
  11664. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11665. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11666. v := m.addachievement_count
  11667. if v == nil {
  11668. return
  11669. }
  11670. return *v, true
  11671. }
  11672. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11673. func (m *EmployeeMutation) ResetAchievementCount() {
  11674. m.achievement_count = nil
  11675. m.addachievement_count = nil
  11676. }
  11677. // SetIntro sets the "intro" field.
  11678. func (m *EmployeeMutation) SetIntro(s string) {
  11679. m.intro = &s
  11680. }
  11681. // Intro returns the value of the "intro" field in the mutation.
  11682. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11683. v := m.intro
  11684. if v == nil {
  11685. return
  11686. }
  11687. return *v, true
  11688. }
  11689. // OldIntro returns the old "intro" field's value of the Employee entity.
  11690. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11692. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11693. if !m.op.Is(OpUpdateOne) {
  11694. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11695. }
  11696. if m.id == nil || m.oldValue == nil {
  11697. return v, errors.New("OldIntro requires an ID field in the mutation")
  11698. }
  11699. oldValue, err := m.oldValue(ctx)
  11700. if err != nil {
  11701. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11702. }
  11703. return oldValue.Intro, nil
  11704. }
  11705. // ResetIntro resets all changes to the "intro" field.
  11706. func (m *EmployeeMutation) ResetIntro() {
  11707. m.intro = nil
  11708. }
  11709. // SetEstimate sets the "estimate" field.
  11710. func (m *EmployeeMutation) SetEstimate(s string) {
  11711. m.estimate = &s
  11712. }
  11713. // Estimate returns the value of the "estimate" field in the mutation.
  11714. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11715. v := m.estimate
  11716. if v == nil {
  11717. return
  11718. }
  11719. return *v, true
  11720. }
  11721. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11722. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11724. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11725. if !m.op.Is(OpUpdateOne) {
  11726. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11727. }
  11728. if m.id == nil || m.oldValue == nil {
  11729. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11730. }
  11731. oldValue, err := m.oldValue(ctx)
  11732. if err != nil {
  11733. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11734. }
  11735. return oldValue.Estimate, nil
  11736. }
  11737. // ResetEstimate resets all changes to the "estimate" field.
  11738. func (m *EmployeeMutation) ResetEstimate() {
  11739. m.estimate = nil
  11740. }
  11741. // SetSkill sets the "skill" field.
  11742. func (m *EmployeeMutation) SetSkill(s string) {
  11743. m.skill = &s
  11744. }
  11745. // Skill returns the value of the "skill" field in the mutation.
  11746. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11747. v := m.skill
  11748. if v == nil {
  11749. return
  11750. }
  11751. return *v, true
  11752. }
  11753. // OldSkill returns the old "skill" field's value of the Employee entity.
  11754. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11756. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11757. if !m.op.Is(OpUpdateOne) {
  11758. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11759. }
  11760. if m.id == nil || m.oldValue == nil {
  11761. return v, errors.New("OldSkill requires an ID field in the mutation")
  11762. }
  11763. oldValue, err := m.oldValue(ctx)
  11764. if err != nil {
  11765. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11766. }
  11767. return oldValue.Skill, nil
  11768. }
  11769. // ResetSkill resets all changes to the "skill" field.
  11770. func (m *EmployeeMutation) ResetSkill() {
  11771. m.skill = nil
  11772. }
  11773. // SetAbilityType sets the "ability_type" field.
  11774. func (m *EmployeeMutation) SetAbilityType(s string) {
  11775. m.ability_type = &s
  11776. }
  11777. // AbilityType returns the value of the "ability_type" field in the mutation.
  11778. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11779. v := m.ability_type
  11780. if v == nil {
  11781. return
  11782. }
  11783. return *v, true
  11784. }
  11785. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11786. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11788. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11789. if !m.op.Is(OpUpdateOne) {
  11790. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11791. }
  11792. if m.id == nil || m.oldValue == nil {
  11793. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11794. }
  11795. oldValue, err := m.oldValue(ctx)
  11796. if err != nil {
  11797. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11798. }
  11799. return oldValue.AbilityType, nil
  11800. }
  11801. // ResetAbilityType resets all changes to the "ability_type" field.
  11802. func (m *EmployeeMutation) ResetAbilityType() {
  11803. m.ability_type = nil
  11804. }
  11805. // SetScene sets the "scene" field.
  11806. func (m *EmployeeMutation) SetScene(s string) {
  11807. m.scene = &s
  11808. }
  11809. // Scene returns the value of the "scene" field in the mutation.
  11810. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11811. v := m.scene
  11812. if v == nil {
  11813. return
  11814. }
  11815. return *v, true
  11816. }
  11817. // OldScene returns the old "scene" field's value of the Employee entity.
  11818. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11820. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11821. if !m.op.Is(OpUpdateOne) {
  11822. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11823. }
  11824. if m.id == nil || m.oldValue == nil {
  11825. return v, errors.New("OldScene requires an ID field in the mutation")
  11826. }
  11827. oldValue, err := m.oldValue(ctx)
  11828. if err != nil {
  11829. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11830. }
  11831. return oldValue.Scene, nil
  11832. }
  11833. // ResetScene resets all changes to the "scene" field.
  11834. func (m *EmployeeMutation) ResetScene() {
  11835. m.scene = nil
  11836. }
  11837. // SetSwitchIn sets the "switch_in" field.
  11838. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11839. m.switch_in = &s
  11840. }
  11841. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11842. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11843. v := m.switch_in
  11844. if v == nil {
  11845. return
  11846. }
  11847. return *v, true
  11848. }
  11849. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11850. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11852. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11853. if !m.op.Is(OpUpdateOne) {
  11854. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11855. }
  11856. if m.id == nil || m.oldValue == nil {
  11857. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11858. }
  11859. oldValue, err := m.oldValue(ctx)
  11860. if err != nil {
  11861. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11862. }
  11863. return oldValue.SwitchIn, nil
  11864. }
  11865. // ResetSwitchIn resets all changes to the "switch_in" field.
  11866. func (m *EmployeeMutation) ResetSwitchIn() {
  11867. m.switch_in = nil
  11868. }
  11869. // SetVideoURL sets the "video_url" field.
  11870. func (m *EmployeeMutation) SetVideoURL(s string) {
  11871. m.video_url = &s
  11872. }
  11873. // VideoURL returns the value of the "video_url" field in the mutation.
  11874. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11875. v := m.video_url
  11876. if v == nil {
  11877. return
  11878. }
  11879. return *v, true
  11880. }
  11881. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11882. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11884. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11885. if !m.op.Is(OpUpdateOne) {
  11886. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11887. }
  11888. if m.id == nil || m.oldValue == nil {
  11889. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11890. }
  11891. oldValue, err := m.oldValue(ctx)
  11892. if err != nil {
  11893. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11894. }
  11895. return oldValue.VideoURL, nil
  11896. }
  11897. // ResetVideoURL resets all changes to the "video_url" field.
  11898. func (m *EmployeeMutation) ResetVideoURL() {
  11899. m.video_url = nil
  11900. }
  11901. // SetOrganizationID sets the "organization_id" field.
  11902. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11903. m.organization_id = &u
  11904. m.addorganization_id = nil
  11905. }
  11906. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11907. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11908. v := m.organization_id
  11909. if v == nil {
  11910. return
  11911. }
  11912. return *v, true
  11913. }
  11914. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11915. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11917. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11918. if !m.op.Is(OpUpdateOne) {
  11919. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11920. }
  11921. if m.id == nil || m.oldValue == nil {
  11922. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11923. }
  11924. oldValue, err := m.oldValue(ctx)
  11925. if err != nil {
  11926. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11927. }
  11928. return oldValue.OrganizationID, nil
  11929. }
  11930. // AddOrganizationID adds u to the "organization_id" field.
  11931. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11932. if m.addorganization_id != nil {
  11933. *m.addorganization_id += u
  11934. } else {
  11935. m.addorganization_id = &u
  11936. }
  11937. }
  11938. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11939. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11940. v := m.addorganization_id
  11941. if v == nil {
  11942. return
  11943. }
  11944. return *v, true
  11945. }
  11946. // ResetOrganizationID resets all changes to the "organization_id" field.
  11947. func (m *EmployeeMutation) ResetOrganizationID() {
  11948. m.organization_id = nil
  11949. m.addorganization_id = nil
  11950. }
  11951. // SetCategoryID sets the "category_id" field.
  11952. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11953. m.category_id = &u
  11954. m.addcategory_id = nil
  11955. }
  11956. // CategoryID returns the value of the "category_id" field in the mutation.
  11957. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11958. v := m.category_id
  11959. if v == nil {
  11960. return
  11961. }
  11962. return *v, true
  11963. }
  11964. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11965. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11967. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11968. if !m.op.Is(OpUpdateOne) {
  11969. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11970. }
  11971. if m.id == nil || m.oldValue == nil {
  11972. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11973. }
  11974. oldValue, err := m.oldValue(ctx)
  11975. if err != nil {
  11976. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11977. }
  11978. return oldValue.CategoryID, nil
  11979. }
  11980. // AddCategoryID adds u to the "category_id" field.
  11981. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11982. if m.addcategory_id != nil {
  11983. *m.addcategory_id += u
  11984. } else {
  11985. m.addcategory_id = &u
  11986. }
  11987. }
  11988. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11989. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11990. v := m.addcategory_id
  11991. if v == nil {
  11992. return
  11993. }
  11994. return *v, true
  11995. }
  11996. // ResetCategoryID resets all changes to the "category_id" field.
  11997. func (m *EmployeeMutation) ResetCategoryID() {
  11998. m.category_id = nil
  11999. m.addcategory_id = nil
  12000. }
  12001. // SetAPIBase sets the "api_base" field.
  12002. func (m *EmployeeMutation) SetAPIBase(s string) {
  12003. m.api_base = &s
  12004. }
  12005. // APIBase returns the value of the "api_base" field in the mutation.
  12006. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  12007. v := m.api_base
  12008. if v == nil {
  12009. return
  12010. }
  12011. return *v, true
  12012. }
  12013. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  12014. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12016. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12017. if !m.op.Is(OpUpdateOne) {
  12018. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12019. }
  12020. if m.id == nil || m.oldValue == nil {
  12021. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  12022. }
  12023. oldValue, err := m.oldValue(ctx)
  12024. if err != nil {
  12025. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  12026. }
  12027. return oldValue.APIBase, nil
  12028. }
  12029. // ResetAPIBase resets all changes to the "api_base" field.
  12030. func (m *EmployeeMutation) ResetAPIBase() {
  12031. m.api_base = nil
  12032. }
  12033. // SetAPIKey sets the "api_key" field.
  12034. func (m *EmployeeMutation) SetAPIKey(s string) {
  12035. m.api_key = &s
  12036. }
  12037. // APIKey returns the value of the "api_key" field in the mutation.
  12038. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12039. v := m.api_key
  12040. if v == nil {
  12041. return
  12042. }
  12043. return *v, true
  12044. }
  12045. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12046. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12048. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12049. if !m.op.Is(OpUpdateOne) {
  12050. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12051. }
  12052. if m.id == nil || m.oldValue == nil {
  12053. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12054. }
  12055. oldValue, err := m.oldValue(ctx)
  12056. if err != nil {
  12057. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12058. }
  12059. return oldValue.APIKey, nil
  12060. }
  12061. // ResetAPIKey resets all changes to the "api_key" field.
  12062. func (m *EmployeeMutation) ResetAPIKey() {
  12063. m.api_key = nil
  12064. }
  12065. // SetAiInfo sets the "ai_info" field.
  12066. func (m *EmployeeMutation) SetAiInfo(s string) {
  12067. m.ai_info = &s
  12068. }
  12069. // AiInfo returns the value of the "ai_info" field in the mutation.
  12070. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12071. v := m.ai_info
  12072. if v == nil {
  12073. return
  12074. }
  12075. return *v, true
  12076. }
  12077. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12078. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12080. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12081. if !m.op.Is(OpUpdateOne) {
  12082. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12083. }
  12084. if m.id == nil || m.oldValue == nil {
  12085. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12086. }
  12087. oldValue, err := m.oldValue(ctx)
  12088. if err != nil {
  12089. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12090. }
  12091. return oldValue.AiInfo, nil
  12092. }
  12093. // ClearAiInfo clears the value of the "ai_info" field.
  12094. func (m *EmployeeMutation) ClearAiInfo() {
  12095. m.ai_info = nil
  12096. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12097. }
  12098. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12099. func (m *EmployeeMutation) AiInfoCleared() bool {
  12100. _, ok := m.clearedFields[employee.FieldAiInfo]
  12101. return ok
  12102. }
  12103. // ResetAiInfo resets all changes to the "ai_info" field.
  12104. func (m *EmployeeMutation) ResetAiInfo() {
  12105. m.ai_info = nil
  12106. delete(m.clearedFields, employee.FieldAiInfo)
  12107. }
  12108. // SetIsVip sets the "is_vip" field.
  12109. func (m *EmployeeMutation) SetIsVip(i int) {
  12110. m.is_vip = &i
  12111. m.addis_vip = nil
  12112. }
  12113. // IsVip returns the value of the "is_vip" field in the mutation.
  12114. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12115. v := m.is_vip
  12116. if v == nil {
  12117. return
  12118. }
  12119. return *v, true
  12120. }
  12121. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12122. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12124. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12125. if !m.op.Is(OpUpdateOne) {
  12126. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12127. }
  12128. if m.id == nil || m.oldValue == nil {
  12129. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12130. }
  12131. oldValue, err := m.oldValue(ctx)
  12132. if err != nil {
  12133. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12134. }
  12135. return oldValue.IsVip, nil
  12136. }
  12137. // AddIsVip adds i to the "is_vip" field.
  12138. func (m *EmployeeMutation) AddIsVip(i int) {
  12139. if m.addis_vip != nil {
  12140. *m.addis_vip += i
  12141. } else {
  12142. m.addis_vip = &i
  12143. }
  12144. }
  12145. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12146. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12147. v := m.addis_vip
  12148. if v == nil {
  12149. return
  12150. }
  12151. return *v, true
  12152. }
  12153. // ResetIsVip resets all changes to the "is_vip" field.
  12154. func (m *EmployeeMutation) ResetIsVip() {
  12155. m.is_vip = nil
  12156. m.addis_vip = nil
  12157. }
  12158. // SetChatURL sets the "chat_url" field.
  12159. func (m *EmployeeMutation) SetChatURL(s string) {
  12160. m.chat_url = &s
  12161. }
  12162. // ChatURL returns the value of the "chat_url" field in the mutation.
  12163. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12164. v := m.chat_url
  12165. if v == nil {
  12166. return
  12167. }
  12168. return *v, true
  12169. }
  12170. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12171. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12173. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12174. if !m.op.Is(OpUpdateOne) {
  12175. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12176. }
  12177. if m.id == nil || m.oldValue == nil {
  12178. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12179. }
  12180. oldValue, err := m.oldValue(ctx)
  12181. if err != nil {
  12182. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12183. }
  12184. return oldValue.ChatURL, nil
  12185. }
  12186. // ResetChatURL resets all changes to the "chat_url" field.
  12187. func (m *EmployeeMutation) ResetChatURL() {
  12188. m.chat_url = nil
  12189. }
  12190. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12191. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12192. if m.em_work_experiences == nil {
  12193. m.em_work_experiences = make(map[uint64]struct{})
  12194. }
  12195. for i := range ids {
  12196. m.em_work_experiences[ids[i]] = struct{}{}
  12197. }
  12198. }
  12199. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12200. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12201. m.clearedem_work_experiences = true
  12202. }
  12203. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12204. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12205. return m.clearedem_work_experiences
  12206. }
  12207. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12208. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12209. if m.removedem_work_experiences == nil {
  12210. m.removedem_work_experiences = make(map[uint64]struct{})
  12211. }
  12212. for i := range ids {
  12213. delete(m.em_work_experiences, ids[i])
  12214. m.removedem_work_experiences[ids[i]] = struct{}{}
  12215. }
  12216. }
  12217. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12218. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12219. for id := range m.removedem_work_experiences {
  12220. ids = append(ids, id)
  12221. }
  12222. return
  12223. }
  12224. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12225. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12226. for id := range m.em_work_experiences {
  12227. ids = append(ids, id)
  12228. }
  12229. return
  12230. }
  12231. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12232. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12233. m.em_work_experiences = nil
  12234. m.clearedem_work_experiences = false
  12235. m.removedem_work_experiences = nil
  12236. }
  12237. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12238. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12239. if m.em_tutorial == nil {
  12240. m.em_tutorial = make(map[uint64]struct{})
  12241. }
  12242. for i := range ids {
  12243. m.em_tutorial[ids[i]] = struct{}{}
  12244. }
  12245. }
  12246. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12247. func (m *EmployeeMutation) ClearEmTutorial() {
  12248. m.clearedem_tutorial = true
  12249. }
  12250. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12251. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12252. return m.clearedem_tutorial
  12253. }
  12254. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12255. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12256. if m.removedem_tutorial == nil {
  12257. m.removedem_tutorial = make(map[uint64]struct{})
  12258. }
  12259. for i := range ids {
  12260. delete(m.em_tutorial, ids[i])
  12261. m.removedem_tutorial[ids[i]] = struct{}{}
  12262. }
  12263. }
  12264. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12265. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12266. for id := range m.removedem_tutorial {
  12267. ids = append(ids, id)
  12268. }
  12269. return
  12270. }
  12271. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12272. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12273. for id := range m.em_tutorial {
  12274. ids = append(ids, id)
  12275. }
  12276. return
  12277. }
  12278. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12279. func (m *EmployeeMutation) ResetEmTutorial() {
  12280. m.em_tutorial = nil
  12281. m.clearedem_tutorial = false
  12282. m.removedem_tutorial = nil
  12283. }
  12284. // Where appends a list predicates to the EmployeeMutation builder.
  12285. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12286. m.predicates = append(m.predicates, ps...)
  12287. }
  12288. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12289. // users can use type-assertion to append predicates that do not depend on any generated package.
  12290. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12291. p := make([]predicate.Employee, len(ps))
  12292. for i := range ps {
  12293. p[i] = ps[i]
  12294. }
  12295. m.Where(p...)
  12296. }
  12297. // Op returns the operation name.
  12298. func (m *EmployeeMutation) Op() Op {
  12299. return m.op
  12300. }
  12301. // SetOp allows setting the mutation operation.
  12302. func (m *EmployeeMutation) SetOp(op Op) {
  12303. m.op = op
  12304. }
  12305. // Type returns the node type of this mutation (Employee).
  12306. func (m *EmployeeMutation) Type() string {
  12307. return m.typ
  12308. }
  12309. // Fields returns all fields that were changed during this mutation. Note that in
  12310. // order to get all numeric fields that were incremented/decremented, call
  12311. // AddedFields().
  12312. func (m *EmployeeMutation) Fields() []string {
  12313. fields := make([]string, 0, 23)
  12314. if m.created_at != nil {
  12315. fields = append(fields, employee.FieldCreatedAt)
  12316. }
  12317. if m.updated_at != nil {
  12318. fields = append(fields, employee.FieldUpdatedAt)
  12319. }
  12320. if m.deleted_at != nil {
  12321. fields = append(fields, employee.FieldDeletedAt)
  12322. }
  12323. if m.title != nil {
  12324. fields = append(fields, employee.FieldTitle)
  12325. }
  12326. if m.avatar != nil {
  12327. fields = append(fields, employee.FieldAvatar)
  12328. }
  12329. if m.tags != nil {
  12330. fields = append(fields, employee.FieldTags)
  12331. }
  12332. if m.hire_count != nil {
  12333. fields = append(fields, employee.FieldHireCount)
  12334. }
  12335. if m.service_count != nil {
  12336. fields = append(fields, employee.FieldServiceCount)
  12337. }
  12338. if m.achievement_count != nil {
  12339. fields = append(fields, employee.FieldAchievementCount)
  12340. }
  12341. if m.intro != nil {
  12342. fields = append(fields, employee.FieldIntro)
  12343. }
  12344. if m.estimate != nil {
  12345. fields = append(fields, employee.FieldEstimate)
  12346. }
  12347. if m.skill != nil {
  12348. fields = append(fields, employee.FieldSkill)
  12349. }
  12350. if m.ability_type != nil {
  12351. fields = append(fields, employee.FieldAbilityType)
  12352. }
  12353. if m.scene != nil {
  12354. fields = append(fields, employee.FieldScene)
  12355. }
  12356. if m.switch_in != nil {
  12357. fields = append(fields, employee.FieldSwitchIn)
  12358. }
  12359. if m.video_url != nil {
  12360. fields = append(fields, employee.FieldVideoURL)
  12361. }
  12362. if m.organization_id != nil {
  12363. fields = append(fields, employee.FieldOrganizationID)
  12364. }
  12365. if m.category_id != nil {
  12366. fields = append(fields, employee.FieldCategoryID)
  12367. }
  12368. if m.api_base != nil {
  12369. fields = append(fields, employee.FieldAPIBase)
  12370. }
  12371. if m.api_key != nil {
  12372. fields = append(fields, employee.FieldAPIKey)
  12373. }
  12374. if m.ai_info != nil {
  12375. fields = append(fields, employee.FieldAiInfo)
  12376. }
  12377. if m.is_vip != nil {
  12378. fields = append(fields, employee.FieldIsVip)
  12379. }
  12380. if m.chat_url != nil {
  12381. fields = append(fields, employee.FieldChatURL)
  12382. }
  12383. return fields
  12384. }
  12385. // Field returns the value of a field with the given name. The second boolean
  12386. // return value indicates that this field was not set, or was not defined in the
  12387. // schema.
  12388. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12389. switch name {
  12390. case employee.FieldCreatedAt:
  12391. return m.CreatedAt()
  12392. case employee.FieldUpdatedAt:
  12393. return m.UpdatedAt()
  12394. case employee.FieldDeletedAt:
  12395. return m.DeletedAt()
  12396. case employee.FieldTitle:
  12397. return m.Title()
  12398. case employee.FieldAvatar:
  12399. return m.Avatar()
  12400. case employee.FieldTags:
  12401. return m.Tags()
  12402. case employee.FieldHireCount:
  12403. return m.HireCount()
  12404. case employee.FieldServiceCount:
  12405. return m.ServiceCount()
  12406. case employee.FieldAchievementCount:
  12407. return m.AchievementCount()
  12408. case employee.FieldIntro:
  12409. return m.Intro()
  12410. case employee.FieldEstimate:
  12411. return m.Estimate()
  12412. case employee.FieldSkill:
  12413. return m.Skill()
  12414. case employee.FieldAbilityType:
  12415. return m.AbilityType()
  12416. case employee.FieldScene:
  12417. return m.Scene()
  12418. case employee.FieldSwitchIn:
  12419. return m.SwitchIn()
  12420. case employee.FieldVideoURL:
  12421. return m.VideoURL()
  12422. case employee.FieldOrganizationID:
  12423. return m.OrganizationID()
  12424. case employee.FieldCategoryID:
  12425. return m.CategoryID()
  12426. case employee.FieldAPIBase:
  12427. return m.APIBase()
  12428. case employee.FieldAPIKey:
  12429. return m.APIKey()
  12430. case employee.FieldAiInfo:
  12431. return m.AiInfo()
  12432. case employee.FieldIsVip:
  12433. return m.IsVip()
  12434. case employee.FieldChatURL:
  12435. return m.ChatURL()
  12436. }
  12437. return nil, false
  12438. }
  12439. // OldField returns the old value of the field from the database. An error is
  12440. // returned if the mutation operation is not UpdateOne, or the query to the
  12441. // database failed.
  12442. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12443. switch name {
  12444. case employee.FieldCreatedAt:
  12445. return m.OldCreatedAt(ctx)
  12446. case employee.FieldUpdatedAt:
  12447. return m.OldUpdatedAt(ctx)
  12448. case employee.FieldDeletedAt:
  12449. return m.OldDeletedAt(ctx)
  12450. case employee.FieldTitle:
  12451. return m.OldTitle(ctx)
  12452. case employee.FieldAvatar:
  12453. return m.OldAvatar(ctx)
  12454. case employee.FieldTags:
  12455. return m.OldTags(ctx)
  12456. case employee.FieldHireCount:
  12457. return m.OldHireCount(ctx)
  12458. case employee.FieldServiceCount:
  12459. return m.OldServiceCount(ctx)
  12460. case employee.FieldAchievementCount:
  12461. return m.OldAchievementCount(ctx)
  12462. case employee.FieldIntro:
  12463. return m.OldIntro(ctx)
  12464. case employee.FieldEstimate:
  12465. return m.OldEstimate(ctx)
  12466. case employee.FieldSkill:
  12467. return m.OldSkill(ctx)
  12468. case employee.FieldAbilityType:
  12469. return m.OldAbilityType(ctx)
  12470. case employee.FieldScene:
  12471. return m.OldScene(ctx)
  12472. case employee.FieldSwitchIn:
  12473. return m.OldSwitchIn(ctx)
  12474. case employee.FieldVideoURL:
  12475. return m.OldVideoURL(ctx)
  12476. case employee.FieldOrganizationID:
  12477. return m.OldOrganizationID(ctx)
  12478. case employee.FieldCategoryID:
  12479. return m.OldCategoryID(ctx)
  12480. case employee.FieldAPIBase:
  12481. return m.OldAPIBase(ctx)
  12482. case employee.FieldAPIKey:
  12483. return m.OldAPIKey(ctx)
  12484. case employee.FieldAiInfo:
  12485. return m.OldAiInfo(ctx)
  12486. case employee.FieldIsVip:
  12487. return m.OldIsVip(ctx)
  12488. case employee.FieldChatURL:
  12489. return m.OldChatURL(ctx)
  12490. }
  12491. return nil, fmt.Errorf("unknown Employee field %s", name)
  12492. }
  12493. // SetField sets the value of a field with the given name. It returns an error if
  12494. // the field is not defined in the schema, or if the type mismatched the field
  12495. // type.
  12496. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12497. switch name {
  12498. case employee.FieldCreatedAt:
  12499. v, ok := value.(time.Time)
  12500. if !ok {
  12501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12502. }
  12503. m.SetCreatedAt(v)
  12504. return nil
  12505. case employee.FieldUpdatedAt:
  12506. v, ok := value.(time.Time)
  12507. if !ok {
  12508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12509. }
  12510. m.SetUpdatedAt(v)
  12511. return nil
  12512. case employee.FieldDeletedAt:
  12513. v, ok := value.(time.Time)
  12514. if !ok {
  12515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12516. }
  12517. m.SetDeletedAt(v)
  12518. return nil
  12519. case employee.FieldTitle:
  12520. v, ok := value.(string)
  12521. if !ok {
  12522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12523. }
  12524. m.SetTitle(v)
  12525. return nil
  12526. case employee.FieldAvatar:
  12527. v, ok := value.(string)
  12528. if !ok {
  12529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12530. }
  12531. m.SetAvatar(v)
  12532. return nil
  12533. case employee.FieldTags:
  12534. v, ok := value.(string)
  12535. if !ok {
  12536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12537. }
  12538. m.SetTags(v)
  12539. return nil
  12540. case employee.FieldHireCount:
  12541. v, ok := value.(int)
  12542. if !ok {
  12543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12544. }
  12545. m.SetHireCount(v)
  12546. return nil
  12547. case employee.FieldServiceCount:
  12548. v, ok := value.(int)
  12549. if !ok {
  12550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12551. }
  12552. m.SetServiceCount(v)
  12553. return nil
  12554. case employee.FieldAchievementCount:
  12555. v, ok := value.(int)
  12556. if !ok {
  12557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12558. }
  12559. m.SetAchievementCount(v)
  12560. return nil
  12561. case employee.FieldIntro:
  12562. v, ok := value.(string)
  12563. if !ok {
  12564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12565. }
  12566. m.SetIntro(v)
  12567. return nil
  12568. case employee.FieldEstimate:
  12569. v, ok := value.(string)
  12570. if !ok {
  12571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12572. }
  12573. m.SetEstimate(v)
  12574. return nil
  12575. case employee.FieldSkill:
  12576. v, ok := value.(string)
  12577. if !ok {
  12578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12579. }
  12580. m.SetSkill(v)
  12581. return nil
  12582. case employee.FieldAbilityType:
  12583. v, ok := value.(string)
  12584. if !ok {
  12585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12586. }
  12587. m.SetAbilityType(v)
  12588. return nil
  12589. case employee.FieldScene:
  12590. v, ok := value.(string)
  12591. if !ok {
  12592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12593. }
  12594. m.SetScene(v)
  12595. return nil
  12596. case employee.FieldSwitchIn:
  12597. v, ok := value.(string)
  12598. if !ok {
  12599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12600. }
  12601. m.SetSwitchIn(v)
  12602. return nil
  12603. case employee.FieldVideoURL:
  12604. v, ok := value.(string)
  12605. if !ok {
  12606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12607. }
  12608. m.SetVideoURL(v)
  12609. return nil
  12610. case employee.FieldOrganizationID:
  12611. v, ok := value.(uint64)
  12612. if !ok {
  12613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12614. }
  12615. m.SetOrganizationID(v)
  12616. return nil
  12617. case employee.FieldCategoryID:
  12618. v, ok := value.(uint64)
  12619. if !ok {
  12620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12621. }
  12622. m.SetCategoryID(v)
  12623. return nil
  12624. case employee.FieldAPIBase:
  12625. v, ok := value.(string)
  12626. if !ok {
  12627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12628. }
  12629. m.SetAPIBase(v)
  12630. return nil
  12631. case employee.FieldAPIKey:
  12632. v, ok := value.(string)
  12633. if !ok {
  12634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12635. }
  12636. m.SetAPIKey(v)
  12637. return nil
  12638. case employee.FieldAiInfo:
  12639. v, ok := value.(string)
  12640. if !ok {
  12641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12642. }
  12643. m.SetAiInfo(v)
  12644. return nil
  12645. case employee.FieldIsVip:
  12646. v, ok := value.(int)
  12647. if !ok {
  12648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12649. }
  12650. m.SetIsVip(v)
  12651. return nil
  12652. case employee.FieldChatURL:
  12653. v, ok := value.(string)
  12654. if !ok {
  12655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12656. }
  12657. m.SetChatURL(v)
  12658. return nil
  12659. }
  12660. return fmt.Errorf("unknown Employee field %s", name)
  12661. }
  12662. // AddedFields returns all numeric fields that were incremented/decremented during
  12663. // this mutation.
  12664. func (m *EmployeeMutation) AddedFields() []string {
  12665. var fields []string
  12666. if m.addhire_count != nil {
  12667. fields = append(fields, employee.FieldHireCount)
  12668. }
  12669. if m.addservice_count != nil {
  12670. fields = append(fields, employee.FieldServiceCount)
  12671. }
  12672. if m.addachievement_count != nil {
  12673. fields = append(fields, employee.FieldAchievementCount)
  12674. }
  12675. if m.addorganization_id != nil {
  12676. fields = append(fields, employee.FieldOrganizationID)
  12677. }
  12678. if m.addcategory_id != nil {
  12679. fields = append(fields, employee.FieldCategoryID)
  12680. }
  12681. if m.addis_vip != nil {
  12682. fields = append(fields, employee.FieldIsVip)
  12683. }
  12684. return fields
  12685. }
  12686. // AddedField returns the numeric value that was incremented/decremented on a field
  12687. // with the given name. The second boolean return value indicates that this field
  12688. // was not set, or was not defined in the schema.
  12689. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12690. switch name {
  12691. case employee.FieldHireCount:
  12692. return m.AddedHireCount()
  12693. case employee.FieldServiceCount:
  12694. return m.AddedServiceCount()
  12695. case employee.FieldAchievementCount:
  12696. return m.AddedAchievementCount()
  12697. case employee.FieldOrganizationID:
  12698. return m.AddedOrganizationID()
  12699. case employee.FieldCategoryID:
  12700. return m.AddedCategoryID()
  12701. case employee.FieldIsVip:
  12702. return m.AddedIsVip()
  12703. }
  12704. return nil, false
  12705. }
  12706. // AddField adds the value to the field with the given name. It returns an error if
  12707. // the field is not defined in the schema, or if the type mismatched the field
  12708. // type.
  12709. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12710. switch name {
  12711. case employee.FieldHireCount:
  12712. v, ok := value.(int)
  12713. if !ok {
  12714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12715. }
  12716. m.AddHireCount(v)
  12717. return nil
  12718. case employee.FieldServiceCount:
  12719. v, ok := value.(int)
  12720. if !ok {
  12721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12722. }
  12723. m.AddServiceCount(v)
  12724. return nil
  12725. case employee.FieldAchievementCount:
  12726. v, ok := value.(int)
  12727. if !ok {
  12728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12729. }
  12730. m.AddAchievementCount(v)
  12731. return nil
  12732. case employee.FieldOrganizationID:
  12733. v, ok := value.(int64)
  12734. if !ok {
  12735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12736. }
  12737. m.AddOrganizationID(v)
  12738. return nil
  12739. case employee.FieldCategoryID:
  12740. v, ok := value.(int64)
  12741. if !ok {
  12742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12743. }
  12744. m.AddCategoryID(v)
  12745. return nil
  12746. case employee.FieldIsVip:
  12747. v, ok := value.(int)
  12748. if !ok {
  12749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12750. }
  12751. m.AddIsVip(v)
  12752. return nil
  12753. }
  12754. return fmt.Errorf("unknown Employee numeric field %s", name)
  12755. }
  12756. // ClearedFields returns all nullable fields that were cleared during this
  12757. // mutation.
  12758. func (m *EmployeeMutation) ClearedFields() []string {
  12759. var fields []string
  12760. if m.FieldCleared(employee.FieldDeletedAt) {
  12761. fields = append(fields, employee.FieldDeletedAt)
  12762. }
  12763. if m.FieldCleared(employee.FieldAiInfo) {
  12764. fields = append(fields, employee.FieldAiInfo)
  12765. }
  12766. return fields
  12767. }
  12768. // FieldCleared returns a boolean indicating if a field with the given name was
  12769. // cleared in this mutation.
  12770. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12771. _, ok := m.clearedFields[name]
  12772. return ok
  12773. }
  12774. // ClearField clears the value of the field with the given name. It returns an
  12775. // error if the field is not defined in the schema.
  12776. func (m *EmployeeMutation) ClearField(name string) error {
  12777. switch name {
  12778. case employee.FieldDeletedAt:
  12779. m.ClearDeletedAt()
  12780. return nil
  12781. case employee.FieldAiInfo:
  12782. m.ClearAiInfo()
  12783. return nil
  12784. }
  12785. return fmt.Errorf("unknown Employee nullable field %s", name)
  12786. }
  12787. // ResetField resets all changes in the mutation for the field with the given name.
  12788. // It returns an error if the field is not defined in the schema.
  12789. func (m *EmployeeMutation) ResetField(name string) error {
  12790. switch name {
  12791. case employee.FieldCreatedAt:
  12792. m.ResetCreatedAt()
  12793. return nil
  12794. case employee.FieldUpdatedAt:
  12795. m.ResetUpdatedAt()
  12796. return nil
  12797. case employee.FieldDeletedAt:
  12798. m.ResetDeletedAt()
  12799. return nil
  12800. case employee.FieldTitle:
  12801. m.ResetTitle()
  12802. return nil
  12803. case employee.FieldAvatar:
  12804. m.ResetAvatar()
  12805. return nil
  12806. case employee.FieldTags:
  12807. m.ResetTags()
  12808. return nil
  12809. case employee.FieldHireCount:
  12810. m.ResetHireCount()
  12811. return nil
  12812. case employee.FieldServiceCount:
  12813. m.ResetServiceCount()
  12814. return nil
  12815. case employee.FieldAchievementCount:
  12816. m.ResetAchievementCount()
  12817. return nil
  12818. case employee.FieldIntro:
  12819. m.ResetIntro()
  12820. return nil
  12821. case employee.FieldEstimate:
  12822. m.ResetEstimate()
  12823. return nil
  12824. case employee.FieldSkill:
  12825. m.ResetSkill()
  12826. return nil
  12827. case employee.FieldAbilityType:
  12828. m.ResetAbilityType()
  12829. return nil
  12830. case employee.FieldScene:
  12831. m.ResetScene()
  12832. return nil
  12833. case employee.FieldSwitchIn:
  12834. m.ResetSwitchIn()
  12835. return nil
  12836. case employee.FieldVideoURL:
  12837. m.ResetVideoURL()
  12838. return nil
  12839. case employee.FieldOrganizationID:
  12840. m.ResetOrganizationID()
  12841. return nil
  12842. case employee.FieldCategoryID:
  12843. m.ResetCategoryID()
  12844. return nil
  12845. case employee.FieldAPIBase:
  12846. m.ResetAPIBase()
  12847. return nil
  12848. case employee.FieldAPIKey:
  12849. m.ResetAPIKey()
  12850. return nil
  12851. case employee.FieldAiInfo:
  12852. m.ResetAiInfo()
  12853. return nil
  12854. case employee.FieldIsVip:
  12855. m.ResetIsVip()
  12856. return nil
  12857. case employee.FieldChatURL:
  12858. m.ResetChatURL()
  12859. return nil
  12860. }
  12861. return fmt.Errorf("unknown Employee field %s", name)
  12862. }
  12863. // AddedEdges returns all edge names that were set/added in this mutation.
  12864. func (m *EmployeeMutation) AddedEdges() []string {
  12865. edges := make([]string, 0, 2)
  12866. if m.em_work_experiences != nil {
  12867. edges = append(edges, employee.EdgeEmWorkExperiences)
  12868. }
  12869. if m.em_tutorial != nil {
  12870. edges = append(edges, employee.EdgeEmTutorial)
  12871. }
  12872. return edges
  12873. }
  12874. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12875. // name in this mutation.
  12876. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12877. switch name {
  12878. case employee.EdgeEmWorkExperiences:
  12879. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12880. for id := range m.em_work_experiences {
  12881. ids = append(ids, id)
  12882. }
  12883. return ids
  12884. case employee.EdgeEmTutorial:
  12885. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12886. for id := range m.em_tutorial {
  12887. ids = append(ids, id)
  12888. }
  12889. return ids
  12890. }
  12891. return nil
  12892. }
  12893. // RemovedEdges returns all edge names that were removed in this mutation.
  12894. func (m *EmployeeMutation) RemovedEdges() []string {
  12895. edges := make([]string, 0, 2)
  12896. if m.removedem_work_experiences != nil {
  12897. edges = append(edges, employee.EdgeEmWorkExperiences)
  12898. }
  12899. if m.removedem_tutorial != nil {
  12900. edges = append(edges, employee.EdgeEmTutorial)
  12901. }
  12902. return edges
  12903. }
  12904. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12905. // the given name in this mutation.
  12906. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12907. switch name {
  12908. case employee.EdgeEmWorkExperiences:
  12909. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12910. for id := range m.removedem_work_experiences {
  12911. ids = append(ids, id)
  12912. }
  12913. return ids
  12914. case employee.EdgeEmTutorial:
  12915. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12916. for id := range m.removedem_tutorial {
  12917. ids = append(ids, id)
  12918. }
  12919. return ids
  12920. }
  12921. return nil
  12922. }
  12923. // ClearedEdges returns all edge names that were cleared in this mutation.
  12924. func (m *EmployeeMutation) ClearedEdges() []string {
  12925. edges := make([]string, 0, 2)
  12926. if m.clearedem_work_experiences {
  12927. edges = append(edges, employee.EdgeEmWorkExperiences)
  12928. }
  12929. if m.clearedem_tutorial {
  12930. edges = append(edges, employee.EdgeEmTutorial)
  12931. }
  12932. return edges
  12933. }
  12934. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12935. // was cleared in this mutation.
  12936. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12937. switch name {
  12938. case employee.EdgeEmWorkExperiences:
  12939. return m.clearedem_work_experiences
  12940. case employee.EdgeEmTutorial:
  12941. return m.clearedem_tutorial
  12942. }
  12943. return false
  12944. }
  12945. // ClearEdge clears the value of the edge with the given name. It returns an error
  12946. // if that edge is not defined in the schema.
  12947. func (m *EmployeeMutation) ClearEdge(name string) error {
  12948. switch name {
  12949. }
  12950. return fmt.Errorf("unknown Employee unique edge %s", name)
  12951. }
  12952. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12953. // It returns an error if the edge is not defined in the schema.
  12954. func (m *EmployeeMutation) ResetEdge(name string) error {
  12955. switch name {
  12956. case employee.EdgeEmWorkExperiences:
  12957. m.ResetEmWorkExperiences()
  12958. return nil
  12959. case employee.EdgeEmTutorial:
  12960. m.ResetEmTutorial()
  12961. return nil
  12962. }
  12963. return fmt.Errorf("unknown Employee edge %s", name)
  12964. }
  12965. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12966. type EmployeeConfigMutation struct {
  12967. config
  12968. op Op
  12969. typ string
  12970. id *uint64
  12971. created_at *time.Time
  12972. updated_at *time.Time
  12973. deleted_at *time.Time
  12974. stype *string
  12975. title *string
  12976. photo *string
  12977. organization_id *uint64
  12978. addorganization_id *int64
  12979. clearedFields map[string]struct{}
  12980. done bool
  12981. oldValue func(context.Context) (*EmployeeConfig, error)
  12982. predicates []predicate.EmployeeConfig
  12983. }
  12984. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12985. // employeeconfigOption allows management of the mutation configuration using functional options.
  12986. type employeeconfigOption func(*EmployeeConfigMutation)
  12987. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12988. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12989. m := &EmployeeConfigMutation{
  12990. config: c,
  12991. op: op,
  12992. typ: TypeEmployeeConfig,
  12993. clearedFields: make(map[string]struct{}),
  12994. }
  12995. for _, opt := range opts {
  12996. opt(m)
  12997. }
  12998. return m
  12999. }
  13000. // withEmployeeConfigID sets the ID field of the mutation.
  13001. func withEmployeeConfigID(id uint64) employeeconfigOption {
  13002. return func(m *EmployeeConfigMutation) {
  13003. var (
  13004. err error
  13005. once sync.Once
  13006. value *EmployeeConfig
  13007. )
  13008. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  13009. once.Do(func() {
  13010. if m.done {
  13011. err = errors.New("querying old values post mutation is not allowed")
  13012. } else {
  13013. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  13014. }
  13015. })
  13016. return value, err
  13017. }
  13018. m.id = &id
  13019. }
  13020. }
  13021. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  13022. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  13023. return func(m *EmployeeConfigMutation) {
  13024. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  13025. return node, nil
  13026. }
  13027. m.id = &node.ID
  13028. }
  13029. }
  13030. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13031. // executed in a transaction (ent.Tx), a transactional client is returned.
  13032. func (m EmployeeConfigMutation) Client() *Client {
  13033. client := &Client{config: m.config}
  13034. client.init()
  13035. return client
  13036. }
  13037. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13038. // it returns an error otherwise.
  13039. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13040. if _, ok := m.driver.(*txDriver); !ok {
  13041. return nil, errors.New("ent: mutation is not running in a transaction")
  13042. }
  13043. tx := &Tx{config: m.config}
  13044. tx.init()
  13045. return tx, nil
  13046. }
  13047. // SetID sets the value of the id field. Note that this
  13048. // operation is only accepted on creation of EmployeeConfig entities.
  13049. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13050. m.id = &id
  13051. }
  13052. // ID returns the ID value in the mutation. Note that the ID is only available
  13053. // if it was provided to the builder or after it was returned from the database.
  13054. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13055. if m.id == nil {
  13056. return
  13057. }
  13058. return *m.id, true
  13059. }
  13060. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13061. // That means, if the mutation is applied within a transaction with an isolation level such
  13062. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13063. // or updated by the mutation.
  13064. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13065. switch {
  13066. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13067. id, exists := m.ID()
  13068. if exists {
  13069. return []uint64{id}, nil
  13070. }
  13071. fallthrough
  13072. case m.op.Is(OpUpdate | OpDelete):
  13073. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13074. default:
  13075. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13076. }
  13077. }
  13078. // SetCreatedAt sets the "created_at" field.
  13079. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13080. m.created_at = &t
  13081. }
  13082. // CreatedAt returns the value of the "created_at" field in the mutation.
  13083. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13084. v := m.created_at
  13085. if v == nil {
  13086. return
  13087. }
  13088. return *v, true
  13089. }
  13090. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13091. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13093. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13094. if !m.op.Is(OpUpdateOne) {
  13095. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13096. }
  13097. if m.id == nil || m.oldValue == nil {
  13098. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13099. }
  13100. oldValue, err := m.oldValue(ctx)
  13101. if err != nil {
  13102. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13103. }
  13104. return oldValue.CreatedAt, nil
  13105. }
  13106. // ResetCreatedAt resets all changes to the "created_at" field.
  13107. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13108. m.created_at = nil
  13109. }
  13110. // SetUpdatedAt sets the "updated_at" field.
  13111. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13112. m.updated_at = &t
  13113. }
  13114. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13115. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13116. v := m.updated_at
  13117. if v == nil {
  13118. return
  13119. }
  13120. return *v, true
  13121. }
  13122. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13123. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13125. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13126. if !m.op.Is(OpUpdateOne) {
  13127. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13128. }
  13129. if m.id == nil || m.oldValue == nil {
  13130. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13131. }
  13132. oldValue, err := m.oldValue(ctx)
  13133. if err != nil {
  13134. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13135. }
  13136. return oldValue.UpdatedAt, nil
  13137. }
  13138. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13139. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13140. m.updated_at = nil
  13141. }
  13142. // SetDeletedAt sets the "deleted_at" field.
  13143. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13144. m.deleted_at = &t
  13145. }
  13146. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13147. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13148. v := m.deleted_at
  13149. if v == nil {
  13150. return
  13151. }
  13152. return *v, true
  13153. }
  13154. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13155. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13157. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13158. if !m.op.Is(OpUpdateOne) {
  13159. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13160. }
  13161. if m.id == nil || m.oldValue == nil {
  13162. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13163. }
  13164. oldValue, err := m.oldValue(ctx)
  13165. if err != nil {
  13166. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13167. }
  13168. return oldValue.DeletedAt, nil
  13169. }
  13170. // ClearDeletedAt clears the value of the "deleted_at" field.
  13171. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13172. m.deleted_at = nil
  13173. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13174. }
  13175. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13176. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13177. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13178. return ok
  13179. }
  13180. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13181. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13182. m.deleted_at = nil
  13183. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13184. }
  13185. // SetStype sets the "stype" field.
  13186. func (m *EmployeeConfigMutation) SetStype(s string) {
  13187. m.stype = &s
  13188. }
  13189. // Stype returns the value of the "stype" field in the mutation.
  13190. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13191. v := m.stype
  13192. if v == nil {
  13193. return
  13194. }
  13195. return *v, true
  13196. }
  13197. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13198. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13200. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13201. if !m.op.Is(OpUpdateOne) {
  13202. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13203. }
  13204. if m.id == nil || m.oldValue == nil {
  13205. return v, errors.New("OldStype requires an ID field in the mutation")
  13206. }
  13207. oldValue, err := m.oldValue(ctx)
  13208. if err != nil {
  13209. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13210. }
  13211. return oldValue.Stype, nil
  13212. }
  13213. // ResetStype resets all changes to the "stype" field.
  13214. func (m *EmployeeConfigMutation) ResetStype() {
  13215. m.stype = nil
  13216. }
  13217. // SetTitle sets the "title" field.
  13218. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13219. m.title = &s
  13220. }
  13221. // Title returns the value of the "title" field in the mutation.
  13222. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13223. v := m.title
  13224. if v == nil {
  13225. return
  13226. }
  13227. return *v, true
  13228. }
  13229. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13230. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13232. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13233. if !m.op.Is(OpUpdateOne) {
  13234. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13235. }
  13236. if m.id == nil || m.oldValue == nil {
  13237. return v, errors.New("OldTitle requires an ID field in the mutation")
  13238. }
  13239. oldValue, err := m.oldValue(ctx)
  13240. if err != nil {
  13241. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13242. }
  13243. return oldValue.Title, nil
  13244. }
  13245. // ResetTitle resets all changes to the "title" field.
  13246. func (m *EmployeeConfigMutation) ResetTitle() {
  13247. m.title = nil
  13248. }
  13249. // SetPhoto sets the "photo" field.
  13250. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13251. m.photo = &s
  13252. }
  13253. // Photo returns the value of the "photo" field in the mutation.
  13254. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13255. v := m.photo
  13256. if v == nil {
  13257. return
  13258. }
  13259. return *v, true
  13260. }
  13261. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13262. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13264. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13265. if !m.op.Is(OpUpdateOne) {
  13266. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13267. }
  13268. if m.id == nil || m.oldValue == nil {
  13269. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13270. }
  13271. oldValue, err := m.oldValue(ctx)
  13272. if err != nil {
  13273. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13274. }
  13275. return oldValue.Photo, nil
  13276. }
  13277. // ResetPhoto resets all changes to the "photo" field.
  13278. func (m *EmployeeConfigMutation) ResetPhoto() {
  13279. m.photo = nil
  13280. }
  13281. // SetOrganizationID sets the "organization_id" field.
  13282. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13283. m.organization_id = &u
  13284. m.addorganization_id = nil
  13285. }
  13286. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13287. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13288. v := m.organization_id
  13289. if v == nil {
  13290. return
  13291. }
  13292. return *v, true
  13293. }
  13294. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13295. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13297. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13298. if !m.op.Is(OpUpdateOne) {
  13299. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13300. }
  13301. if m.id == nil || m.oldValue == nil {
  13302. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13303. }
  13304. oldValue, err := m.oldValue(ctx)
  13305. if err != nil {
  13306. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13307. }
  13308. return oldValue.OrganizationID, nil
  13309. }
  13310. // AddOrganizationID adds u to the "organization_id" field.
  13311. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13312. if m.addorganization_id != nil {
  13313. *m.addorganization_id += u
  13314. } else {
  13315. m.addorganization_id = &u
  13316. }
  13317. }
  13318. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13319. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13320. v := m.addorganization_id
  13321. if v == nil {
  13322. return
  13323. }
  13324. return *v, true
  13325. }
  13326. // ClearOrganizationID clears the value of the "organization_id" field.
  13327. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13328. m.organization_id = nil
  13329. m.addorganization_id = nil
  13330. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13331. }
  13332. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13333. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13334. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13335. return ok
  13336. }
  13337. // ResetOrganizationID resets all changes to the "organization_id" field.
  13338. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13339. m.organization_id = nil
  13340. m.addorganization_id = nil
  13341. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13342. }
  13343. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13344. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13345. m.predicates = append(m.predicates, ps...)
  13346. }
  13347. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13348. // users can use type-assertion to append predicates that do not depend on any generated package.
  13349. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13350. p := make([]predicate.EmployeeConfig, len(ps))
  13351. for i := range ps {
  13352. p[i] = ps[i]
  13353. }
  13354. m.Where(p...)
  13355. }
  13356. // Op returns the operation name.
  13357. func (m *EmployeeConfigMutation) Op() Op {
  13358. return m.op
  13359. }
  13360. // SetOp allows setting the mutation operation.
  13361. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13362. m.op = op
  13363. }
  13364. // Type returns the node type of this mutation (EmployeeConfig).
  13365. func (m *EmployeeConfigMutation) Type() string {
  13366. return m.typ
  13367. }
  13368. // Fields returns all fields that were changed during this mutation. Note that in
  13369. // order to get all numeric fields that were incremented/decremented, call
  13370. // AddedFields().
  13371. func (m *EmployeeConfigMutation) Fields() []string {
  13372. fields := make([]string, 0, 7)
  13373. if m.created_at != nil {
  13374. fields = append(fields, employeeconfig.FieldCreatedAt)
  13375. }
  13376. if m.updated_at != nil {
  13377. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13378. }
  13379. if m.deleted_at != nil {
  13380. fields = append(fields, employeeconfig.FieldDeletedAt)
  13381. }
  13382. if m.stype != nil {
  13383. fields = append(fields, employeeconfig.FieldStype)
  13384. }
  13385. if m.title != nil {
  13386. fields = append(fields, employeeconfig.FieldTitle)
  13387. }
  13388. if m.photo != nil {
  13389. fields = append(fields, employeeconfig.FieldPhoto)
  13390. }
  13391. if m.organization_id != nil {
  13392. fields = append(fields, employeeconfig.FieldOrganizationID)
  13393. }
  13394. return fields
  13395. }
  13396. // Field returns the value of a field with the given name. The second boolean
  13397. // return value indicates that this field was not set, or was not defined in the
  13398. // schema.
  13399. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13400. switch name {
  13401. case employeeconfig.FieldCreatedAt:
  13402. return m.CreatedAt()
  13403. case employeeconfig.FieldUpdatedAt:
  13404. return m.UpdatedAt()
  13405. case employeeconfig.FieldDeletedAt:
  13406. return m.DeletedAt()
  13407. case employeeconfig.FieldStype:
  13408. return m.Stype()
  13409. case employeeconfig.FieldTitle:
  13410. return m.Title()
  13411. case employeeconfig.FieldPhoto:
  13412. return m.Photo()
  13413. case employeeconfig.FieldOrganizationID:
  13414. return m.OrganizationID()
  13415. }
  13416. return nil, false
  13417. }
  13418. // OldField returns the old value of the field from the database. An error is
  13419. // returned if the mutation operation is not UpdateOne, or the query to the
  13420. // database failed.
  13421. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13422. switch name {
  13423. case employeeconfig.FieldCreatedAt:
  13424. return m.OldCreatedAt(ctx)
  13425. case employeeconfig.FieldUpdatedAt:
  13426. return m.OldUpdatedAt(ctx)
  13427. case employeeconfig.FieldDeletedAt:
  13428. return m.OldDeletedAt(ctx)
  13429. case employeeconfig.FieldStype:
  13430. return m.OldStype(ctx)
  13431. case employeeconfig.FieldTitle:
  13432. return m.OldTitle(ctx)
  13433. case employeeconfig.FieldPhoto:
  13434. return m.OldPhoto(ctx)
  13435. case employeeconfig.FieldOrganizationID:
  13436. return m.OldOrganizationID(ctx)
  13437. }
  13438. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13439. }
  13440. // SetField sets the value of a field with the given name. It returns an error if
  13441. // the field is not defined in the schema, or if the type mismatched the field
  13442. // type.
  13443. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13444. switch name {
  13445. case employeeconfig.FieldCreatedAt:
  13446. v, ok := value.(time.Time)
  13447. if !ok {
  13448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13449. }
  13450. m.SetCreatedAt(v)
  13451. return nil
  13452. case employeeconfig.FieldUpdatedAt:
  13453. v, ok := value.(time.Time)
  13454. if !ok {
  13455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13456. }
  13457. m.SetUpdatedAt(v)
  13458. return nil
  13459. case employeeconfig.FieldDeletedAt:
  13460. v, ok := value.(time.Time)
  13461. if !ok {
  13462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13463. }
  13464. m.SetDeletedAt(v)
  13465. return nil
  13466. case employeeconfig.FieldStype:
  13467. v, ok := value.(string)
  13468. if !ok {
  13469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13470. }
  13471. m.SetStype(v)
  13472. return nil
  13473. case employeeconfig.FieldTitle:
  13474. v, ok := value.(string)
  13475. if !ok {
  13476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13477. }
  13478. m.SetTitle(v)
  13479. return nil
  13480. case employeeconfig.FieldPhoto:
  13481. v, ok := value.(string)
  13482. if !ok {
  13483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13484. }
  13485. m.SetPhoto(v)
  13486. return nil
  13487. case employeeconfig.FieldOrganizationID:
  13488. v, ok := value.(uint64)
  13489. if !ok {
  13490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13491. }
  13492. m.SetOrganizationID(v)
  13493. return nil
  13494. }
  13495. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13496. }
  13497. // AddedFields returns all numeric fields that were incremented/decremented during
  13498. // this mutation.
  13499. func (m *EmployeeConfigMutation) AddedFields() []string {
  13500. var fields []string
  13501. if m.addorganization_id != nil {
  13502. fields = append(fields, employeeconfig.FieldOrganizationID)
  13503. }
  13504. return fields
  13505. }
  13506. // AddedField returns the numeric value that was incremented/decremented on a field
  13507. // with the given name. The second boolean return value indicates that this field
  13508. // was not set, or was not defined in the schema.
  13509. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13510. switch name {
  13511. case employeeconfig.FieldOrganizationID:
  13512. return m.AddedOrganizationID()
  13513. }
  13514. return nil, false
  13515. }
  13516. // AddField adds the value to the field with the given name. It returns an error if
  13517. // the field is not defined in the schema, or if the type mismatched the field
  13518. // type.
  13519. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13520. switch name {
  13521. case employeeconfig.FieldOrganizationID:
  13522. v, ok := value.(int64)
  13523. if !ok {
  13524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13525. }
  13526. m.AddOrganizationID(v)
  13527. return nil
  13528. }
  13529. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13530. }
  13531. // ClearedFields returns all nullable fields that were cleared during this
  13532. // mutation.
  13533. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13534. var fields []string
  13535. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13536. fields = append(fields, employeeconfig.FieldDeletedAt)
  13537. }
  13538. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13539. fields = append(fields, employeeconfig.FieldOrganizationID)
  13540. }
  13541. return fields
  13542. }
  13543. // FieldCleared returns a boolean indicating if a field with the given name was
  13544. // cleared in this mutation.
  13545. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13546. _, ok := m.clearedFields[name]
  13547. return ok
  13548. }
  13549. // ClearField clears the value of the field with the given name. It returns an
  13550. // error if the field is not defined in the schema.
  13551. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13552. switch name {
  13553. case employeeconfig.FieldDeletedAt:
  13554. m.ClearDeletedAt()
  13555. return nil
  13556. case employeeconfig.FieldOrganizationID:
  13557. m.ClearOrganizationID()
  13558. return nil
  13559. }
  13560. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13561. }
  13562. // ResetField resets all changes in the mutation for the field with the given name.
  13563. // It returns an error if the field is not defined in the schema.
  13564. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13565. switch name {
  13566. case employeeconfig.FieldCreatedAt:
  13567. m.ResetCreatedAt()
  13568. return nil
  13569. case employeeconfig.FieldUpdatedAt:
  13570. m.ResetUpdatedAt()
  13571. return nil
  13572. case employeeconfig.FieldDeletedAt:
  13573. m.ResetDeletedAt()
  13574. return nil
  13575. case employeeconfig.FieldStype:
  13576. m.ResetStype()
  13577. return nil
  13578. case employeeconfig.FieldTitle:
  13579. m.ResetTitle()
  13580. return nil
  13581. case employeeconfig.FieldPhoto:
  13582. m.ResetPhoto()
  13583. return nil
  13584. case employeeconfig.FieldOrganizationID:
  13585. m.ResetOrganizationID()
  13586. return nil
  13587. }
  13588. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13589. }
  13590. // AddedEdges returns all edge names that were set/added in this mutation.
  13591. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13592. edges := make([]string, 0, 0)
  13593. return edges
  13594. }
  13595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13596. // name in this mutation.
  13597. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13598. return nil
  13599. }
  13600. // RemovedEdges returns all edge names that were removed in this mutation.
  13601. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13602. edges := make([]string, 0, 0)
  13603. return edges
  13604. }
  13605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13606. // the given name in this mutation.
  13607. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13608. return nil
  13609. }
  13610. // ClearedEdges returns all edge names that were cleared in this mutation.
  13611. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13612. edges := make([]string, 0, 0)
  13613. return edges
  13614. }
  13615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13616. // was cleared in this mutation.
  13617. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13618. return false
  13619. }
  13620. // ClearEdge clears the value of the edge with the given name. It returns an error
  13621. // if that edge is not defined in the schema.
  13622. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13623. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13624. }
  13625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13626. // It returns an error if the edge is not defined in the schema.
  13627. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13628. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13629. }
  13630. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13631. type LabelMutation struct {
  13632. config
  13633. op Op
  13634. typ string
  13635. id *uint64
  13636. created_at *time.Time
  13637. updated_at *time.Time
  13638. status *uint8
  13639. addstatus *int8
  13640. _type *int
  13641. add_type *int
  13642. name *string
  13643. from *int
  13644. addfrom *int
  13645. mode *int
  13646. addmode *int
  13647. conditions *string
  13648. organization_id *uint64
  13649. addorganization_id *int64
  13650. clearedFields map[string]struct{}
  13651. label_relationships map[uint64]struct{}
  13652. removedlabel_relationships map[uint64]struct{}
  13653. clearedlabel_relationships bool
  13654. done bool
  13655. oldValue func(context.Context) (*Label, error)
  13656. predicates []predicate.Label
  13657. }
  13658. var _ ent.Mutation = (*LabelMutation)(nil)
  13659. // labelOption allows management of the mutation configuration using functional options.
  13660. type labelOption func(*LabelMutation)
  13661. // newLabelMutation creates new mutation for the Label entity.
  13662. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13663. m := &LabelMutation{
  13664. config: c,
  13665. op: op,
  13666. typ: TypeLabel,
  13667. clearedFields: make(map[string]struct{}),
  13668. }
  13669. for _, opt := range opts {
  13670. opt(m)
  13671. }
  13672. return m
  13673. }
  13674. // withLabelID sets the ID field of the mutation.
  13675. func withLabelID(id uint64) labelOption {
  13676. return func(m *LabelMutation) {
  13677. var (
  13678. err error
  13679. once sync.Once
  13680. value *Label
  13681. )
  13682. m.oldValue = func(ctx context.Context) (*Label, error) {
  13683. once.Do(func() {
  13684. if m.done {
  13685. err = errors.New("querying old values post mutation is not allowed")
  13686. } else {
  13687. value, err = m.Client().Label.Get(ctx, id)
  13688. }
  13689. })
  13690. return value, err
  13691. }
  13692. m.id = &id
  13693. }
  13694. }
  13695. // withLabel sets the old Label of the mutation.
  13696. func withLabel(node *Label) labelOption {
  13697. return func(m *LabelMutation) {
  13698. m.oldValue = func(context.Context) (*Label, error) {
  13699. return node, nil
  13700. }
  13701. m.id = &node.ID
  13702. }
  13703. }
  13704. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13705. // executed in a transaction (ent.Tx), a transactional client is returned.
  13706. func (m LabelMutation) Client() *Client {
  13707. client := &Client{config: m.config}
  13708. client.init()
  13709. return client
  13710. }
  13711. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13712. // it returns an error otherwise.
  13713. func (m LabelMutation) Tx() (*Tx, error) {
  13714. if _, ok := m.driver.(*txDriver); !ok {
  13715. return nil, errors.New("ent: mutation is not running in a transaction")
  13716. }
  13717. tx := &Tx{config: m.config}
  13718. tx.init()
  13719. return tx, nil
  13720. }
  13721. // SetID sets the value of the id field. Note that this
  13722. // operation is only accepted on creation of Label entities.
  13723. func (m *LabelMutation) SetID(id uint64) {
  13724. m.id = &id
  13725. }
  13726. // ID returns the ID value in the mutation. Note that the ID is only available
  13727. // if it was provided to the builder or after it was returned from the database.
  13728. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13729. if m.id == nil {
  13730. return
  13731. }
  13732. return *m.id, true
  13733. }
  13734. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13735. // That means, if the mutation is applied within a transaction with an isolation level such
  13736. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13737. // or updated by the mutation.
  13738. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13739. switch {
  13740. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13741. id, exists := m.ID()
  13742. if exists {
  13743. return []uint64{id}, nil
  13744. }
  13745. fallthrough
  13746. case m.op.Is(OpUpdate | OpDelete):
  13747. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13748. default:
  13749. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13750. }
  13751. }
  13752. // SetCreatedAt sets the "created_at" field.
  13753. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13754. m.created_at = &t
  13755. }
  13756. // CreatedAt returns the value of the "created_at" field in the mutation.
  13757. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13758. v := m.created_at
  13759. if v == nil {
  13760. return
  13761. }
  13762. return *v, true
  13763. }
  13764. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13765. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13767. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13768. if !m.op.Is(OpUpdateOne) {
  13769. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13770. }
  13771. if m.id == nil || m.oldValue == nil {
  13772. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13773. }
  13774. oldValue, err := m.oldValue(ctx)
  13775. if err != nil {
  13776. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13777. }
  13778. return oldValue.CreatedAt, nil
  13779. }
  13780. // ResetCreatedAt resets all changes to the "created_at" field.
  13781. func (m *LabelMutation) ResetCreatedAt() {
  13782. m.created_at = nil
  13783. }
  13784. // SetUpdatedAt sets the "updated_at" field.
  13785. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13786. m.updated_at = &t
  13787. }
  13788. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13789. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13790. v := m.updated_at
  13791. if v == nil {
  13792. return
  13793. }
  13794. return *v, true
  13795. }
  13796. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13797. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13799. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13800. if !m.op.Is(OpUpdateOne) {
  13801. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13802. }
  13803. if m.id == nil || m.oldValue == nil {
  13804. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13805. }
  13806. oldValue, err := m.oldValue(ctx)
  13807. if err != nil {
  13808. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13809. }
  13810. return oldValue.UpdatedAt, nil
  13811. }
  13812. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13813. func (m *LabelMutation) ResetUpdatedAt() {
  13814. m.updated_at = nil
  13815. }
  13816. // SetStatus sets the "status" field.
  13817. func (m *LabelMutation) SetStatus(u uint8) {
  13818. m.status = &u
  13819. m.addstatus = nil
  13820. }
  13821. // Status returns the value of the "status" field in the mutation.
  13822. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13823. v := m.status
  13824. if v == nil {
  13825. return
  13826. }
  13827. return *v, true
  13828. }
  13829. // OldStatus returns the old "status" field's value of the Label entity.
  13830. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13832. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13833. if !m.op.Is(OpUpdateOne) {
  13834. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13835. }
  13836. if m.id == nil || m.oldValue == nil {
  13837. return v, errors.New("OldStatus requires an ID field in the mutation")
  13838. }
  13839. oldValue, err := m.oldValue(ctx)
  13840. if err != nil {
  13841. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13842. }
  13843. return oldValue.Status, nil
  13844. }
  13845. // AddStatus adds u to the "status" field.
  13846. func (m *LabelMutation) AddStatus(u int8) {
  13847. if m.addstatus != nil {
  13848. *m.addstatus += u
  13849. } else {
  13850. m.addstatus = &u
  13851. }
  13852. }
  13853. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13854. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13855. v := m.addstatus
  13856. if v == nil {
  13857. return
  13858. }
  13859. return *v, true
  13860. }
  13861. // ClearStatus clears the value of the "status" field.
  13862. func (m *LabelMutation) ClearStatus() {
  13863. m.status = nil
  13864. m.addstatus = nil
  13865. m.clearedFields[label.FieldStatus] = struct{}{}
  13866. }
  13867. // StatusCleared returns if the "status" field was cleared in this mutation.
  13868. func (m *LabelMutation) StatusCleared() bool {
  13869. _, ok := m.clearedFields[label.FieldStatus]
  13870. return ok
  13871. }
  13872. // ResetStatus resets all changes to the "status" field.
  13873. func (m *LabelMutation) ResetStatus() {
  13874. m.status = nil
  13875. m.addstatus = nil
  13876. delete(m.clearedFields, label.FieldStatus)
  13877. }
  13878. // SetType sets the "type" field.
  13879. func (m *LabelMutation) SetType(i int) {
  13880. m._type = &i
  13881. m.add_type = nil
  13882. }
  13883. // GetType returns the value of the "type" field in the mutation.
  13884. func (m *LabelMutation) GetType() (r int, exists bool) {
  13885. v := m._type
  13886. if v == nil {
  13887. return
  13888. }
  13889. return *v, true
  13890. }
  13891. // OldType returns the old "type" field's value of the Label entity.
  13892. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13894. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13895. if !m.op.Is(OpUpdateOne) {
  13896. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13897. }
  13898. if m.id == nil || m.oldValue == nil {
  13899. return v, errors.New("OldType requires an ID field in the mutation")
  13900. }
  13901. oldValue, err := m.oldValue(ctx)
  13902. if err != nil {
  13903. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13904. }
  13905. return oldValue.Type, nil
  13906. }
  13907. // AddType adds i to the "type" field.
  13908. func (m *LabelMutation) AddType(i int) {
  13909. if m.add_type != nil {
  13910. *m.add_type += i
  13911. } else {
  13912. m.add_type = &i
  13913. }
  13914. }
  13915. // AddedType returns the value that was added to the "type" field in this mutation.
  13916. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13917. v := m.add_type
  13918. if v == nil {
  13919. return
  13920. }
  13921. return *v, true
  13922. }
  13923. // ResetType resets all changes to the "type" field.
  13924. func (m *LabelMutation) ResetType() {
  13925. m._type = nil
  13926. m.add_type = nil
  13927. }
  13928. // SetName sets the "name" field.
  13929. func (m *LabelMutation) SetName(s string) {
  13930. m.name = &s
  13931. }
  13932. // Name returns the value of the "name" field in the mutation.
  13933. func (m *LabelMutation) Name() (r string, exists bool) {
  13934. v := m.name
  13935. if v == nil {
  13936. return
  13937. }
  13938. return *v, true
  13939. }
  13940. // OldName returns the old "name" field's value of the Label entity.
  13941. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13943. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13944. if !m.op.Is(OpUpdateOne) {
  13945. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13946. }
  13947. if m.id == nil || m.oldValue == nil {
  13948. return v, errors.New("OldName requires an ID field in the mutation")
  13949. }
  13950. oldValue, err := m.oldValue(ctx)
  13951. if err != nil {
  13952. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13953. }
  13954. return oldValue.Name, nil
  13955. }
  13956. // ResetName resets all changes to the "name" field.
  13957. func (m *LabelMutation) ResetName() {
  13958. m.name = nil
  13959. }
  13960. // SetFrom sets the "from" field.
  13961. func (m *LabelMutation) SetFrom(i int) {
  13962. m.from = &i
  13963. m.addfrom = nil
  13964. }
  13965. // From returns the value of the "from" field in the mutation.
  13966. func (m *LabelMutation) From() (r int, exists bool) {
  13967. v := m.from
  13968. if v == nil {
  13969. return
  13970. }
  13971. return *v, true
  13972. }
  13973. // OldFrom returns the old "from" field's value of the Label entity.
  13974. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13976. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13977. if !m.op.Is(OpUpdateOne) {
  13978. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13979. }
  13980. if m.id == nil || m.oldValue == nil {
  13981. return v, errors.New("OldFrom requires an ID field in the mutation")
  13982. }
  13983. oldValue, err := m.oldValue(ctx)
  13984. if err != nil {
  13985. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13986. }
  13987. return oldValue.From, nil
  13988. }
  13989. // AddFrom adds i to the "from" field.
  13990. func (m *LabelMutation) AddFrom(i int) {
  13991. if m.addfrom != nil {
  13992. *m.addfrom += i
  13993. } else {
  13994. m.addfrom = &i
  13995. }
  13996. }
  13997. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13998. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13999. v := m.addfrom
  14000. if v == nil {
  14001. return
  14002. }
  14003. return *v, true
  14004. }
  14005. // ResetFrom resets all changes to the "from" field.
  14006. func (m *LabelMutation) ResetFrom() {
  14007. m.from = nil
  14008. m.addfrom = nil
  14009. }
  14010. // SetMode sets the "mode" field.
  14011. func (m *LabelMutation) SetMode(i int) {
  14012. m.mode = &i
  14013. m.addmode = nil
  14014. }
  14015. // Mode returns the value of the "mode" field in the mutation.
  14016. func (m *LabelMutation) Mode() (r int, exists bool) {
  14017. v := m.mode
  14018. if v == nil {
  14019. return
  14020. }
  14021. return *v, true
  14022. }
  14023. // OldMode returns the old "mode" field's value of the Label entity.
  14024. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14026. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14027. if !m.op.Is(OpUpdateOne) {
  14028. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14029. }
  14030. if m.id == nil || m.oldValue == nil {
  14031. return v, errors.New("OldMode requires an ID field in the mutation")
  14032. }
  14033. oldValue, err := m.oldValue(ctx)
  14034. if err != nil {
  14035. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14036. }
  14037. return oldValue.Mode, nil
  14038. }
  14039. // AddMode adds i to the "mode" field.
  14040. func (m *LabelMutation) AddMode(i int) {
  14041. if m.addmode != nil {
  14042. *m.addmode += i
  14043. } else {
  14044. m.addmode = &i
  14045. }
  14046. }
  14047. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14048. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14049. v := m.addmode
  14050. if v == nil {
  14051. return
  14052. }
  14053. return *v, true
  14054. }
  14055. // ResetMode resets all changes to the "mode" field.
  14056. func (m *LabelMutation) ResetMode() {
  14057. m.mode = nil
  14058. m.addmode = nil
  14059. }
  14060. // SetConditions sets the "conditions" field.
  14061. func (m *LabelMutation) SetConditions(s string) {
  14062. m.conditions = &s
  14063. }
  14064. // Conditions returns the value of the "conditions" field in the mutation.
  14065. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14066. v := m.conditions
  14067. if v == nil {
  14068. return
  14069. }
  14070. return *v, true
  14071. }
  14072. // OldConditions returns the old "conditions" field's value of the Label entity.
  14073. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14075. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14076. if !m.op.Is(OpUpdateOne) {
  14077. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14078. }
  14079. if m.id == nil || m.oldValue == nil {
  14080. return v, errors.New("OldConditions requires an ID field in the mutation")
  14081. }
  14082. oldValue, err := m.oldValue(ctx)
  14083. if err != nil {
  14084. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14085. }
  14086. return oldValue.Conditions, nil
  14087. }
  14088. // ClearConditions clears the value of the "conditions" field.
  14089. func (m *LabelMutation) ClearConditions() {
  14090. m.conditions = nil
  14091. m.clearedFields[label.FieldConditions] = struct{}{}
  14092. }
  14093. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14094. func (m *LabelMutation) ConditionsCleared() bool {
  14095. _, ok := m.clearedFields[label.FieldConditions]
  14096. return ok
  14097. }
  14098. // ResetConditions resets all changes to the "conditions" field.
  14099. func (m *LabelMutation) ResetConditions() {
  14100. m.conditions = nil
  14101. delete(m.clearedFields, label.FieldConditions)
  14102. }
  14103. // SetOrganizationID sets the "organization_id" field.
  14104. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14105. m.organization_id = &u
  14106. m.addorganization_id = nil
  14107. }
  14108. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14109. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14110. v := m.organization_id
  14111. if v == nil {
  14112. return
  14113. }
  14114. return *v, true
  14115. }
  14116. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14117. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14119. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14120. if !m.op.Is(OpUpdateOne) {
  14121. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14122. }
  14123. if m.id == nil || m.oldValue == nil {
  14124. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14125. }
  14126. oldValue, err := m.oldValue(ctx)
  14127. if err != nil {
  14128. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14129. }
  14130. return oldValue.OrganizationID, nil
  14131. }
  14132. // AddOrganizationID adds u to the "organization_id" field.
  14133. func (m *LabelMutation) AddOrganizationID(u int64) {
  14134. if m.addorganization_id != nil {
  14135. *m.addorganization_id += u
  14136. } else {
  14137. m.addorganization_id = &u
  14138. }
  14139. }
  14140. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14141. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14142. v := m.addorganization_id
  14143. if v == nil {
  14144. return
  14145. }
  14146. return *v, true
  14147. }
  14148. // ClearOrganizationID clears the value of the "organization_id" field.
  14149. func (m *LabelMutation) ClearOrganizationID() {
  14150. m.organization_id = nil
  14151. m.addorganization_id = nil
  14152. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14153. }
  14154. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14155. func (m *LabelMutation) OrganizationIDCleared() bool {
  14156. _, ok := m.clearedFields[label.FieldOrganizationID]
  14157. return ok
  14158. }
  14159. // ResetOrganizationID resets all changes to the "organization_id" field.
  14160. func (m *LabelMutation) ResetOrganizationID() {
  14161. m.organization_id = nil
  14162. m.addorganization_id = nil
  14163. delete(m.clearedFields, label.FieldOrganizationID)
  14164. }
  14165. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14166. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14167. if m.label_relationships == nil {
  14168. m.label_relationships = make(map[uint64]struct{})
  14169. }
  14170. for i := range ids {
  14171. m.label_relationships[ids[i]] = struct{}{}
  14172. }
  14173. }
  14174. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14175. func (m *LabelMutation) ClearLabelRelationships() {
  14176. m.clearedlabel_relationships = true
  14177. }
  14178. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14179. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14180. return m.clearedlabel_relationships
  14181. }
  14182. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14183. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14184. if m.removedlabel_relationships == nil {
  14185. m.removedlabel_relationships = make(map[uint64]struct{})
  14186. }
  14187. for i := range ids {
  14188. delete(m.label_relationships, ids[i])
  14189. m.removedlabel_relationships[ids[i]] = struct{}{}
  14190. }
  14191. }
  14192. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14193. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14194. for id := range m.removedlabel_relationships {
  14195. ids = append(ids, id)
  14196. }
  14197. return
  14198. }
  14199. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14200. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14201. for id := range m.label_relationships {
  14202. ids = append(ids, id)
  14203. }
  14204. return
  14205. }
  14206. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14207. func (m *LabelMutation) ResetLabelRelationships() {
  14208. m.label_relationships = nil
  14209. m.clearedlabel_relationships = false
  14210. m.removedlabel_relationships = nil
  14211. }
  14212. // Where appends a list predicates to the LabelMutation builder.
  14213. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14214. m.predicates = append(m.predicates, ps...)
  14215. }
  14216. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14217. // users can use type-assertion to append predicates that do not depend on any generated package.
  14218. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14219. p := make([]predicate.Label, len(ps))
  14220. for i := range ps {
  14221. p[i] = ps[i]
  14222. }
  14223. m.Where(p...)
  14224. }
  14225. // Op returns the operation name.
  14226. func (m *LabelMutation) Op() Op {
  14227. return m.op
  14228. }
  14229. // SetOp allows setting the mutation operation.
  14230. func (m *LabelMutation) SetOp(op Op) {
  14231. m.op = op
  14232. }
  14233. // Type returns the node type of this mutation (Label).
  14234. func (m *LabelMutation) Type() string {
  14235. return m.typ
  14236. }
  14237. // Fields returns all fields that were changed during this mutation. Note that in
  14238. // order to get all numeric fields that were incremented/decremented, call
  14239. // AddedFields().
  14240. func (m *LabelMutation) Fields() []string {
  14241. fields := make([]string, 0, 9)
  14242. if m.created_at != nil {
  14243. fields = append(fields, label.FieldCreatedAt)
  14244. }
  14245. if m.updated_at != nil {
  14246. fields = append(fields, label.FieldUpdatedAt)
  14247. }
  14248. if m.status != nil {
  14249. fields = append(fields, label.FieldStatus)
  14250. }
  14251. if m._type != nil {
  14252. fields = append(fields, label.FieldType)
  14253. }
  14254. if m.name != nil {
  14255. fields = append(fields, label.FieldName)
  14256. }
  14257. if m.from != nil {
  14258. fields = append(fields, label.FieldFrom)
  14259. }
  14260. if m.mode != nil {
  14261. fields = append(fields, label.FieldMode)
  14262. }
  14263. if m.conditions != nil {
  14264. fields = append(fields, label.FieldConditions)
  14265. }
  14266. if m.organization_id != nil {
  14267. fields = append(fields, label.FieldOrganizationID)
  14268. }
  14269. return fields
  14270. }
  14271. // Field returns the value of a field with the given name. The second boolean
  14272. // return value indicates that this field was not set, or was not defined in the
  14273. // schema.
  14274. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14275. switch name {
  14276. case label.FieldCreatedAt:
  14277. return m.CreatedAt()
  14278. case label.FieldUpdatedAt:
  14279. return m.UpdatedAt()
  14280. case label.FieldStatus:
  14281. return m.Status()
  14282. case label.FieldType:
  14283. return m.GetType()
  14284. case label.FieldName:
  14285. return m.Name()
  14286. case label.FieldFrom:
  14287. return m.From()
  14288. case label.FieldMode:
  14289. return m.Mode()
  14290. case label.FieldConditions:
  14291. return m.Conditions()
  14292. case label.FieldOrganizationID:
  14293. return m.OrganizationID()
  14294. }
  14295. return nil, false
  14296. }
  14297. // OldField returns the old value of the field from the database. An error is
  14298. // returned if the mutation operation is not UpdateOne, or the query to the
  14299. // database failed.
  14300. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14301. switch name {
  14302. case label.FieldCreatedAt:
  14303. return m.OldCreatedAt(ctx)
  14304. case label.FieldUpdatedAt:
  14305. return m.OldUpdatedAt(ctx)
  14306. case label.FieldStatus:
  14307. return m.OldStatus(ctx)
  14308. case label.FieldType:
  14309. return m.OldType(ctx)
  14310. case label.FieldName:
  14311. return m.OldName(ctx)
  14312. case label.FieldFrom:
  14313. return m.OldFrom(ctx)
  14314. case label.FieldMode:
  14315. return m.OldMode(ctx)
  14316. case label.FieldConditions:
  14317. return m.OldConditions(ctx)
  14318. case label.FieldOrganizationID:
  14319. return m.OldOrganizationID(ctx)
  14320. }
  14321. return nil, fmt.Errorf("unknown Label field %s", name)
  14322. }
  14323. // SetField sets the value of a field with the given name. It returns an error if
  14324. // the field is not defined in the schema, or if the type mismatched the field
  14325. // type.
  14326. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14327. switch name {
  14328. case label.FieldCreatedAt:
  14329. v, ok := value.(time.Time)
  14330. if !ok {
  14331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14332. }
  14333. m.SetCreatedAt(v)
  14334. return nil
  14335. case label.FieldUpdatedAt:
  14336. v, ok := value.(time.Time)
  14337. if !ok {
  14338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14339. }
  14340. m.SetUpdatedAt(v)
  14341. return nil
  14342. case label.FieldStatus:
  14343. v, ok := value.(uint8)
  14344. if !ok {
  14345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14346. }
  14347. m.SetStatus(v)
  14348. return nil
  14349. case label.FieldType:
  14350. v, ok := value.(int)
  14351. if !ok {
  14352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14353. }
  14354. m.SetType(v)
  14355. return nil
  14356. case label.FieldName:
  14357. v, ok := value.(string)
  14358. if !ok {
  14359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14360. }
  14361. m.SetName(v)
  14362. return nil
  14363. case label.FieldFrom:
  14364. v, ok := value.(int)
  14365. if !ok {
  14366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14367. }
  14368. m.SetFrom(v)
  14369. return nil
  14370. case label.FieldMode:
  14371. v, ok := value.(int)
  14372. if !ok {
  14373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14374. }
  14375. m.SetMode(v)
  14376. return nil
  14377. case label.FieldConditions:
  14378. v, ok := value.(string)
  14379. if !ok {
  14380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14381. }
  14382. m.SetConditions(v)
  14383. return nil
  14384. case label.FieldOrganizationID:
  14385. v, ok := value.(uint64)
  14386. if !ok {
  14387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14388. }
  14389. m.SetOrganizationID(v)
  14390. return nil
  14391. }
  14392. return fmt.Errorf("unknown Label field %s", name)
  14393. }
  14394. // AddedFields returns all numeric fields that were incremented/decremented during
  14395. // this mutation.
  14396. func (m *LabelMutation) AddedFields() []string {
  14397. var fields []string
  14398. if m.addstatus != nil {
  14399. fields = append(fields, label.FieldStatus)
  14400. }
  14401. if m.add_type != nil {
  14402. fields = append(fields, label.FieldType)
  14403. }
  14404. if m.addfrom != nil {
  14405. fields = append(fields, label.FieldFrom)
  14406. }
  14407. if m.addmode != nil {
  14408. fields = append(fields, label.FieldMode)
  14409. }
  14410. if m.addorganization_id != nil {
  14411. fields = append(fields, label.FieldOrganizationID)
  14412. }
  14413. return fields
  14414. }
  14415. // AddedField returns the numeric value that was incremented/decremented on a field
  14416. // with the given name. The second boolean return value indicates that this field
  14417. // was not set, or was not defined in the schema.
  14418. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14419. switch name {
  14420. case label.FieldStatus:
  14421. return m.AddedStatus()
  14422. case label.FieldType:
  14423. return m.AddedType()
  14424. case label.FieldFrom:
  14425. return m.AddedFrom()
  14426. case label.FieldMode:
  14427. return m.AddedMode()
  14428. case label.FieldOrganizationID:
  14429. return m.AddedOrganizationID()
  14430. }
  14431. return nil, false
  14432. }
  14433. // AddField adds the value to the field with the given name. It returns an error if
  14434. // the field is not defined in the schema, or if the type mismatched the field
  14435. // type.
  14436. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14437. switch name {
  14438. case label.FieldStatus:
  14439. v, ok := value.(int8)
  14440. if !ok {
  14441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14442. }
  14443. m.AddStatus(v)
  14444. return nil
  14445. case label.FieldType:
  14446. v, ok := value.(int)
  14447. if !ok {
  14448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14449. }
  14450. m.AddType(v)
  14451. return nil
  14452. case label.FieldFrom:
  14453. v, ok := value.(int)
  14454. if !ok {
  14455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14456. }
  14457. m.AddFrom(v)
  14458. return nil
  14459. case label.FieldMode:
  14460. v, ok := value.(int)
  14461. if !ok {
  14462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14463. }
  14464. m.AddMode(v)
  14465. return nil
  14466. case label.FieldOrganizationID:
  14467. v, ok := value.(int64)
  14468. if !ok {
  14469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14470. }
  14471. m.AddOrganizationID(v)
  14472. return nil
  14473. }
  14474. return fmt.Errorf("unknown Label numeric field %s", name)
  14475. }
  14476. // ClearedFields returns all nullable fields that were cleared during this
  14477. // mutation.
  14478. func (m *LabelMutation) ClearedFields() []string {
  14479. var fields []string
  14480. if m.FieldCleared(label.FieldStatus) {
  14481. fields = append(fields, label.FieldStatus)
  14482. }
  14483. if m.FieldCleared(label.FieldConditions) {
  14484. fields = append(fields, label.FieldConditions)
  14485. }
  14486. if m.FieldCleared(label.FieldOrganizationID) {
  14487. fields = append(fields, label.FieldOrganizationID)
  14488. }
  14489. return fields
  14490. }
  14491. // FieldCleared returns a boolean indicating if a field with the given name was
  14492. // cleared in this mutation.
  14493. func (m *LabelMutation) FieldCleared(name string) bool {
  14494. _, ok := m.clearedFields[name]
  14495. return ok
  14496. }
  14497. // ClearField clears the value of the field with the given name. It returns an
  14498. // error if the field is not defined in the schema.
  14499. func (m *LabelMutation) ClearField(name string) error {
  14500. switch name {
  14501. case label.FieldStatus:
  14502. m.ClearStatus()
  14503. return nil
  14504. case label.FieldConditions:
  14505. m.ClearConditions()
  14506. return nil
  14507. case label.FieldOrganizationID:
  14508. m.ClearOrganizationID()
  14509. return nil
  14510. }
  14511. return fmt.Errorf("unknown Label nullable field %s", name)
  14512. }
  14513. // ResetField resets all changes in the mutation for the field with the given name.
  14514. // It returns an error if the field is not defined in the schema.
  14515. func (m *LabelMutation) ResetField(name string) error {
  14516. switch name {
  14517. case label.FieldCreatedAt:
  14518. m.ResetCreatedAt()
  14519. return nil
  14520. case label.FieldUpdatedAt:
  14521. m.ResetUpdatedAt()
  14522. return nil
  14523. case label.FieldStatus:
  14524. m.ResetStatus()
  14525. return nil
  14526. case label.FieldType:
  14527. m.ResetType()
  14528. return nil
  14529. case label.FieldName:
  14530. m.ResetName()
  14531. return nil
  14532. case label.FieldFrom:
  14533. m.ResetFrom()
  14534. return nil
  14535. case label.FieldMode:
  14536. m.ResetMode()
  14537. return nil
  14538. case label.FieldConditions:
  14539. m.ResetConditions()
  14540. return nil
  14541. case label.FieldOrganizationID:
  14542. m.ResetOrganizationID()
  14543. return nil
  14544. }
  14545. return fmt.Errorf("unknown Label field %s", name)
  14546. }
  14547. // AddedEdges returns all edge names that were set/added in this mutation.
  14548. func (m *LabelMutation) AddedEdges() []string {
  14549. edges := make([]string, 0, 1)
  14550. if m.label_relationships != nil {
  14551. edges = append(edges, label.EdgeLabelRelationships)
  14552. }
  14553. return edges
  14554. }
  14555. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14556. // name in this mutation.
  14557. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14558. switch name {
  14559. case label.EdgeLabelRelationships:
  14560. ids := make([]ent.Value, 0, len(m.label_relationships))
  14561. for id := range m.label_relationships {
  14562. ids = append(ids, id)
  14563. }
  14564. return ids
  14565. }
  14566. return nil
  14567. }
  14568. // RemovedEdges returns all edge names that were removed in this mutation.
  14569. func (m *LabelMutation) RemovedEdges() []string {
  14570. edges := make([]string, 0, 1)
  14571. if m.removedlabel_relationships != nil {
  14572. edges = append(edges, label.EdgeLabelRelationships)
  14573. }
  14574. return edges
  14575. }
  14576. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14577. // the given name in this mutation.
  14578. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14579. switch name {
  14580. case label.EdgeLabelRelationships:
  14581. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14582. for id := range m.removedlabel_relationships {
  14583. ids = append(ids, id)
  14584. }
  14585. return ids
  14586. }
  14587. return nil
  14588. }
  14589. // ClearedEdges returns all edge names that were cleared in this mutation.
  14590. func (m *LabelMutation) ClearedEdges() []string {
  14591. edges := make([]string, 0, 1)
  14592. if m.clearedlabel_relationships {
  14593. edges = append(edges, label.EdgeLabelRelationships)
  14594. }
  14595. return edges
  14596. }
  14597. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14598. // was cleared in this mutation.
  14599. func (m *LabelMutation) EdgeCleared(name string) bool {
  14600. switch name {
  14601. case label.EdgeLabelRelationships:
  14602. return m.clearedlabel_relationships
  14603. }
  14604. return false
  14605. }
  14606. // ClearEdge clears the value of the edge with the given name. It returns an error
  14607. // if that edge is not defined in the schema.
  14608. func (m *LabelMutation) ClearEdge(name string) error {
  14609. switch name {
  14610. }
  14611. return fmt.Errorf("unknown Label unique edge %s", name)
  14612. }
  14613. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14614. // It returns an error if the edge is not defined in the schema.
  14615. func (m *LabelMutation) ResetEdge(name string) error {
  14616. switch name {
  14617. case label.EdgeLabelRelationships:
  14618. m.ResetLabelRelationships()
  14619. return nil
  14620. }
  14621. return fmt.Errorf("unknown Label edge %s", name)
  14622. }
  14623. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14624. type LabelRelationshipMutation struct {
  14625. config
  14626. op Op
  14627. typ string
  14628. id *uint64
  14629. created_at *time.Time
  14630. updated_at *time.Time
  14631. status *uint8
  14632. addstatus *int8
  14633. organization_id *uint64
  14634. addorganization_id *int64
  14635. clearedFields map[string]struct{}
  14636. contacts *uint64
  14637. clearedcontacts bool
  14638. labels *uint64
  14639. clearedlabels bool
  14640. done bool
  14641. oldValue func(context.Context) (*LabelRelationship, error)
  14642. predicates []predicate.LabelRelationship
  14643. }
  14644. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14645. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14646. type labelrelationshipOption func(*LabelRelationshipMutation)
  14647. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14648. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14649. m := &LabelRelationshipMutation{
  14650. config: c,
  14651. op: op,
  14652. typ: TypeLabelRelationship,
  14653. clearedFields: make(map[string]struct{}),
  14654. }
  14655. for _, opt := range opts {
  14656. opt(m)
  14657. }
  14658. return m
  14659. }
  14660. // withLabelRelationshipID sets the ID field of the mutation.
  14661. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14662. return func(m *LabelRelationshipMutation) {
  14663. var (
  14664. err error
  14665. once sync.Once
  14666. value *LabelRelationship
  14667. )
  14668. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14669. once.Do(func() {
  14670. if m.done {
  14671. err = errors.New("querying old values post mutation is not allowed")
  14672. } else {
  14673. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14674. }
  14675. })
  14676. return value, err
  14677. }
  14678. m.id = &id
  14679. }
  14680. }
  14681. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14682. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14683. return func(m *LabelRelationshipMutation) {
  14684. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14685. return node, nil
  14686. }
  14687. m.id = &node.ID
  14688. }
  14689. }
  14690. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14691. // executed in a transaction (ent.Tx), a transactional client is returned.
  14692. func (m LabelRelationshipMutation) Client() *Client {
  14693. client := &Client{config: m.config}
  14694. client.init()
  14695. return client
  14696. }
  14697. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14698. // it returns an error otherwise.
  14699. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14700. if _, ok := m.driver.(*txDriver); !ok {
  14701. return nil, errors.New("ent: mutation is not running in a transaction")
  14702. }
  14703. tx := &Tx{config: m.config}
  14704. tx.init()
  14705. return tx, nil
  14706. }
  14707. // SetID sets the value of the id field. Note that this
  14708. // operation is only accepted on creation of LabelRelationship entities.
  14709. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14710. m.id = &id
  14711. }
  14712. // ID returns the ID value in the mutation. Note that the ID is only available
  14713. // if it was provided to the builder or after it was returned from the database.
  14714. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14715. if m.id == nil {
  14716. return
  14717. }
  14718. return *m.id, true
  14719. }
  14720. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14721. // That means, if the mutation is applied within a transaction with an isolation level such
  14722. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14723. // or updated by the mutation.
  14724. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14725. switch {
  14726. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14727. id, exists := m.ID()
  14728. if exists {
  14729. return []uint64{id}, nil
  14730. }
  14731. fallthrough
  14732. case m.op.Is(OpUpdate | OpDelete):
  14733. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14734. default:
  14735. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14736. }
  14737. }
  14738. // SetCreatedAt sets the "created_at" field.
  14739. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14740. m.created_at = &t
  14741. }
  14742. // CreatedAt returns the value of the "created_at" field in the mutation.
  14743. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14744. v := m.created_at
  14745. if v == nil {
  14746. return
  14747. }
  14748. return *v, true
  14749. }
  14750. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14751. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14753. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14754. if !m.op.Is(OpUpdateOne) {
  14755. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14756. }
  14757. if m.id == nil || m.oldValue == nil {
  14758. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14759. }
  14760. oldValue, err := m.oldValue(ctx)
  14761. if err != nil {
  14762. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14763. }
  14764. return oldValue.CreatedAt, nil
  14765. }
  14766. // ResetCreatedAt resets all changes to the "created_at" field.
  14767. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14768. m.created_at = nil
  14769. }
  14770. // SetUpdatedAt sets the "updated_at" field.
  14771. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14772. m.updated_at = &t
  14773. }
  14774. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14775. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14776. v := m.updated_at
  14777. if v == nil {
  14778. return
  14779. }
  14780. return *v, true
  14781. }
  14782. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14783. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14785. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14786. if !m.op.Is(OpUpdateOne) {
  14787. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14788. }
  14789. if m.id == nil || m.oldValue == nil {
  14790. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14791. }
  14792. oldValue, err := m.oldValue(ctx)
  14793. if err != nil {
  14794. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14795. }
  14796. return oldValue.UpdatedAt, nil
  14797. }
  14798. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14799. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14800. m.updated_at = nil
  14801. }
  14802. // SetStatus sets the "status" field.
  14803. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14804. m.status = &u
  14805. m.addstatus = nil
  14806. }
  14807. // Status returns the value of the "status" field in the mutation.
  14808. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14809. v := m.status
  14810. if v == nil {
  14811. return
  14812. }
  14813. return *v, true
  14814. }
  14815. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14816. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14818. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14819. if !m.op.Is(OpUpdateOne) {
  14820. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14821. }
  14822. if m.id == nil || m.oldValue == nil {
  14823. return v, errors.New("OldStatus requires an ID field in the mutation")
  14824. }
  14825. oldValue, err := m.oldValue(ctx)
  14826. if err != nil {
  14827. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14828. }
  14829. return oldValue.Status, nil
  14830. }
  14831. // AddStatus adds u to the "status" field.
  14832. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14833. if m.addstatus != nil {
  14834. *m.addstatus += u
  14835. } else {
  14836. m.addstatus = &u
  14837. }
  14838. }
  14839. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14840. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14841. v := m.addstatus
  14842. if v == nil {
  14843. return
  14844. }
  14845. return *v, true
  14846. }
  14847. // ClearStatus clears the value of the "status" field.
  14848. func (m *LabelRelationshipMutation) ClearStatus() {
  14849. m.status = nil
  14850. m.addstatus = nil
  14851. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14852. }
  14853. // StatusCleared returns if the "status" field was cleared in this mutation.
  14854. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14855. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14856. return ok
  14857. }
  14858. // ResetStatus resets all changes to the "status" field.
  14859. func (m *LabelRelationshipMutation) ResetStatus() {
  14860. m.status = nil
  14861. m.addstatus = nil
  14862. delete(m.clearedFields, labelrelationship.FieldStatus)
  14863. }
  14864. // SetLabelID sets the "label_id" field.
  14865. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14866. m.labels = &u
  14867. }
  14868. // LabelID returns the value of the "label_id" field in the mutation.
  14869. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14870. v := m.labels
  14871. if v == nil {
  14872. return
  14873. }
  14874. return *v, true
  14875. }
  14876. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14877. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14879. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14880. if !m.op.Is(OpUpdateOne) {
  14881. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14882. }
  14883. if m.id == nil || m.oldValue == nil {
  14884. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14885. }
  14886. oldValue, err := m.oldValue(ctx)
  14887. if err != nil {
  14888. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14889. }
  14890. return oldValue.LabelID, nil
  14891. }
  14892. // ResetLabelID resets all changes to the "label_id" field.
  14893. func (m *LabelRelationshipMutation) ResetLabelID() {
  14894. m.labels = nil
  14895. }
  14896. // SetContactID sets the "contact_id" field.
  14897. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14898. m.contacts = &u
  14899. }
  14900. // ContactID returns the value of the "contact_id" field in the mutation.
  14901. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14902. v := m.contacts
  14903. if v == nil {
  14904. return
  14905. }
  14906. return *v, true
  14907. }
  14908. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14909. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14911. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14912. if !m.op.Is(OpUpdateOne) {
  14913. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14914. }
  14915. if m.id == nil || m.oldValue == nil {
  14916. return v, errors.New("OldContactID requires an ID field in the mutation")
  14917. }
  14918. oldValue, err := m.oldValue(ctx)
  14919. if err != nil {
  14920. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14921. }
  14922. return oldValue.ContactID, nil
  14923. }
  14924. // ResetContactID resets all changes to the "contact_id" field.
  14925. func (m *LabelRelationshipMutation) ResetContactID() {
  14926. m.contacts = nil
  14927. }
  14928. // SetOrganizationID sets the "organization_id" field.
  14929. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14930. m.organization_id = &u
  14931. m.addorganization_id = nil
  14932. }
  14933. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14934. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14935. v := m.organization_id
  14936. if v == nil {
  14937. return
  14938. }
  14939. return *v, true
  14940. }
  14941. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14942. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14944. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14945. if !m.op.Is(OpUpdateOne) {
  14946. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14947. }
  14948. if m.id == nil || m.oldValue == nil {
  14949. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14950. }
  14951. oldValue, err := m.oldValue(ctx)
  14952. if err != nil {
  14953. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14954. }
  14955. return oldValue.OrganizationID, nil
  14956. }
  14957. // AddOrganizationID adds u to the "organization_id" field.
  14958. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14959. if m.addorganization_id != nil {
  14960. *m.addorganization_id += u
  14961. } else {
  14962. m.addorganization_id = &u
  14963. }
  14964. }
  14965. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14966. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14967. v := m.addorganization_id
  14968. if v == nil {
  14969. return
  14970. }
  14971. return *v, true
  14972. }
  14973. // ClearOrganizationID clears the value of the "organization_id" field.
  14974. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14975. m.organization_id = nil
  14976. m.addorganization_id = nil
  14977. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14978. }
  14979. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14980. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14981. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14982. return ok
  14983. }
  14984. // ResetOrganizationID resets all changes to the "organization_id" field.
  14985. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14986. m.organization_id = nil
  14987. m.addorganization_id = nil
  14988. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14989. }
  14990. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14991. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14992. m.contacts = &id
  14993. }
  14994. // ClearContacts clears the "contacts" edge to the Contact entity.
  14995. func (m *LabelRelationshipMutation) ClearContacts() {
  14996. m.clearedcontacts = true
  14997. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14998. }
  14999. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  15000. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  15001. return m.clearedcontacts
  15002. }
  15003. // ContactsID returns the "contacts" edge ID in the mutation.
  15004. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  15005. if m.contacts != nil {
  15006. return *m.contacts, true
  15007. }
  15008. return
  15009. }
  15010. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  15011. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15012. // ContactsID instead. It exists only for internal usage by the builders.
  15013. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  15014. if id := m.contacts; id != nil {
  15015. ids = append(ids, *id)
  15016. }
  15017. return
  15018. }
  15019. // ResetContacts resets all changes to the "contacts" edge.
  15020. func (m *LabelRelationshipMutation) ResetContacts() {
  15021. m.contacts = nil
  15022. m.clearedcontacts = false
  15023. }
  15024. // SetLabelsID sets the "labels" edge to the Label entity by id.
  15025. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  15026. m.labels = &id
  15027. }
  15028. // ClearLabels clears the "labels" edge to the Label entity.
  15029. func (m *LabelRelationshipMutation) ClearLabels() {
  15030. m.clearedlabels = true
  15031. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  15032. }
  15033. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  15034. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  15035. return m.clearedlabels
  15036. }
  15037. // LabelsID returns the "labels" edge ID in the mutation.
  15038. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15039. if m.labels != nil {
  15040. return *m.labels, true
  15041. }
  15042. return
  15043. }
  15044. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15045. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15046. // LabelsID instead. It exists only for internal usage by the builders.
  15047. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15048. if id := m.labels; id != nil {
  15049. ids = append(ids, *id)
  15050. }
  15051. return
  15052. }
  15053. // ResetLabels resets all changes to the "labels" edge.
  15054. func (m *LabelRelationshipMutation) ResetLabels() {
  15055. m.labels = nil
  15056. m.clearedlabels = false
  15057. }
  15058. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15059. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15060. m.predicates = append(m.predicates, ps...)
  15061. }
  15062. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15063. // users can use type-assertion to append predicates that do not depend on any generated package.
  15064. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15065. p := make([]predicate.LabelRelationship, len(ps))
  15066. for i := range ps {
  15067. p[i] = ps[i]
  15068. }
  15069. m.Where(p...)
  15070. }
  15071. // Op returns the operation name.
  15072. func (m *LabelRelationshipMutation) Op() Op {
  15073. return m.op
  15074. }
  15075. // SetOp allows setting the mutation operation.
  15076. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15077. m.op = op
  15078. }
  15079. // Type returns the node type of this mutation (LabelRelationship).
  15080. func (m *LabelRelationshipMutation) Type() string {
  15081. return m.typ
  15082. }
  15083. // Fields returns all fields that were changed during this mutation. Note that in
  15084. // order to get all numeric fields that were incremented/decremented, call
  15085. // AddedFields().
  15086. func (m *LabelRelationshipMutation) Fields() []string {
  15087. fields := make([]string, 0, 6)
  15088. if m.created_at != nil {
  15089. fields = append(fields, labelrelationship.FieldCreatedAt)
  15090. }
  15091. if m.updated_at != nil {
  15092. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15093. }
  15094. if m.status != nil {
  15095. fields = append(fields, labelrelationship.FieldStatus)
  15096. }
  15097. if m.labels != nil {
  15098. fields = append(fields, labelrelationship.FieldLabelID)
  15099. }
  15100. if m.contacts != nil {
  15101. fields = append(fields, labelrelationship.FieldContactID)
  15102. }
  15103. if m.organization_id != nil {
  15104. fields = append(fields, labelrelationship.FieldOrganizationID)
  15105. }
  15106. return fields
  15107. }
  15108. // Field returns the value of a field with the given name. The second boolean
  15109. // return value indicates that this field was not set, or was not defined in the
  15110. // schema.
  15111. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15112. switch name {
  15113. case labelrelationship.FieldCreatedAt:
  15114. return m.CreatedAt()
  15115. case labelrelationship.FieldUpdatedAt:
  15116. return m.UpdatedAt()
  15117. case labelrelationship.FieldStatus:
  15118. return m.Status()
  15119. case labelrelationship.FieldLabelID:
  15120. return m.LabelID()
  15121. case labelrelationship.FieldContactID:
  15122. return m.ContactID()
  15123. case labelrelationship.FieldOrganizationID:
  15124. return m.OrganizationID()
  15125. }
  15126. return nil, false
  15127. }
  15128. // OldField returns the old value of the field from the database. An error is
  15129. // returned if the mutation operation is not UpdateOne, or the query to the
  15130. // database failed.
  15131. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15132. switch name {
  15133. case labelrelationship.FieldCreatedAt:
  15134. return m.OldCreatedAt(ctx)
  15135. case labelrelationship.FieldUpdatedAt:
  15136. return m.OldUpdatedAt(ctx)
  15137. case labelrelationship.FieldStatus:
  15138. return m.OldStatus(ctx)
  15139. case labelrelationship.FieldLabelID:
  15140. return m.OldLabelID(ctx)
  15141. case labelrelationship.FieldContactID:
  15142. return m.OldContactID(ctx)
  15143. case labelrelationship.FieldOrganizationID:
  15144. return m.OldOrganizationID(ctx)
  15145. }
  15146. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15147. }
  15148. // SetField sets the value of a field with the given name. It returns an error if
  15149. // the field is not defined in the schema, or if the type mismatched the field
  15150. // type.
  15151. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15152. switch name {
  15153. case labelrelationship.FieldCreatedAt:
  15154. v, ok := value.(time.Time)
  15155. if !ok {
  15156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15157. }
  15158. m.SetCreatedAt(v)
  15159. return nil
  15160. case labelrelationship.FieldUpdatedAt:
  15161. v, ok := value.(time.Time)
  15162. if !ok {
  15163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15164. }
  15165. m.SetUpdatedAt(v)
  15166. return nil
  15167. case labelrelationship.FieldStatus:
  15168. v, ok := value.(uint8)
  15169. if !ok {
  15170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15171. }
  15172. m.SetStatus(v)
  15173. return nil
  15174. case labelrelationship.FieldLabelID:
  15175. v, ok := value.(uint64)
  15176. if !ok {
  15177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15178. }
  15179. m.SetLabelID(v)
  15180. return nil
  15181. case labelrelationship.FieldContactID:
  15182. v, ok := value.(uint64)
  15183. if !ok {
  15184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15185. }
  15186. m.SetContactID(v)
  15187. return nil
  15188. case labelrelationship.FieldOrganizationID:
  15189. v, ok := value.(uint64)
  15190. if !ok {
  15191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15192. }
  15193. m.SetOrganizationID(v)
  15194. return nil
  15195. }
  15196. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15197. }
  15198. // AddedFields returns all numeric fields that were incremented/decremented during
  15199. // this mutation.
  15200. func (m *LabelRelationshipMutation) AddedFields() []string {
  15201. var fields []string
  15202. if m.addstatus != nil {
  15203. fields = append(fields, labelrelationship.FieldStatus)
  15204. }
  15205. if m.addorganization_id != nil {
  15206. fields = append(fields, labelrelationship.FieldOrganizationID)
  15207. }
  15208. return fields
  15209. }
  15210. // AddedField returns the numeric value that was incremented/decremented on a field
  15211. // with the given name. The second boolean return value indicates that this field
  15212. // was not set, or was not defined in the schema.
  15213. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15214. switch name {
  15215. case labelrelationship.FieldStatus:
  15216. return m.AddedStatus()
  15217. case labelrelationship.FieldOrganizationID:
  15218. return m.AddedOrganizationID()
  15219. }
  15220. return nil, false
  15221. }
  15222. // AddField adds the value to the field with the given name. It returns an error if
  15223. // the field is not defined in the schema, or if the type mismatched the field
  15224. // type.
  15225. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15226. switch name {
  15227. case labelrelationship.FieldStatus:
  15228. v, ok := value.(int8)
  15229. if !ok {
  15230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15231. }
  15232. m.AddStatus(v)
  15233. return nil
  15234. case labelrelationship.FieldOrganizationID:
  15235. v, ok := value.(int64)
  15236. if !ok {
  15237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15238. }
  15239. m.AddOrganizationID(v)
  15240. return nil
  15241. }
  15242. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15243. }
  15244. // ClearedFields returns all nullable fields that were cleared during this
  15245. // mutation.
  15246. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15247. var fields []string
  15248. if m.FieldCleared(labelrelationship.FieldStatus) {
  15249. fields = append(fields, labelrelationship.FieldStatus)
  15250. }
  15251. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15252. fields = append(fields, labelrelationship.FieldOrganizationID)
  15253. }
  15254. return fields
  15255. }
  15256. // FieldCleared returns a boolean indicating if a field with the given name was
  15257. // cleared in this mutation.
  15258. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15259. _, ok := m.clearedFields[name]
  15260. return ok
  15261. }
  15262. // ClearField clears the value of the field with the given name. It returns an
  15263. // error if the field is not defined in the schema.
  15264. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15265. switch name {
  15266. case labelrelationship.FieldStatus:
  15267. m.ClearStatus()
  15268. return nil
  15269. case labelrelationship.FieldOrganizationID:
  15270. m.ClearOrganizationID()
  15271. return nil
  15272. }
  15273. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15274. }
  15275. // ResetField resets all changes in the mutation for the field with the given name.
  15276. // It returns an error if the field is not defined in the schema.
  15277. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15278. switch name {
  15279. case labelrelationship.FieldCreatedAt:
  15280. m.ResetCreatedAt()
  15281. return nil
  15282. case labelrelationship.FieldUpdatedAt:
  15283. m.ResetUpdatedAt()
  15284. return nil
  15285. case labelrelationship.FieldStatus:
  15286. m.ResetStatus()
  15287. return nil
  15288. case labelrelationship.FieldLabelID:
  15289. m.ResetLabelID()
  15290. return nil
  15291. case labelrelationship.FieldContactID:
  15292. m.ResetContactID()
  15293. return nil
  15294. case labelrelationship.FieldOrganizationID:
  15295. m.ResetOrganizationID()
  15296. return nil
  15297. }
  15298. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15299. }
  15300. // AddedEdges returns all edge names that were set/added in this mutation.
  15301. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15302. edges := make([]string, 0, 2)
  15303. if m.contacts != nil {
  15304. edges = append(edges, labelrelationship.EdgeContacts)
  15305. }
  15306. if m.labels != nil {
  15307. edges = append(edges, labelrelationship.EdgeLabels)
  15308. }
  15309. return edges
  15310. }
  15311. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15312. // name in this mutation.
  15313. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15314. switch name {
  15315. case labelrelationship.EdgeContacts:
  15316. if id := m.contacts; id != nil {
  15317. return []ent.Value{*id}
  15318. }
  15319. case labelrelationship.EdgeLabels:
  15320. if id := m.labels; id != nil {
  15321. return []ent.Value{*id}
  15322. }
  15323. }
  15324. return nil
  15325. }
  15326. // RemovedEdges returns all edge names that were removed in this mutation.
  15327. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15328. edges := make([]string, 0, 2)
  15329. return edges
  15330. }
  15331. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15332. // the given name in this mutation.
  15333. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15334. return nil
  15335. }
  15336. // ClearedEdges returns all edge names that were cleared in this mutation.
  15337. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15338. edges := make([]string, 0, 2)
  15339. if m.clearedcontacts {
  15340. edges = append(edges, labelrelationship.EdgeContacts)
  15341. }
  15342. if m.clearedlabels {
  15343. edges = append(edges, labelrelationship.EdgeLabels)
  15344. }
  15345. return edges
  15346. }
  15347. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15348. // was cleared in this mutation.
  15349. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15350. switch name {
  15351. case labelrelationship.EdgeContacts:
  15352. return m.clearedcontacts
  15353. case labelrelationship.EdgeLabels:
  15354. return m.clearedlabels
  15355. }
  15356. return false
  15357. }
  15358. // ClearEdge clears the value of the edge with the given name. It returns an error
  15359. // if that edge is not defined in the schema.
  15360. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15361. switch name {
  15362. case labelrelationship.EdgeContacts:
  15363. m.ClearContacts()
  15364. return nil
  15365. case labelrelationship.EdgeLabels:
  15366. m.ClearLabels()
  15367. return nil
  15368. }
  15369. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15370. }
  15371. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15372. // It returns an error if the edge is not defined in the schema.
  15373. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15374. switch name {
  15375. case labelrelationship.EdgeContacts:
  15376. m.ResetContacts()
  15377. return nil
  15378. case labelrelationship.EdgeLabels:
  15379. m.ResetLabels()
  15380. return nil
  15381. }
  15382. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15383. }
  15384. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15385. type LabelTaggingMutation struct {
  15386. config
  15387. op Op
  15388. typ string
  15389. id *uint64
  15390. created_at *time.Time
  15391. updated_at *time.Time
  15392. status *uint8
  15393. addstatus *int8
  15394. deleted_at *time.Time
  15395. organization_id *uint64
  15396. addorganization_id *int64
  15397. _type *int
  15398. add_type *int
  15399. conditions *string
  15400. action_label_add *[]uint64
  15401. appendaction_label_add []uint64
  15402. action_label_del *[]uint64
  15403. appendaction_label_del []uint64
  15404. clearedFields map[string]struct{}
  15405. done bool
  15406. oldValue func(context.Context) (*LabelTagging, error)
  15407. predicates []predicate.LabelTagging
  15408. }
  15409. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15410. // labeltaggingOption allows management of the mutation configuration using functional options.
  15411. type labeltaggingOption func(*LabelTaggingMutation)
  15412. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15413. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15414. m := &LabelTaggingMutation{
  15415. config: c,
  15416. op: op,
  15417. typ: TypeLabelTagging,
  15418. clearedFields: make(map[string]struct{}),
  15419. }
  15420. for _, opt := range opts {
  15421. opt(m)
  15422. }
  15423. return m
  15424. }
  15425. // withLabelTaggingID sets the ID field of the mutation.
  15426. func withLabelTaggingID(id uint64) labeltaggingOption {
  15427. return func(m *LabelTaggingMutation) {
  15428. var (
  15429. err error
  15430. once sync.Once
  15431. value *LabelTagging
  15432. )
  15433. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15434. once.Do(func() {
  15435. if m.done {
  15436. err = errors.New("querying old values post mutation is not allowed")
  15437. } else {
  15438. value, err = m.Client().LabelTagging.Get(ctx, id)
  15439. }
  15440. })
  15441. return value, err
  15442. }
  15443. m.id = &id
  15444. }
  15445. }
  15446. // withLabelTagging sets the old LabelTagging of the mutation.
  15447. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15448. return func(m *LabelTaggingMutation) {
  15449. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15450. return node, nil
  15451. }
  15452. m.id = &node.ID
  15453. }
  15454. }
  15455. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15456. // executed in a transaction (ent.Tx), a transactional client is returned.
  15457. func (m LabelTaggingMutation) Client() *Client {
  15458. client := &Client{config: m.config}
  15459. client.init()
  15460. return client
  15461. }
  15462. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15463. // it returns an error otherwise.
  15464. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15465. if _, ok := m.driver.(*txDriver); !ok {
  15466. return nil, errors.New("ent: mutation is not running in a transaction")
  15467. }
  15468. tx := &Tx{config: m.config}
  15469. tx.init()
  15470. return tx, nil
  15471. }
  15472. // SetID sets the value of the id field. Note that this
  15473. // operation is only accepted on creation of LabelTagging entities.
  15474. func (m *LabelTaggingMutation) SetID(id uint64) {
  15475. m.id = &id
  15476. }
  15477. // ID returns the ID value in the mutation. Note that the ID is only available
  15478. // if it was provided to the builder or after it was returned from the database.
  15479. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15480. if m.id == nil {
  15481. return
  15482. }
  15483. return *m.id, true
  15484. }
  15485. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15486. // That means, if the mutation is applied within a transaction with an isolation level such
  15487. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15488. // or updated by the mutation.
  15489. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15490. switch {
  15491. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15492. id, exists := m.ID()
  15493. if exists {
  15494. return []uint64{id}, nil
  15495. }
  15496. fallthrough
  15497. case m.op.Is(OpUpdate | OpDelete):
  15498. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15499. default:
  15500. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15501. }
  15502. }
  15503. // SetCreatedAt sets the "created_at" field.
  15504. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15505. m.created_at = &t
  15506. }
  15507. // CreatedAt returns the value of the "created_at" field in the mutation.
  15508. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15509. v := m.created_at
  15510. if v == nil {
  15511. return
  15512. }
  15513. return *v, true
  15514. }
  15515. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15516. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15518. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15519. if !m.op.Is(OpUpdateOne) {
  15520. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15521. }
  15522. if m.id == nil || m.oldValue == nil {
  15523. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15524. }
  15525. oldValue, err := m.oldValue(ctx)
  15526. if err != nil {
  15527. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15528. }
  15529. return oldValue.CreatedAt, nil
  15530. }
  15531. // ResetCreatedAt resets all changes to the "created_at" field.
  15532. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15533. m.created_at = nil
  15534. }
  15535. // SetUpdatedAt sets the "updated_at" field.
  15536. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15537. m.updated_at = &t
  15538. }
  15539. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15540. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15541. v := m.updated_at
  15542. if v == nil {
  15543. return
  15544. }
  15545. return *v, true
  15546. }
  15547. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15548. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15550. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15551. if !m.op.Is(OpUpdateOne) {
  15552. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15553. }
  15554. if m.id == nil || m.oldValue == nil {
  15555. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15556. }
  15557. oldValue, err := m.oldValue(ctx)
  15558. if err != nil {
  15559. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15560. }
  15561. return oldValue.UpdatedAt, nil
  15562. }
  15563. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15564. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15565. m.updated_at = nil
  15566. }
  15567. // SetStatus sets the "status" field.
  15568. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15569. m.status = &u
  15570. m.addstatus = nil
  15571. }
  15572. // Status returns the value of the "status" field in the mutation.
  15573. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15574. v := m.status
  15575. if v == nil {
  15576. return
  15577. }
  15578. return *v, true
  15579. }
  15580. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15581. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15583. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15584. if !m.op.Is(OpUpdateOne) {
  15585. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15586. }
  15587. if m.id == nil || m.oldValue == nil {
  15588. return v, errors.New("OldStatus requires an ID field in the mutation")
  15589. }
  15590. oldValue, err := m.oldValue(ctx)
  15591. if err != nil {
  15592. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15593. }
  15594. return oldValue.Status, nil
  15595. }
  15596. // AddStatus adds u to the "status" field.
  15597. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15598. if m.addstatus != nil {
  15599. *m.addstatus += u
  15600. } else {
  15601. m.addstatus = &u
  15602. }
  15603. }
  15604. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15605. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15606. v := m.addstatus
  15607. if v == nil {
  15608. return
  15609. }
  15610. return *v, true
  15611. }
  15612. // ClearStatus clears the value of the "status" field.
  15613. func (m *LabelTaggingMutation) ClearStatus() {
  15614. m.status = nil
  15615. m.addstatus = nil
  15616. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15617. }
  15618. // StatusCleared returns if the "status" field was cleared in this mutation.
  15619. func (m *LabelTaggingMutation) StatusCleared() bool {
  15620. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15621. return ok
  15622. }
  15623. // ResetStatus resets all changes to the "status" field.
  15624. func (m *LabelTaggingMutation) ResetStatus() {
  15625. m.status = nil
  15626. m.addstatus = nil
  15627. delete(m.clearedFields, labeltagging.FieldStatus)
  15628. }
  15629. // SetDeletedAt sets the "deleted_at" field.
  15630. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15631. m.deleted_at = &t
  15632. }
  15633. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15634. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15635. v := m.deleted_at
  15636. if v == nil {
  15637. return
  15638. }
  15639. return *v, true
  15640. }
  15641. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15642. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15644. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15645. if !m.op.Is(OpUpdateOne) {
  15646. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15647. }
  15648. if m.id == nil || m.oldValue == nil {
  15649. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15650. }
  15651. oldValue, err := m.oldValue(ctx)
  15652. if err != nil {
  15653. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15654. }
  15655. return oldValue.DeletedAt, nil
  15656. }
  15657. // ClearDeletedAt clears the value of the "deleted_at" field.
  15658. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15659. m.deleted_at = nil
  15660. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15661. }
  15662. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15663. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15664. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15665. return ok
  15666. }
  15667. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15668. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15669. m.deleted_at = nil
  15670. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15671. }
  15672. // SetOrganizationID sets the "organization_id" field.
  15673. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15674. m.organization_id = &u
  15675. m.addorganization_id = nil
  15676. }
  15677. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15678. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15679. v := m.organization_id
  15680. if v == nil {
  15681. return
  15682. }
  15683. return *v, true
  15684. }
  15685. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15686. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15688. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15689. if !m.op.Is(OpUpdateOne) {
  15690. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15691. }
  15692. if m.id == nil || m.oldValue == nil {
  15693. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15694. }
  15695. oldValue, err := m.oldValue(ctx)
  15696. if err != nil {
  15697. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15698. }
  15699. return oldValue.OrganizationID, nil
  15700. }
  15701. // AddOrganizationID adds u to the "organization_id" field.
  15702. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15703. if m.addorganization_id != nil {
  15704. *m.addorganization_id += u
  15705. } else {
  15706. m.addorganization_id = &u
  15707. }
  15708. }
  15709. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15710. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15711. v := m.addorganization_id
  15712. if v == nil {
  15713. return
  15714. }
  15715. return *v, true
  15716. }
  15717. // ResetOrganizationID resets all changes to the "organization_id" field.
  15718. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15719. m.organization_id = nil
  15720. m.addorganization_id = nil
  15721. }
  15722. // SetType sets the "type" field.
  15723. func (m *LabelTaggingMutation) SetType(i int) {
  15724. m._type = &i
  15725. m.add_type = nil
  15726. }
  15727. // GetType returns the value of the "type" field in the mutation.
  15728. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15729. v := m._type
  15730. if v == nil {
  15731. return
  15732. }
  15733. return *v, true
  15734. }
  15735. // OldType returns the old "type" field's value of the LabelTagging entity.
  15736. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15738. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15739. if !m.op.Is(OpUpdateOne) {
  15740. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15741. }
  15742. if m.id == nil || m.oldValue == nil {
  15743. return v, errors.New("OldType requires an ID field in the mutation")
  15744. }
  15745. oldValue, err := m.oldValue(ctx)
  15746. if err != nil {
  15747. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15748. }
  15749. return oldValue.Type, nil
  15750. }
  15751. // AddType adds i to the "type" field.
  15752. func (m *LabelTaggingMutation) AddType(i int) {
  15753. if m.add_type != nil {
  15754. *m.add_type += i
  15755. } else {
  15756. m.add_type = &i
  15757. }
  15758. }
  15759. // AddedType returns the value that was added to the "type" field in this mutation.
  15760. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15761. v := m.add_type
  15762. if v == nil {
  15763. return
  15764. }
  15765. return *v, true
  15766. }
  15767. // ResetType resets all changes to the "type" field.
  15768. func (m *LabelTaggingMutation) ResetType() {
  15769. m._type = nil
  15770. m.add_type = nil
  15771. }
  15772. // SetConditions sets the "conditions" field.
  15773. func (m *LabelTaggingMutation) SetConditions(s string) {
  15774. m.conditions = &s
  15775. }
  15776. // Conditions returns the value of the "conditions" field in the mutation.
  15777. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15778. v := m.conditions
  15779. if v == nil {
  15780. return
  15781. }
  15782. return *v, true
  15783. }
  15784. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15785. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15787. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15788. if !m.op.Is(OpUpdateOne) {
  15789. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15790. }
  15791. if m.id == nil || m.oldValue == nil {
  15792. return v, errors.New("OldConditions requires an ID field in the mutation")
  15793. }
  15794. oldValue, err := m.oldValue(ctx)
  15795. if err != nil {
  15796. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15797. }
  15798. return oldValue.Conditions, nil
  15799. }
  15800. // ResetConditions resets all changes to the "conditions" field.
  15801. func (m *LabelTaggingMutation) ResetConditions() {
  15802. m.conditions = nil
  15803. }
  15804. // SetActionLabelAdd sets the "action_label_add" field.
  15805. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15806. m.action_label_add = &u
  15807. m.appendaction_label_add = nil
  15808. }
  15809. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15810. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15811. v := m.action_label_add
  15812. if v == nil {
  15813. return
  15814. }
  15815. return *v, true
  15816. }
  15817. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15818. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15820. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15821. if !m.op.Is(OpUpdateOne) {
  15822. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15823. }
  15824. if m.id == nil || m.oldValue == nil {
  15825. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15826. }
  15827. oldValue, err := m.oldValue(ctx)
  15828. if err != nil {
  15829. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15830. }
  15831. return oldValue.ActionLabelAdd, nil
  15832. }
  15833. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15834. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15835. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15836. }
  15837. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15838. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15839. if len(m.appendaction_label_add) == 0 {
  15840. return nil, false
  15841. }
  15842. return m.appendaction_label_add, true
  15843. }
  15844. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15845. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15846. m.action_label_add = nil
  15847. m.appendaction_label_add = nil
  15848. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15849. }
  15850. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15851. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15852. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15853. return ok
  15854. }
  15855. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15856. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15857. m.action_label_add = nil
  15858. m.appendaction_label_add = nil
  15859. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15860. }
  15861. // SetActionLabelDel sets the "action_label_del" field.
  15862. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15863. m.action_label_del = &u
  15864. m.appendaction_label_del = nil
  15865. }
  15866. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15867. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15868. v := m.action_label_del
  15869. if v == nil {
  15870. return
  15871. }
  15872. return *v, true
  15873. }
  15874. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15875. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15877. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15878. if !m.op.Is(OpUpdateOne) {
  15879. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15880. }
  15881. if m.id == nil || m.oldValue == nil {
  15882. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15883. }
  15884. oldValue, err := m.oldValue(ctx)
  15885. if err != nil {
  15886. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15887. }
  15888. return oldValue.ActionLabelDel, nil
  15889. }
  15890. // AppendActionLabelDel adds u to the "action_label_del" field.
  15891. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15892. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15893. }
  15894. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15895. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15896. if len(m.appendaction_label_del) == 0 {
  15897. return nil, false
  15898. }
  15899. return m.appendaction_label_del, true
  15900. }
  15901. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15902. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15903. m.action_label_del = nil
  15904. m.appendaction_label_del = nil
  15905. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15906. }
  15907. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15908. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15909. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15910. return ok
  15911. }
  15912. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15913. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15914. m.action_label_del = nil
  15915. m.appendaction_label_del = nil
  15916. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15917. }
  15918. // Where appends a list predicates to the LabelTaggingMutation builder.
  15919. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15920. m.predicates = append(m.predicates, ps...)
  15921. }
  15922. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15923. // users can use type-assertion to append predicates that do not depend on any generated package.
  15924. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15925. p := make([]predicate.LabelTagging, len(ps))
  15926. for i := range ps {
  15927. p[i] = ps[i]
  15928. }
  15929. m.Where(p...)
  15930. }
  15931. // Op returns the operation name.
  15932. func (m *LabelTaggingMutation) Op() Op {
  15933. return m.op
  15934. }
  15935. // SetOp allows setting the mutation operation.
  15936. func (m *LabelTaggingMutation) SetOp(op Op) {
  15937. m.op = op
  15938. }
  15939. // Type returns the node type of this mutation (LabelTagging).
  15940. func (m *LabelTaggingMutation) Type() string {
  15941. return m.typ
  15942. }
  15943. // Fields returns all fields that were changed during this mutation. Note that in
  15944. // order to get all numeric fields that were incremented/decremented, call
  15945. // AddedFields().
  15946. func (m *LabelTaggingMutation) Fields() []string {
  15947. fields := make([]string, 0, 9)
  15948. if m.created_at != nil {
  15949. fields = append(fields, labeltagging.FieldCreatedAt)
  15950. }
  15951. if m.updated_at != nil {
  15952. fields = append(fields, labeltagging.FieldUpdatedAt)
  15953. }
  15954. if m.status != nil {
  15955. fields = append(fields, labeltagging.FieldStatus)
  15956. }
  15957. if m.deleted_at != nil {
  15958. fields = append(fields, labeltagging.FieldDeletedAt)
  15959. }
  15960. if m.organization_id != nil {
  15961. fields = append(fields, labeltagging.FieldOrganizationID)
  15962. }
  15963. if m._type != nil {
  15964. fields = append(fields, labeltagging.FieldType)
  15965. }
  15966. if m.conditions != nil {
  15967. fields = append(fields, labeltagging.FieldConditions)
  15968. }
  15969. if m.action_label_add != nil {
  15970. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15971. }
  15972. if m.action_label_del != nil {
  15973. fields = append(fields, labeltagging.FieldActionLabelDel)
  15974. }
  15975. return fields
  15976. }
  15977. // Field returns the value of a field with the given name. The second boolean
  15978. // return value indicates that this field was not set, or was not defined in the
  15979. // schema.
  15980. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15981. switch name {
  15982. case labeltagging.FieldCreatedAt:
  15983. return m.CreatedAt()
  15984. case labeltagging.FieldUpdatedAt:
  15985. return m.UpdatedAt()
  15986. case labeltagging.FieldStatus:
  15987. return m.Status()
  15988. case labeltagging.FieldDeletedAt:
  15989. return m.DeletedAt()
  15990. case labeltagging.FieldOrganizationID:
  15991. return m.OrganizationID()
  15992. case labeltagging.FieldType:
  15993. return m.GetType()
  15994. case labeltagging.FieldConditions:
  15995. return m.Conditions()
  15996. case labeltagging.FieldActionLabelAdd:
  15997. return m.ActionLabelAdd()
  15998. case labeltagging.FieldActionLabelDel:
  15999. return m.ActionLabelDel()
  16000. }
  16001. return nil, false
  16002. }
  16003. // OldField returns the old value of the field from the database. An error is
  16004. // returned if the mutation operation is not UpdateOne, or the query to the
  16005. // database failed.
  16006. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16007. switch name {
  16008. case labeltagging.FieldCreatedAt:
  16009. return m.OldCreatedAt(ctx)
  16010. case labeltagging.FieldUpdatedAt:
  16011. return m.OldUpdatedAt(ctx)
  16012. case labeltagging.FieldStatus:
  16013. return m.OldStatus(ctx)
  16014. case labeltagging.FieldDeletedAt:
  16015. return m.OldDeletedAt(ctx)
  16016. case labeltagging.FieldOrganizationID:
  16017. return m.OldOrganizationID(ctx)
  16018. case labeltagging.FieldType:
  16019. return m.OldType(ctx)
  16020. case labeltagging.FieldConditions:
  16021. return m.OldConditions(ctx)
  16022. case labeltagging.FieldActionLabelAdd:
  16023. return m.OldActionLabelAdd(ctx)
  16024. case labeltagging.FieldActionLabelDel:
  16025. return m.OldActionLabelDel(ctx)
  16026. }
  16027. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  16028. }
  16029. // SetField sets the value of a field with the given name. It returns an error if
  16030. // the field is not defined in the schema, or if the type mismatched the field
  16031. // type.
  16032. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  16033. switch name {
  16034. case labeltagging.FieldCreatedAt:
  16035. v, ok := value.(time.Time)
  16036. if !ok {
  16037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16038. }
  16039. m.SetCreatedAt(v)
  16040. return nil
  16041. case labeltagging.FieldUpdatedAt:
  16042. v, ok := value.(time.Time)
  16043. if !ok {
  16044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16045. }
  16046. m.SetUpdatedAt(v)
  16047. return nil
  16048. case labeltagging.FieldStatus:
  16049. v, ok := value.(uint8)
  16050. if !ok {
  16051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16052. }
  16053. m.SetStatus(v)
  16054. return nil
  16055. case labeltagging.FieldDeletedAt:
  16056. v, ok := value.(time.Time)
  16057. if !ok {
  16058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16059. }
  16060. m.SetDeletedAt(v)
  16061. return nil
  16062. case labeltagging.FieldOrganizationID:
  16063. v, ok := value.(uint64)
  16064. if !ok {
  16065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16066. }
  16067. m.SetOrganizationID(v)
  16068. return nil
  16069. case labeltagging.FieldType:
  16070. v, ok := value.(int)
  16071. if !ok {
  16072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16073. }
  16074. m.SetType(v)
  16075. return nil
  16076. case labeltagging.FieldConditions:
  16077. v, ok := value.(string)
  16078. if !ok {
  16079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16080. }
  16081. m.SetConditions(v)
  16082. return nil
  16083. case labeltagging.FieldActionLabelAdd:
  16084. v, ok := value.([]uint64)
  16085. if !ok {
  16086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16087. }
  16088. m.SetActionLabelAdd(v)
  16089. return nil
  16090. case labeltagging.FieldActionLabelDel:
  16091. v, ok := value.([]uint64)
  16092. if !ok {
  16093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16094. }
  16095. m.SetActionLabelDel(v)
  16096. return nil
  16097. }
  16098. return fmt.Errorf("unknown LabelTagging field %s", name)
  16099. }
  16100. // AddedFields returns all numeric fields that were incremented/decremented during
  16101. // this mutation.
  16102. func (m *LabelTaggingMutation) AddedFields() []string {
  16103. var fields []string
  16104. if m.addstatus != nil {
  16105. fields = append(fields, labeltagging.FieldStatus)
  16106. }
  16107. if m.addorganization_id != nil {
  16108. fields = append(fields, labeltagging.FieldOrganizationID)
  16109. }
  16110. if m.add_type != nil {
  16111. fields = append(fields, labeltagging.FieldType)
  16112. }
  16113. return fields
  16114. }
  16115. // AddedField returns the numeric value that was incremented/decremented on a field
  16116. // with the given name. The second boolean return value indicates that this field
  16117. // was not set, or was not defined in the schema.
  16118. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16119. switch name {
  16120. case labeltagging.FieldStatus:
  16121. return m.AddedStatus()
  16122. case labeltagging.FieldOrganizationID:
  16123. return m.AddedOrganizationID()
  16124. case labeltagging.FieldType:
  16125. return m.AddedType()
  16126. }
  16127. return nil, false
  16128. }
  16129. // AddField adds the value to the field with the given name. It returns an error if
  16130. // the field is not defined in the schema, or if the type mismatched the field
  16131. // type.
  16132. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16133. switch name {
  16134. case labeltagging.FieldStatus:
  16135. v, ok := value.(int8)
  16136. if !ok {
  16137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16138. }
  16139. m.AddStatus(v)
  16140. return nil
  16141. case labeltagging.FieldOrganizationID:
  16142. v, ok := value.(int64)
  16143. if !ok {
  16144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16145. }
  16146. m.AddOrganizationID(v)
  16147. return nil
  16148. case labeltagging.FieldType:
  16149. v, ok := value.(int)
  16150. if !ok {
  16151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16152. }
  16153. m.AddType(v)
  16154. return nil
  16155. }
  16156. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16157. }
  16158. // ClearedFields returns all nullable fields that were cleared during this
  16159. // mutation.
  16160. func (m *LabelTaggingMutation) ClearedFields() []string {
  16161. var fields []string
  16162. if m.FieldCleared(labeltagging.FieldStatus) {
  16163. fields = append(fields, labeltagging.FieldStatus)
  16164. }
  16165. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16166. fields = append(fields, labeltagging.FieldDeletedAt)
  16167. }
  16168. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16169. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16170. }
  16171. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16172. fields = append(fields, labeltagging.FieldActionLabelDel)
  16173. }
  16174. return fields
  16175. }
  16176. // FieldCleared returns a boolean indicating if a field with the given name was
  16177. // cleared in this mutation.
  16178. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16179. _, ok := m.clearedFields[name]
  16180. return ok
  16181. }
  16182. // ClearField clears the value of the field with the given name. It returns an
  16183. // error if the field is not defined in the schema.
  16184. func (m *LabelTaggingMutation) ClearField(name string) error {
  16185. switch name {
  16186. case labeltagging.FieldStatus:
  16187. m.ClearStatus()
  16188. return nil
  16189. case labeltagging.FieldDeletedAt:
  16190. m.ClearDeletedAt()
  16191. return nil
  16192. case labeltagging.FieldActionLabelAdd:
  16193. m.ClearActionLabelAdd()
  16194. return nil
  16195. case labeltagging.FieldActionLabelDel:
  16196. m.ClearActionLabelDel()
  16197. return nil
  16198. }
  16199. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16200. }
  16201. // ResetField resets all changes in the mutation for the field with the given name.
  16202. // It returns an error if the field is not defined in the schema.
  16203. func (m *LabelTaggingMutation) ResetField(name string) error {
  16204. switch name {
  16205. case labeltagging.FieldCreatedAt:
  16206. m.ResetCreatedAt()
  16207. return nil
  16208. case labeltagging.FieldUpdatedAt:
  16209. m.ResetUpdatedAt()
  16210. return nil
  16211. case labeltagging.FieldStatus:
  16212. m.ResetStatus()
  16213. return nil
  16214. case labeltagging.FieldDeletedAt:
  16215. m.ResetDeletedAt()
  16216. return nil
  16217. case labeltagging.FieldOrganizationID:
  16218. m.ResetOrganizationID()
  16219. return nil
  16220. case labeltagging.FieldType:
  16221. m.ResetType()
  16222. return nil
  16223. case labeltagging.FieldConditions:
  16224. m.ResetConditions()
  16225. return nil
  16226. case labeltagging.FieldActionLabelAdd:
  16227. m.ResetActionLabelAdd()
  16228. return nil
  16229. case labeltagging.FieldActionLabelDel:
  16230. m.ResetActionLabelDel()
  16231. return nil
  16232. }
  16233. return fmt.Errorf("unknown LabelTagging field %s", name)
  16234. }
  16235. // AddedEdges returns all edge names that were set/added in this mutation.
  16236. func (m *LabelTaggingMutation) AddedEdges() []string {
  16237. edges := make([]string, 0, 0)
  16238. return edges
  16239. }
  16240. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16241. // name in this mutation.
  16242. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16243. return nil
  16244. }
  16245. // RemovedEdges returns all edge names that were removed in this mutation.
  16246. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16247. edges := make([]string, 0, 0)
  16248. return edges
  16249. }
  16250. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16251. // the given name in this mutation.
  16252. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16253. return nil
  16254. }
  16255. // ClearedEdges returns all edge names that were cleared in this mutation.
  16256. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16257. edges := make([]string, 0, 0)
  16258. return edges
  16259. }
  16260. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16261. // was cleared in this mutation.
  16262. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16263. return false
  16264. }
  16265. // ClearEdge clears the value of the edge with the given name. It returns an error
  16266. // if that edge is not defined in the schema.
  16267. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16268. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16269. }
  16270. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16271. // It returns an error if the edge is not defined in the schema.
  16272. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16273. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16274. }
  16275. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16276. type MessageMutation struct {
  16277. config
  16278. op Op
  16279. typ string
  16280. id *int
  16281. wx_wxid *string
  16282. wxid *string
  16283. content *string
  16284. clearedFields map[string]struct{}
  16285. done bool
  16286. oldValue func(context.Context) (*Message, error)
  16287. predicates []predicate.Message
  16288. }
  16289. var _ ent.Mutation = (*MessageMutation)(nil)
  16290. // messageOption allows management of the mutation configuration using functional options.
  16291. type messageOption func(*MessageMutation)
  16292. // newMessageMutation creates new mutation for the Message entity.
  16293. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16294. m := &MessageMutation{
  16295. config: c,
  16296. op: op,
  16297. typ: TypeMessage,
  16298. clearedFields: make(map[string]struct{}),
  16299. }
  16300. for _, opt := range opts {
  16301. opt(m)
  16302. }
  16303. return m
  16304. }
  16305. // withMessageID sets the ID field of the mutation.
  16306. func withMessageID(id int) messageOption {
  16307. return func(m *MessageMutation) {
  16308. var (
  16309. err error
  16310. once sync.Once
  16311. value *Message
  16312. )
  16313. m.oldValue = func(ctx context.Context) (*Message, error) {
  16314. once.Do(func() {
  16315. if m.done {
  16316. err = errors.New("querying old values post mutation is not allowed")
  16317. } else {
  16318. value, err = m.Client().Message.Get(ctx, id)
  16319. }
  16320. })
  16321. return value, err
  16322. }
  16323. m.id = &id
  16324. }
  16325. }
  16326. // withMessage sets the old Message of the mutation.
  16327. func withMessage(node *Message) messageOption {
  16328. return func(m *MessageMutation) {
  16329. m.oldValue = func(context.Context) (*Message, error) {
  16330. return node, nil
  16331. }
  16332. m.id = &node.ID
  16333. }
  16334. }
  16335. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16336. // executed in a transaction (ent.Tx), a transactional client is returned.
  16337. func (m MessageMutation) Client() *Client {
  16338. client := &Client{config: m.config}
  16339. client.init()
  16340. return client
  16341. }
  16342. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16343. // it returns an error otherwise.
  16344. func (m MessageMutation) Tx() (*Tx, error) {
  16345. if _, ok := m.driver.(*txDriver); !ok {
  16346. return nil, errors.New("ent: mutation is not running in a transaction")
  16347. }
  16348. tx := &Tx{config: m.config}
  16349. tx.init()
  16350. return tx, nil
  16351. }
  16352. // ID returns the ID value in the mutation. Note that the ID is only available
  16353. // if it was provided to the builder or after it was returned from the database.
  16354. func (m *MessageMutation) ID() (id int, exists bool) {
  16355. if m.id == nil {
  16356. return
  16357. }
  16358. return *m.id, true
  16359. }
  16360. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16361. // That means, if the mutation is applied within a transaction with an isolation level such
  16362. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16363. // or updated by the mutation.
  16364. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16365. switch {
  16366. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16367. id, exists := m.ID()
  16368. if exists {
  16369. return []int{id}, nil
  16370. }
  16371. fallthrough
  16372. case m.op.Is(OpUpdate | OpDelete):
  16373. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16374. default:
  16375. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16376. }
  16377. }
  16378. // SetWxWxid sets the "wx_wxid" field.
  16379. func (m *MessageMutation) SetWxWxid(s string) {
  16380. m.wx_wxid = &s
  16381. }
  16382. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16383. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16384. v := m.wx_wxid
  16385. if v == nil {
  16386. return
  16387. }
  16388. return *v, true
  16389. }
  16390. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16391. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16393. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16394. if !m.op.Is(OpUpdateOne) {
  16395. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16396. }
  16397. if m.id == nil || m.oldValue == nil {
  16398. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16399. }
  16400. oldValue, err := m.oldValue(ctx)
  16401. if err != nil {
  16402. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16403. }
  16404. return oldValue.WxWxid, nil
  16405. }
  16406. // ClearWxWxid clears the value of the "wx_wxid" field.
  16407. func (m *MessageMutation) ClearWxWxid() {
  16408. m.wx_wxid = nil
  16409. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16410. }
  16411. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16412. func (m *MessageMutation) WxWxidCleared() bool {
  16413. _, ok := m.clearedFields[message.FieldWxWxid]
  16414. return ok
  16415. }
  16416. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16417. func (m *MessageMutation) ResetWxWxid() {
  16418. m.wx_wxid = nil
  16419. delete(m.clearedFields, message.FieldWxWxid)
  16420. }
  16421. // SetWxid sets the "wxid" field.
  16422. func (m *MessageMutation) SetWxid(s string) {
  16423. m.wxid = &s
  16424. }
  16425. // Wxid returns the value of the "wxid" field in the mutation.
  16426. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16427. v := m.wxid
  16428. if v == nil {
  16429. return
  16430. }
  16431. return *v, true
  16432. }
  16433. // OldWxid returns the old "wxid" field's value of the Message entity.
  16434. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16436. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16437. if !m.op.Is(OpUpdateOne) {
  16438. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16439. }
  16440. if m.id == nil || m.oldValue == nil {
  16441. return v, errors.New("OldWxid requires an ID field in the mutation")
  16442. }
  16443. oldValue, err := m.oldValue(ctx)
  16444. if err != nil {
  16445. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16446. }
  16447. return oldValue.Wxid, nil
  16448. }
  16449. // ResetWxid resets all changes to the "wxid" field.
  16450. func (m *MessageMutation) ResetWxid() {
  16451. m.wxid = nil
  16452. }
  16453. // SetContent sets the "content" field.
  16454. func (m *MessageMutation) SetContent(s string) {
  16455. m.content = &s
  16456. }
  16457. // Content returns the value of the "content" field in the mutation.
  16458. func (m *MessageMutation) Content() (r string, exists bool) {
  16459. v := m.content
  16460. if v == nil {
  16461. return
  16462. }
  16463. return *v, true
  16464. }
  16465. // OldContent returns the old "content" field's value of the Message entity.
  16466. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16468. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16469. if !m.op.Is(OpUpdateOne) {
  16470. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16471. }
  16472. if m.id == nil || m.oldValue == nil {
  16473. return v, errors.New("OldContent requires an ID field in the mutation")
  16474. }
  16475. oldValue, err := m.oldValue(ctx)
  16476. if err != nil {
  16477. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16478. }
  16479. return oldValue.Content, nil
  16480. }
  16481. // ResetContent resets all changes to the "content" field.
  16482. func (m *MessageMutation) ResetContent() {
  16483. m.content = nil
  16484. }
  16485. // Where appends a list predicates to the MessageMutation builder.
  16486. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16487. m.predicates = append(m.predicates, ps...)
  16488. }
  16489. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16490. // users can use type-assertion to append predicates that do not depend on any generated package.
  16491. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16492. p := make([]predicate.Message, len(ps))
  16493. for i := range ps {
  16494. p[i] = ps[i]
  16495. }
  16496. m.Where(p...)
  16497. }
  16498. // Op returns the operation name.
  16499. func (m *MessageMutation) Op() Op {
  16500. return m.op
  16501. }
  16502. // SetOp allows setting the mutation operation.
  16503. func (m *MessageMutation) SetOp(op Op) {
  16504. m.op = op
  16505. }
  16506. // Type returns the node type of this mutation (Message).
  16507. func (m *MessageMutation) Type() string {
  16508. return m.typ
  16509. }
  16510. // Fields returns all fields that were changed during this mutation. Note that in
  16511. // order to get all numeric fields that were incremented/decremented, call
  16512. // AddedFields().
  16513. func (m *MessageMutation) Fields() []string {
  16514. fields := make([]string, 0, 3)
  16515. if m.wx_wxid != nil {
  16516. fields = append(fields, message.FieldWxWxid)
  16517. }
  16518. if m.wxid != nil {
  16519. fields = append(fields, message.FieldWxid)
  16520. }
  16521. if m.content != nil {
  16522. fields = append(fields, message.FieldContent)
  16523. }
  16524. return fields
  16525. }
  16526. // Field returns the value of a field with the given name. The second boolean
  16527. // return value indicates that this field was not set, or was not defined in the
  16528. // schema.
  16529. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16530. switch name {
  16531. case message.FieldWxWxid:
  16532. return m.WxWxid()
  16533. case message.FieldWxid:
  16534. return m.Wxid()
  16535. case message.FieldContent:
  16536. return m.Content()
  16537. }
  16538. return nil, false
  16539. }
  16540. // OldField returns the old value of the field from the database. An error is
  16541. // returned if the mutation operation is not UpdateOne, or the query to the
  16542. // database failed.
  16543. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16544. switch name {
  16545. case message.FieldWxWxid:
  16546. return m.OldWxWxid(ctx)
  16547. case message.FieldWxid:
  16548. return m.OldWxid(ctx)
  16549. case message.FieldContent:
  16550. return m.OldContent(ctx)
  16551. }
  16552. return nil, fmt.Errorf("unknown Message field %s", name)
  16553. }
  16554. // SetField sets the value of a field with the given name. It returns an error if
  16555. // the field is not defined in the schema, or if the type mismatched the field
  16556. // type.
  16557. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16558. switch name {
  16559. case message.FieldWxWxid:
  16560. v, ok := value.(string)
  16561. if !ok {
  16562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16563. }
  16564. m.SetWxWxid(v)
  16565. return nil
  16566. case message.FieldWxid:
  16567. v, ok := value.(string)
  16568. if !ok {
  16569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16570. }
  16571. m.SetWxid(v)
  16572. return nil
  16573. case message.FieldContent:
  16574. v, ok := value.(string)
  16575. if !ok {
  16576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16577. }
  16578. m.SetContent(v)
  16579. return nil
  16580. }
  16581. return fmt.Errorf("unknown Message field %s", name)
  16582. }
  16583. // AddedFields returns all numeric fields that were incremented/decremented during
  16584. // this mutation.
  16585. func (m *MessageMutation) AddedFields() []string {
  16586. return nil
  16587. }
  16588. // AddedField returns the numeric value that was incremented/decremented on a field
  16589. // with the given name. The second boolean return value indicates that this field
  16590. // was not set, or was not defined in the schema.
  16591. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16592. return nil, false
  16593. }
  16594. // AddField adds the value to the field with the given name. It returns an error if
  16595. // the field is not defined in the schema, or if the type mismatched the field
  16596. // type.
  16597. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16598. switch name {
  16599. }
  16600. return fmt.Errorf("unknown Message numeric field %s", name)
  16601. }
  16602. // ClearedFields returns all nullable fields that were cleared during this
  16603. // mutation.
  16604. func (m *MessageMutation) ClearedFields() []string {
  16605. var fields []string
  16606. if m.FieldCleared(message.FieldWxWxid) {
  16607. fields = append(fields, message.FieldWxWxid)
  16608. }
  16609. return fields
  16610. }
  16611. // FieldCleared returns a boolean indicating if a field with the given name was
  16612. // cleared in this mutation.
  16613. func (m *MessageMutation) FieldCleared(name string) bool {
  16614. _, ok := m.clearedFields[name]
  16615. return ok
  16616. }
  16617. // ClearField clears the value of the field with the given name. It returns an
  16618. // error if the field is not defined in the schema.
  16619. func (m *MessageMutation) ClearField(name string) error {
  16620. switch name {
  16621. case message.FieldWxWxid:
  16622. m.ClearWxWxid()
  16623. return nil
  16624. }
  16625. return fmt.Errorf("unknown Message nullable field %s", name)
  16626. }
  16627. // ResetField resets all changes in the mutation for the field with the given name.
  16628. // It returns an error if the field is not defined in the schema.
  16629. func (m *MessageMutation) ResetField(name string) error {
  16630. switch name {
  16631. case message.FieldWxWxid:
  16632. m.ResetWxWxid()
  16633. return nil
  16634. case message.FieldWxid:
  16635. m.ResetWxid()
  16636. return nil
  16637. case message.FieldContent:
  16638. m.ResetContent()
  16639. return nil
  16640. }
  16641. return fmt.Errorf("unknown Message field %s", name)
  16642. }
  16643. // AddedEdges returns all edge names that were set/added in this mutation.
  16644. func (m *MessageMutation) AddedEdges() []string {
  16645. edges := make([]string, 0, 0)
  16646. return edges
  16647. }
  16648. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16649. // name in this mutation.
  16650. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16651. return nil
  16652. }
  16653. // RemovedEdges returns all edge names that were removed in this mutation.
  16654. func (m *MessageMutation) RemovedEdges() []string {
  16655. edges := make([]string, 0, 0)
  16656. return edges
  16657. }
  16658. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16659. // the given name in this mutation.
  16660. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16661. return nil
  16662. }
  16663. // ClearedEdges returns all edge names that were cleared in this mutation.
  16664. func (m *MessageMutation) ClearedEdges() []string {
  16665. edges := make([]string, 0, 0)
  16666. return edges
  16667. }
  16668. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16669. // was cleared in this mutation.
  16670. func (m *MessageMutation) EdgeCleared(name string) bool {
  16671. return false
  16672. }
  16673. // ClearEdge clears the value of the edge with the given name. It returns an error
  16674. // if that edge is not defined in the schema.
  16675. func (m *MessageMutation) ClearEdge(name string) error {
  16676. return fmt.Errorf("unknown Message unique edge %s", name)
  16677. }
  16678. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16679. // It returns an error if the edge is not defined in the schema.
  16680. func (m *MessageMutation) ResetEdge(name string) error {
  16681. return fmt.Errorf("unknown Message edge %s", name)
  16682. }
  16683. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16684. type MessageRecordsMutation struct {
  16685. config
  16686. op Op
  16687. typ string
  16688. id *uint64
  16689. created_at *time.Time
  16690. updated_at *time.Time
  16691. status *uint8
  16692. addstatus *int8
  16693. bot_wxid *string
  16694. contact_type *int
  16695. addcontact_type *int
  16696. contact_wxid *string
  16697. content_type *int
  16698. addcontent_type *int
  16699. content *string
  16700. meta *custom_types.Meta
  16701. error_detail *string
  16702. send_time *time.Time
  16703. source_type *int
  16704. addsource_type *int
  16705. organization_id *uint64
  16706. addorganization_id *int64
  16707. clearedFields map[string]struct{}
  16708. sop_stage *uint64
  16709. clearedsop_stage bool
  16710. sop_node *uint64
  16711. clearedsop_node bool
  16712. message_contact *uint64
  16713. clearedmessage_contact bool
  16714. done bool
  16715. oldValue func(context.Context) (*MessageRecords, error)
  16716. predicates []predicate.MessageRecords
  16717. }
  16718. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16719. // messagerecordsOption allows management of the mutation configuration using functional options.
  16720. type messagerecordsOption func(*MessageRecordsMutation)
  16721. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16722. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16723. m := &MessageRecordsMutation{
  16724. config: c,
  16725. op: op,
  16726. typ: TypeMessageRecords,
  16727. clearedFields: make(map[string]struct{}),
  16728. }
  16729. for _, opt := range opts {
  16730. opt(m)
  16731. }
  16732. return m
  16733. }
  16734. // withMessageRecordsID sets the ID field of the mutation.
  16735. func withMessageRecordsID(id uint64) messagerecordsOption {
  16736. return func(m *MessageRecordsMutation) {
  16737. var (
  16738. err error
  16739. once sync.Once
  16740. value *MessageRecords
  16741. )
  16742. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16743. once.Do(func() {
  16744. if m.done {
  16745. err = errors.New("querying old values post mutation is not allowed")
  16746. } else {
  16747. value, err = m.Client().MessageRecords.Get(ctx, id)
  16748. }
  16749. })
  16750. return value, err
  16751. }
  16752. m.id = &id
  16753. }
  16754. }
  16755. // withMessageRecords sets the old MessageRecords of the mutation.
  16756. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16757. return func(m *MessageRecordsMutation) {
  16758. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16759. return node, nil
  16760. }
  16761. m.id = &node.ID
  16762. }
  16763. }
  16764. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16765. // executed in a transaction (ent.Tx), a transactional client is returned.
  16766. func (m MessageRecordsMutation) Client() *Client {
  16767. client := &Client{config: m.config}
  16768. client.init()
  16769. return client
  16770. }
  16771. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16772. // it returns an error otherwise.
  16773. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16774. if _, ok := m.driver.(*txDriver); !ok {
  16775. return nil, errors.New("ent: mutation is not running in a transaction")
  16776. }
  16777. tx := &Tx{config: m.config}
  16778. tx.init()
  16779. return tx, nil
  16780. }
  16781. // SetID sets the value of the id field. Note that this
  16782. // operation is only accepted on creation of MessageRecords entities.
  16783. func (m *MessageRecordsMutation) SetID(id uint64) {
  16784. m.id = &id
  16785. }
  16786. // ID returns the ID value in the mutation. Note that the ID is only available
  16787. // if it was provided to the builder or after it was returned from the database.
  16788. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16789. if m.id == nil {
  16790. return
  16791. }
  16792. return *m.id, true
  16793. }
  16794. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16795. // That means, if the mutation is applied within a transaction with an isolation level such
  16796. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16797. // or updated by the mutation.
  16798. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16799. switch {
  16800. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16801. id, exists := m.ID()
  16802. if exists {
  16803. return []uint64{id}, nil
  16804. }
  16805. fallthrough
  16806. case m.op.Is(OpUpdate | OpDelete):
  16807. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16808. default:
  16809. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16810. }
  16811. }
  16812. // SetCreatedAt sets the "created_at" field.
  16813. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16814. m.created_at = &t
  16815. }
  16816. // CreatedAt returns the value of the "created_at" field in the mutation.
  16817. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16818. v := m.created_at
  16819. if v == nil {
  16820. return
  16821. }
  16822. return *v, true
  16823. }
  16824. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16825. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16827. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16828. if !m.op.Is(OpUpdateOne) {
  16829. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16830. }
  16831. if m.id == nil || m.oldValue == nil {
  16832. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16833. }
  16834. oldValue, err := m.oldValue(ctx)
  16835. if err != nil {
  16836. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16837. }
  16838. return oldValue.CreatedAt, nil
  16839. }
  16840. // ResetCreatedAt resets all changes to the "created_at" field.
  16841. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16842. m.created_at = nil
  16843. }
  16844. // SetUpdatedAt sets the "updated_at" field.
  16845. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16846. m.updated_at = &t
  16847. }
  16848. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16849. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16850. v := m.updated_at
  16851. if v == nil {
  16852. return
  16853. }
  16854. return *v, true
  16855. }
  16856. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16857. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16859. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16860. if !m.op.Is(OpUpdateOne) {
  16861. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16862. }
  16863. if m.id == nil || m.oldValue == nil {
  16864. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16865. }
  16866. oldValue, err := m.oldValue(ctx)
  16867. if err != nil {
  16868. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16869. }
  16870. return oldValue.UpdatedAt, nil
  16871. }
  16872. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16873. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16874. m.updated_at = nil
  16875. }
  16876. // SetStatus sets the "status" field.
  16877. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16878. m.status = &u
  16879. m.addstatus = nil
  16880. }
  16881. // Status returns the value of the "status" field in the mutation.
  16882. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16883. v := m.status
  16884. if v == nil {
  16885. return
  16886. }
  16887. return *v, true
  16888. }
  16889. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16890. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16892. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16893. if !m.op.Is(OpUpdateOne) {
  16894. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16895. }
  16896. if m.id == nil || m.oldValue == nil {
  16897. return v, errors.New("OldStatus requires an ID field in the mutation")
  16898. }
  16899. oldValue, err := m.oldValue(ctx)
  16900. if err != nil {
  16901. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16902. }
  16903. return oldValue.Status, nil
  16904. }
  16905. // AddStatus adds u to the "status" field.
  16906. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16907. if m.addstatus != nil {
  16908. *m.addstatus += u
  16909. } else {
  16910. m.addstatus = &u
  16911. }
  16912. }
  16913. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16914. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16915. v := m.addstatus
  16916. if v == nil {
  16917. return
  16918. }
  16919. return *v, true
  16920. }
  16921. // ClearStatus clears the value of the "status" field.
  16922. func (m *MessageRecordsMutation) ClearStatus() {
  16923. m.status = nil
  16924. m.addstatus = nil
  16925. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16926. }
  16927. // StatusCleared returns if the "status" field was cleared in this mutation.
  16928. func (m *MessageRecordsMutation) StatusCleared() bool {
  16929. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16930. return ok
  16931. }
  16932. // ResetStatus resets all changes to the "status" field.
  16933. func (m *MessageRecordsMutation) ResetStatus() {
  16934. m.status = nil
  16935. m.addstatus = nil
  16936. delete(m.clearedFields, messagerecords.FieldStatus)
  16937. }
  16938. // SetBotWxid sets the "bot_wxid" field.
  16939. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16940. m.bot_wxid = &s
  16941. }
  16942. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16943. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16944. v := m.bot_wxid
  16945. if v == nil {
  16946. return
  16947. }
  16948. return *v, true
  16949. }
  16950. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16951. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16953. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16954. if !m.op.Is(OpUpdateOne) {
  16955. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16956. }
  16957. if m.id == nil || m.oldValue == nil {
  16958. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16959. }
  16960. oldValue, err := m.oldValue(ctx)
  16961. if err != nil {
  16962. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16963. }
  16964. return oldValue.BotWxid, nil
  16965. }
  16966. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16967. func (m *MessageRecordsMutation) ResetBotWxid() {
  16968. m.bot_wxid = nil
  16969. }
  16970. // SetContactID sets the "contact_id" field.
  16971. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16972. m.message_contact = &u
  16973. }
  16974. // ContactID returns the value of the "contact_id" field in the mutation.
  16975. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16976. v := m.message_contact
  16977. if v == nil {
  16978. return
  16979. }
  16980. return *v, true
  16981. }
  16982. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16983. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16985. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16986. if !m.op.Is(OpUpdateOne) {
  16987. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16988. }
  16989. if m.id == nil || m.oldValue == nil {
  16990. return v, errors.New("OldContactID requires an ID field in the mutation")
  16991. }
  16992. oldValue, err := m.oldValue(ctx)
  16993. if err != nil {
  16994. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16995. }
  16996. return oldValue.ContactID, nil
  16997. }
  16998. // ClearContactID clears the value of the "contact_id" field.
  16999. func (m *MessageRecordsMutation) ClearContactID() {
  17000. m.message_contact = nil
  17001. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17002. }
  17003. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  17004. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  17005. _, ok := m.clearedFields[messagerecords.FieldContactID]
  17006. return ok
  17007. }
  17008. // ResetContactID resets all changes to the "contact_id" field.
  17009. func (m *MessageRecordsMutation) ResetContactID() {
  17010. m.message_contact = nil
  17011. delete(m.clearedFields, messagerecords.FieldContactID)
  17012. }
  17013. // SetContactType sets the "contact_type" field.
  17014. func (m *MessageRecordsMutation) SetContactType(i int) {
  17015. m.contact_type = &i
  17016. m.addcontact_type = nil
  17017. }
  17018. // ContactType returns the value of the "contact_type" field in the mutation.
  17019. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17020. v := m.contact_type
  17021. if v == nil {
  17022. return
  17023. }
  17024. return *v, true
  17025. }
  17026. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  17027. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17029. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  17030. if !m.op.Is(OpUpdateOne) {
  17031. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  17032. }
  17033. if m.id == nil || m.oldValue == nil {
  17034. return v, errors.New("OldContactType requires an ID field in the mutation")
  17035. }
  17036. oldValue, err := m.oldValue(ctx)
  17037. if err != nil {
  17038. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17039. }
  17040. return oldValue.ContactType, nil
  17041. }
  17042. // AddContactType adds i to the "contact_type" field.
  17043. func (m *MessageRecordsMutation) AddContactType(i int) {
  17044. if m.addcontact_type != nil {
  17045. *m.addcontact_type += i
  17046. } else {
  17047. m.addcontact_type = &i
  17048. }
  17049. }
  17050. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17051. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17052. v := m.addcontact_type
  17053. if v == nil {
  17054. return
  17055. }
  17056. return *v, true
  17057. }
  17058. // ResetContactType resets all changes to the "contact_type" field.
  17059. func (m *MessageRecordsMutation) ResetContactType() {
  17060. m.contact_type = nil
  17061. m.addcontact_type = nil
  17062. }
  17063. // SetContactWxid sets the "contact_wxid" field.
  17064. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17065. m.contact_wxid = &s
  17066. }
  17067. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17068. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17069. v := m.contact_wxid
  17070. if v == nil {
  17071. return
  17072. }
  17073. return *v, true
  17074. }
  17075. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17076. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17078. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17079. if !m.op.Is(OpUpdateOne) {
  17080. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17081. }
  17082. if m.id == nil || m.oldValue == nil {
  17083. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17084. }
  17085. oldValue, err := m.oldValue(ctx)
  17086. if err != nil {
  17087. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17088. }
  17089. return oldValue.ContactWxid, nil
  17090. }
  17091. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17092. func (m *MessageRecordsMutation) ResetContactWxid() {
  17093. m.contact_wxid = nil
  17094. }
  17095. // SetContentType sets the "content_type" field.
  17096. func (m *MessageRecordsMutation) SetContentType(i int) {
  17097. m.content_type = &i
  17098. m.addcontent_type = nil
  17099. }
  17100. // ContentType returns the value of the "content_type" field in the mutation.
  17101. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17102. v := m.content_type
  17103. if v == nil {
  17104. return
  17105. }
  17106. return *v, true
  17107. }
  17108. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17109. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17111. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17112. if !m.op.Is(OpUpdateOne) {
  17113. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17114. }
  17115. if m.id == nil || m.oldValue == nil {
  17116. return v, errors.New("OldContentType requires an ID field in the mutation")
  17117. }
  17118. oldValue, err := m.oldValue(ctx)
  17119. if err != nil {
  17120. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17121. }
  17122. return oldValue.ContentType, nil
  17123. }
  17124. // AddContentType adds i to the "content_type" field.
  17125. func (m *MessageRecordsMutation) AddContentType(i int) {
  17126. if m.addcontent_type != nil {
  17127. *m.addcontent_type += i
  17128. } else {
  17129. m.addcontent_type = &i
  17130. }
  17131. }
  17132. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17133. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17134. v := m.addcontent_type
  17135. if v == nil {
  17136. return
  17137. }
  17138. return *v, true
  17139. }
  17140. // ResetContentType resets all changes to the "content_type" field.
  17141. func (m *MessageRecordsMutation) ResetContentType() {
  17142. m.content_type = nil
  17143. m.addcontent_type = nil
  17144. }
  17145. // SetContent sets the "content" field.
  17146. func (m *MessageRecordsMutation) SetContent(s string) {
  17147. m.content = &s
  17148. }
  17149. // Content returns the value of the "content" field in the mutation.
  17150. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17151. v := m.content
  17152. if v == nil {
  17153. return
  17154. }
  17155. return *v, true
  17156. }
  17157. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17158. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17160. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17161. if !m.op.Is(OpUpdateOne) {
  17162. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17163. }
  17164. if m.id == nil || m.oldValue == nil {
  17165. return v, errors.New("OldContent requires an ID field in the mutation")
  17166. }
  17167. oldValue, err := m.oldValue(ctx)
  17168. if err != nil {
  17169. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17170. }
  17171. return oldValue.Content, nil
  17172. }
  17173. // ResetContent resets all changes to the "content" field.
  17174. func (m *MessageRecordsMutation) ResetContent() {
  17175. m.content = nil
  17176. }
  17177. // SetMeta sets the "meta" field.
  17178. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17179. m.meta = &ct
  17180. }
  17181. // Meta returns the value of the "meta" field in the mutation.
  17182. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17183. v := m.meta
  17184. if v == nil {
  17185. return
  17186. }
  17187. return *v, true
  17188. }
  17189. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17190. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17192. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17193. if !m.op.Is(OpUpdateOne) {
  17194. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17195. }
  17196. if m.id == nil || m.oldValue == nil {
  17197. return v, errors.New("OldMeta requires an ID field in the mutation")
  17198. }
  17199. oldValue, err := m.oldValue(ctx)
  17200. if err != nil {
  17201. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17202. }
  17203. return oldValue.Meta, nil
  17204. }
  17205. // ClearMeta clears the value of the "meta" field.
  17206. func (m *MessageRecordsMutation) ClearMeta() {
  17207. m.meta = nil
  17208. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17209. }
  17210. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17211. func (m *MessageRecordsMutation) MetaCleared() bool {
  17212. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17213. return ok
  17214. }
  17215. // ResetMeta resets all changes to the "meta" field.
  17216. func (m *MessageRecordsMutation) ResetMeta() {
  17217. m.meta = nil
  17218. delete(m.clearedFields, messagerecords.FieldMeta)
  17219. }
  17220. // SetErrorDetail sets the "error_detail" field.
  17221. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17222. m.error_detail = &s
  17223. }
  17224. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17225. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17226. v := m.error_detail
  17227. if v == nil {
  17228. return
  17229. }
  17230. return *v, true
  17231. }
  17232. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17233. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17235. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17236. if !m.op.Is(OpUpdateOne) {
  17237. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17238. }
  17239. if m.id == nil || m.oldValue == nil {
  17240. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17241. }
  17242. oldValue, err := m.oldValue(ctx)
  17243. if err != nil {
  17244. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17245. }
  17246. return oldValue.ErrorDetail, nil
  17247. }
  17248. // ResetErrorDetail resets all changes to the "error_detail" field.
  17249. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17250. m.error_detail = nil
  17251. }
  17252. // SetSendTime sets the "send_time" field.
  17253. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17254. m.send_time = &t
  17255. }
  17256. // SendTime returns the value of the "send_time" field in the mutation.
  17257. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17258. v := m.send_time
  17259. if v == nil {
  17260. return
  17261. }
  17262. return *v, true
  17263. }
  17264. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17265. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17267. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17268. if !m.op.Is(OpUpdateOne) {
  17269. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17270. }
  17271. if m.id == nil || m.oldValue == nil {
  17272. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17273. }
  17274. oldValue, err := m.oldValue(ctx)
  17275. if err != nil {
  17276. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17277. }
  17278. return oldValue.SendTime, nil
  17279. }
  17280. // ClearSendTime clears the value of the "send_time" field.
  17281. func (m *MessageRecordsMutation) ClearSendTime() {
  17282. m.send_time = nil
  17283. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17284. }
  17285. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17286. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17287. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17288. return ok
  17289. }
  17290. // ResetSendTime resets all changes to the "send_time" field.
  17291. func (m *MessageRecordsMutation) ResetSendTime() {
  17292. m.send_time = nil
  17293. delete(m.clearedFields, messagerecords.FieldSendTime)
  17294. }
  17295. // SetSourceType sets the "source_type" field.
  17296. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17297. m.source_type = &i
  17298. m.addsource_type = nil
  17299. }
  17300. // SourceType returns the value of the "source_type" field in the mutation.
  17301. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17302. v := m.source_type
  17303. if v == nil {
  17304. return
  17305. }
  17306. return *v, true
  17307. }
  17308. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17309. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17311. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17312. if !m.op.Is(OpUpdateOne) {
  17313. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17314. }
  17315. if m.id == nil || m.oldValue == nil {
  17316. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17317. }
  17318. oldValue, err := m.oldValue(ctx)
  17319. if err != nil {
  17320. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17321. }
  17322. return oldValue.SourceType, nil
  17323. }
  17324. // AddSourceType adds i to the "source_type" field.
  17325. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17326. if m.addsource_type != nil {
  17327. *m.addsource_type += i
  17328. } else {
  17329. m.addsource_type = &i
  17330. }
  17331. }
  17332. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17333. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17334. v := m.addsource_type
  17335. if v == nil {
  17336. return
  17337. }
  17338. return *v, true
  17339. }
  17340. // ResetSourceType resets all changes to the "source_type" field.
  17341. func (m *MessageRecordsMutation) ResetSourceType() {
  17342. m.source_type = nil
  17343. m.addsource_type = nil
  17344. }
  17345. // SetSourceID sets the "source_id" field.
  17346. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17347. m.sop_stage = &u
  17348. }
  17349. // SourceID returns the value of the "source_id" field in the mutation.
  17350. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17351. v := m.sop_stage
  17352. if v == nil {
  17353. return
  17354. }
  17355. return *v, true
  17356. }
  17357. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17358. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17360. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17361. if !m.op.Is(OpUpdateOne) {
  17362. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17363. }
  17364. if m.id == nil || m.oldValue == nil {
  17365. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17366. }
  17367. oldValue, err := m.oldValue(ctx)
  17368. if err != nil {
  17369. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17370. }
  17371. return oldValue.SourceID, nil
  17372. }
  17373. // ClearSourceID clears the value of the "source_id" field.
  17374. func (m *MessageRecordsMutation) ClearSourceID() {
  17375. m.sop_stage = nil
  17376. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17377. }
  17378. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17379. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17380. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17381. return ok
  17382. }
  17383. // ResetSourceID resets all changes to the "source_id" field.
  17384. func (m *MessageRecordsMutation) ResetSourceID() {
  17385. m.sop_stage = nil
  17386. delete(m.clearedFields, messagerecords.FieldSourceID)
  17387. }
  17388. // SetSubSourceID sets the "sub_source_id" field.
  17389. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17390. m.sop_node = &u
  17391. }
  17392. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17393. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17394. v := m.sop_node
  17395. if v == nil {
  17396. return
  17397. }
  17398. return *v, true
  17399. }
  17400. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17401. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17403. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17404. if !m.op.Is(OpUpdateOne) {
  17405. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17406. }
  17407. if m.id == nil || m.oldValue == nil {
  17408. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17409. }
  17410. oldValue, err := m.oldValue(ctx)
  17411. if err != nil {
  17412. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17413. }
  17414. return oldValue.SubSourceID, nil
  17415. }
  17416. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17417. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17418. m.sop_node = nil
  17419. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17420. }
  17421. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17422. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17423. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17424. return ok
  17425. }
  17426. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17427. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17428. m.sop_node = nil
  17429. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17430. }
  17431. // SetOrganizationID sets the "organization_id" field.
  17432. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17433. m.organization_id = &u
  17434. m.addorganization_id = nil
  17435. }
  17436. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17437. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17438. v := m.organization_id
  17439. if v == nil {
  17440. return
  17441. }
  17442. return *v, true
  17443. }
  17444. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17445. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17447. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17448. if !m.op.Is(OpUpdateOne) {
  17449. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17450. }
  17451. if m.id == nil || m.oldValue == nil {
  17452. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17453. }
  17454. oldValue, err := m.oldValue(ctx)
  17455. if err != nil {
  17456. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17457. }
  17458. return oldValue.OrganizationID, nil
  17459. }
  17460. // AddOrganizationID adds u to the "organization_id" field.
  17461. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17462. if m.addorganization_id != nil {
  17463. *m.addorganization_id += u
  17464. } else {
  17465. m.addorganization_id = &u
  17466. }
  17467. }
  17468. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17469. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17470. v := m.addorganization_id
  17471. if v == nil {
  17472. return
  17473. }
  17474. return *v, true
  17475. }
  17476. // ClearOrganizationID clears the value of the "organization_id" field.
  17477. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17478. m.organization_id = nil
  17479. m.addorganization_id = nil
  17480. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17481. }
  17482. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17483. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17484. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17485. return ok
  17486. }
  17487. // ResetOrganizationID resets all changes to the "organization_id" field.
  17488. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17489. m.organization_id = nil
  17490. m.addorganization_id = nil
  17491. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17492. }
  17493. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17494. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17495. m.sop_stage = &id
  17496. }
  17497. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17498. func (m *MessageRecordsMutation) ClearSopStage() {
  17499. m.clearedsop_stage = true
  17500. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17501. }
  17502. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17503. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17504. return m.SourceIDCleared() || m.clearedsop_stage
  17505. }
  17506. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17507. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17508. if m.sop_stage != nil {
  17509. return *m.sop_stage, true
  17510. }
  17511. return
  17512. }
  17513. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17514. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17515. // SopStageID instead. It exists only for internal usage by the builders.
  17516. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17517. if id := m.sop_stage; id != nil {
  17518. ids = append(ids, *id)
  17519. }
  17520. return
  17521. }
  17522. // ResetSopStage resets all changes to the "sop_stage" edge.
  17523. func (m *MessageRecordsMutation) ResetSopStage() {
  17524. m.sop_stage = nil
  17525. m.clearedsop_stage = false
  17526. }
  17527. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17528. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17529. m.sop_node = &id
  17530. }
  17531. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17532. func (m *MessageRecordsMutation) ClearSopNode() {
  17533. m.clearedsop_node = true
  17534. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17535. }
  17536. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17537. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17538. return m.SubSourceIDCleared() || m.clearedsop_node
  17539. }
  17540. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17541. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17542. if m.sop_node != nil {
  17543. return *m.sop_node, true
  17544. }
  17545. return
  17546. }
  17547. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17548. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17549. // SopNodeID instead. It exists only for internal usage by the builders.
  17550. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17551. if id := m.sop_node; id != nil {
  17552. ids = append(ids, *id)
  17553. }
  17554. return
  17555. }
  17556. // ResetSopNode resets all changes to the "sop_node" edge.
  17557. func (m *MessageRecordsMutation) ResetSopNode() {
  17558. m.sop_node = nil
  17559. m.clearedsop_node = false
  17560. }
  17561. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17562. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17563. m.message_contact = &id
  17564. }
  17565. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17566. func (m *MessageRecordsMutation) ClearMessageContact() {
  17567. m.clearedmessage_contact = true
  17568. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17569. }
  17570. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17571. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17572. return m.ContactIDCleared() || m.clearedmessage_contact
  17573. }
  17574. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17575. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17576. if m.message_contact != nil {
  17577. return *m.message_contact, true
  17578. }
  17579. return
  17580. }
  17581. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17582. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17583. // MessageContactID instead. It exists only for internal usage by the builders.
  17584. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17585. if id := m.message_contact; id != nil {
  17586. ids = append(ids, *id)
  17587. }
  17588. return
  17589. }
  17590. // ResetMessageContact resets all changes to the "message_contact" edge.
  17591. func (m *MessageRecordsMutation) ResetMessageContact() {
  17592. m.message_contact = nil
  17593. m.clearedmessage_contact = false
  17594. }
  17595. // Where appends a list predicates to the MessageRecordsMutation builder.
  17596. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17597. m.predicates = append(m.predicates, ps...)
  17598. }
  17599. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17600. // users can use type-assertion to append predicates that do not depend on any generated package.
  17601. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17602. p := make([]predicate.MessageRecords, len(ps))
  17603. for i := range ps {
  17604. p[i] = ps[i]
  17605. }
  17606. m.Where(p...)
  17607. }
  17608. // Op returns the operation name.
  17609. func (m *MessageRecordsMutation) Op() Op {
  17610. return m.op
  17611. }
  17612. // SetOp allows setting the mutation operation.
  17613. func (m *MessageRecordsMutation) SetOp(op Op) {
  17614. m.op = op
  17615. }
  17616. // Type returns the node type of this mutation (MessageRecords).
  17617. func (m *MessageRecordsMutation) Type() string {
  17618. return m.typ
  17619. }
  17620. // Fields returns all fields that were changed during this mutation. Note that in
  17621. // order to get all numeric fields that were incremented/decremented, call
  17622. // AddedFields().
  17623. func (m *MessageRecordsMutation) Fields() []string {
  17624. fields := make([]string, 0, 16)
  17625. if m.created_at != nil {
  17626. fields = append(fields, messagerecords.FieldCreatedAt)
  17627. }
  17628. if m.updated_at != nil {
  17629. fields = append(fields, messagerecords.FieldUpdatedAt)
  17630. }
  17631. if m.status != nil {
  17632. fields = append(fields, messagerecords.FieldStatus)
  17633. }
  17634. if m.bot_wxid != nil {
  17635. fields = append(fields, messagerecords.FieldBotWxid)
  17636. }
  17637. if m.message_contact != nil {
  17638. fields = append(fields, messagerecords.FieldContactID)
  17639. }
  17640. if m.contact_type != nil {
  17641. fields = append(fields, messagerecords.FieldContactType)
  17642. }
  17643. if m.contact_wxid != nil {
  17644. fields = append(fields, messagerecords.FieldContactWxid)
  17645. }
  17646. if m.content_type != nil {
  17647. fields = append(fields, messagerecords.FieldContentType)
  17648. }
  17649. if m.content != nil {
  17650. fields = append(fields, messagerecords.FieldContent)
  17651. }
  17652. if m.meta != nil {
  17653. fields = append(fields, messagerecords.FieldMeta)
  17654. }
  17655. if m.error_detail != nil {
  17656. fields = append(fields, messagerecords.FieldErrorDetail)
  17657. }
  17658. if m.send_time != nil {
  17659. fields = append(fields, messagerecords.FieldSendTime)
  17660. }
  17661. if m.source_type != nil {
  17662. fields = append(fields, messagerecords.FieldSourceType)
  17663. }
  17664. if m.sop_stage != nil {
  17665. fields = append(fields, messagerecords.FieldSourceID)
  17666. }
  17667. if m.sop_node != nil {
  17668. fields = append(fields, messagerecords.FieldSubSourceID)
  17669. }
  17670. if m.organization_id != nil {
  17671. fields = append(fields, messagerecords.FieldOrganizationID)
  17672. }
  17673. return fields
  17674. }
  17675. // Field returns the value of a field with the given name. The second boolean
  17676. // return value indicates that this field was not set, or was not defined in the
  17677. // schema.
  17678. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17679. switch name {
  17680. case messagerecords.FieldCreatedAt:
  17681. return m.CreatedAt()
  17682. case messagerecords.FieldUpdatedAt:
  17683. return m.UpdatedAt()
  17684. case messagerecords.FieldStatus:
  17685. return m.Status()
  17686. case messagerecords.FieldBotWxid:
  17687. return m.BotWxid()
  17688. case messagerecords.FieldContactID:
  17689. return m.ContactID()
  17690. case messagerecords.FieldContactType:
  17691. return m.ContactType()
  17692. case messagerecords.FieldContactWxid:
  17693. return m.ContactWxid()
  17694. case messagerecords.FieldContentType:
  17695. return m.ContentType()
  17696. case messagerecords.FieldContent:
  17697. return m.Content()
  17698. case messagerecords.FieldMeta:
  17699. return m.Meta()
  17700. case messagerecords.FieldErrorDetail:
  17701. return m.ErrorDetail()
  17702. case messagerecords.FieldSendTime:
  17703. return m.SendTime()
  17704. case messagerecords.FieldSourceType:
  17705. return m.SourceType()
  17706. case messagerecords.FieldSourceID:
  17707. return m.SourceID()
  17708. case messagerecords.FieldSubSourceID:
  17709. return m.SubSourceID()
  17710. case messagerecords.FieldOrganizationID:
  17711. return m.OrganizationID()
  17712. }
  17713. return nil, false
  17714. }
  17715. // OldField returns the old value of the field from the database. An error is
  17716. // returned if the mutation operation is not UpdateOne, or the query to the
  17717. // database failed.
  17718. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17719. switch name {
  17720. case messagerecords.FieldCreatedAt:
  17721. return m.OldCreatedAt(ctx)
  17722. case messagerecords.FieldUpdatedAt:
  17723. return m.OldUpdatedAt(ctx)
  17724. case messagerecords.FieldStatus:
  17725. return m.OldStatus(ctx)
  17726. case messagerecords.FieldBotWxid:
  17727. return m.OldBotWxid(ctx)
  17728. case messagerecords.FieldContactID:
  17729. return m.OldContactID(ctx)
  17730. case messagerecords.FieldContactType:
  17731. return m.OldContactType(ctx)
  17732. case messagerecords.FieldContactWxid:
  17733. return m.OldContactWxid(ctx)
  17734. case messagerecords.FieldContentType:
  17735. return m.OldContentType(ctx)
  17736. case messagerecords.FieldContent:
  17737. return m.OldContent(ctx)
  17738. case messagerecords.FieldMeta:
  17739. return m.OldMeta(ctx)
  17740. case messagerecords.FieldErrorDetail:
  17741. return m.OldErrorDetail(ctx)
  17742. case messagerecords.FieldSendTime:
  17743. return m.OldSendTime(ctx)
  17744. case messagerecords.FieldSourceType:
  17745. return m.OldSourceType(ctx)
  17746. case messagerecords.FieldSourceID:
  17747. return m.OldSourceID(ctx)
  17748. case messagerecords.FieldSubSourceID:
  17749. return m.OldSubSourceID(ctx)
  17750. case messagerecords.FieldOrganizationID:
  17751. return m.OldOrganizationID(ctx)
  17752. }
  17753. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17754. }
  17755. // SetField sets the value of a field with the given name. It returns an error if
  17756. // the field is not defined in the schema, or if the type mismatched the field
  17757. // type.
  17758. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17759. switch name {
  17760. case messagerecords.FieldCreatedAt:
  17761. v, ok := value.(time.Time)
  17762. if !ok {
  17763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17764. }
  17765. m.SetCreatedAt(v)
  17766. return nil
  17767. case messagerecords.FieldUpdatedAt:
  17768. v, ok := value.(time.Time)
  17769. if !ok {
  17770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17771. }
  17772. m.SetUpdatedAt(v)
  17773. return nil
  17774. case messagerecords.FieldStatus:
  17775. v, ok := value.(uint8)
  17776. if !ok {
  17777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17778. }
  17779. m.SetStatus(v)
  17780. return nil
  17781. case messagerecords.FieldBotWxid:
  17782. v, ok := value.(string)
  17783. if !ok {
  17784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17785. }
  17786. m.SetBotWxid(v)
  17787. return nil
  17788. case messagerecords.FieldContactID:
  17789. v, ok := value.(uint64)
  17790. if !ok {
  17791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17792. }
  17793. m.SetContactID(v)
  17794. return nil
  17795. case messagerecords.FieldContactType:
  17796. v, ok := value.(int)
  17797. if !ok {
  17798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17799. }
  17800. m.SetContactType(v)
  17801. return nil
  17802. case messagerecords.FieldContactWxid:
  17803. v, ok := value.(string)
  17804. if !ok {
  17805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17806. }
  17807. m.SetContactWxid(v)
  17808. return nil
  17809. case messagerecords.FieldContentType:
  17810. v, ok := value.(int)
  17811. if !ok {
  17812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17813. }
  17814. m.SetContentType(v)
  17815. return nil
  17816. case messagerecords.FieldContent:
  17817. v, ok := value.(string)
  17818. if !ok {
  17819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17820. }
  17821. m.SetContent(v)
  17822. return nil
  17823. case messagerecords.FieldMeta:
  17824. v, ok := value.(custom_types.Meta)
  17825. if !ok {
  17826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17827. }
  17828. m.SetMeta(v)
  17829. return nil
  17830. case messagerecords.FieldErrorDetail:
  17831. v, ok := value.(string)
  17832. if !ok {
  17833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17834. }
  17835. m.SetErrorDetail(v)
  17836. return nil
  17837. case messagerecords.FieldSendTime:
  17838. v, ok := value.(time.Time)
  17839. if !ok {
  17840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17841. }
  17842. m.SetSendTime(v)
  17843. return nil
  17844. case messagerecords.FieldSourceType:
  17845. v, ok := value.(int)
  17846. if !ok {
  17847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17848. }
  17849. m.SetSourceType(v)
  17850. return nil
  17851. case messagerecords.FieldSourceID:
  17852. v, ok := value.(uint64)
  17853. if !ok {
  17854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17855. }
  17856. m.SetSourceID(v)
  17857. return nil
  17858. case messagerecords.FieldSubSourceID:
  17859. v, ok := value.(uint64)
  17860. if !ok {
  17861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17862. }
  17863. m.SetSubSourceID(v)
  17864. return nil
  17865. case messagerecords.FieldOrganizationID:
  17866. v, ok := value.(uint64)
  17867. if !ok {
  17868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17869. }
  17870. m.SetOrganizationID(v)
  17871. return nil
  17872. }
  17873. return fmt.Errorf("unknown MessageRecords field %s", name)
  17874. }
  17875. // AddedFields returns all numeric fields that were incremented/decremented during
  17876. // this mutation.
  17877. func (m *MessageRecordsMutation) AddedFields() []string {
  17878. var fields []string
  17879. if m.addstatus != nil {
  17880. fields = append(fields, messagerecords.FieldStatus)
  17881. }
  17882. if m.addcontact_type != nil {
  17883. fields = append(fields, messagerecords.FieldContactType)
  17884. }
  17885. if m.addcontent_type != nil {
  17886. fields = append(fields, messagerecords.FieldContentType)
  17887. }
  17888. if m.addsource_type != nil {
  17889. fields = append(fields, messagerecords.FieldSourceType)
  17890. }
  17891. if m.addorganization_id != nil {
  17892. fields = append(fields, messagerecords.FieldOrganizationID)
  17893. }
  17894. return fields
  17895. }
  17896. // AddedField returns the numeric value that was incremented/decremented on a field
  17897. // with the given name. The second boolean return value indicates that this field
  17898. // was not set, or was not defined in the schema.
  17899. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17900. switch name {
  17901. case messagerecords.FieldStatus:
  17902. return m.AddedStatus()
  17903. case messagerecords.FieldContactType:
  17904. return m.AddedContactType()
  17905. case messagerecords.FieldContentType:
  17906. return m.AddedContentType()
  17907. case messagerecords.FieldSourceType:
  17908. return m.AddedSourceType()
  17909. case messagerecords.FieldOrganizationID:
  17910. return m.AddedOrganizationID()
  17911. }
  17912. return nil, false
  17913. }
  17914. // AddField adds the value to the field with the given name. It returns an error if
  17915. // the field is not defined in the schema, or if the type mismatched the field
  17916. // type.
  17917. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17918. switch name {
  17919. case messagerecords.FieldStatus:
  17920. v, ok := value.(int8)
  17921. if !ok {
  17922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17923. }
  17924. m.AddStatus(v)
  17925. return nil
  17926. case messagerecords.FieldContactType:
  17927. v, ok := value.(int)
  17928. if !ok {
  17929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17930. }
  17931. m.AddContactType(v)
  17932. return nil
  17933. case messagerecords.FieldContentType:
  17934. v, ok := value.(int)
  17935. if !ok {
  17936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17937. }
  17938. m.AddContentType(v)
  17939. return nil
  17940. case messagerecords.FieldSourceType:
  17941. v, ok := value.(int)
  17942. if !ok {
  17943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17944. }
  17945. m.AddSourceType(v)
  17946. return nil
  17947. case messagerecords.FieldOrganizationID:
  17948. v, ok := value.(int64)
  17949. if !ok {
  17950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17951. }
  17952. m.AddOrganizationID(v)
  17953. return nil
  17954. }
  17955. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17956. }
  17957. // ClearedFields returns all nullable fields that were cleared during this
  17958. // mutation.
  17959. func (m *MessageRecordsMutation) ClearedFields() []string {
  17960. var fields []string
  17961. if m.FieldCleared(messagerecords.FieldStatus) {
  17962. fields = append(fields, messagerecords.FieldStatus)
  17963. }
  17964. if m.FieldCleared(messagerecords.FieldContactID) {
  17965. fields = append(fields, messagerecords.FieldContactID)
  17966. }
  17967. if m.FieldCleared(messagerecords.FieldMeta) {
  17968. fields = append(fields, messagerecords.FieldMeta)
  17969. }
  17970. if m.FieldCleared(messagerecords.FieldSendTime) {
  17971. fields = append(fields, messagerecords.FieldSendTime)
  17972. }
  17973. if m.FieldCleared(messagerecords.FieldSourceID) {
  17974. fields = append(fields, messagerecords.FieldSourceID)
  17975. }
  17976. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17977. fields = append(fields, messagerecords.FieldSubSourceID)
  17978. }
  17979. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17980. fields = append(fields, messagerecords.FieldOrganizationID)
  17981. }
  17982. return fields
  17983. }
  17984. // FieldCleared returns a boolean indicating if a field with the given name was
  17985. // cleared in this mutation.
  17986. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17987. _, ok := m.clearedFields[name]
  17988. return ok
  17989. }
  17990. // ClearField clears the value of the field with the given name. It returns an
  17991. // error if the field is not defined in the schema.
  17992. func (m *MessageRecordsMutation) ClearField(name string) error {
  17993. switch name {
  17994. case messagerecords.FieldStatus:
  17995. m.ClearStatus()
  17996. return nil
  17997. case messagerecords.FieldContactID:
  17998. m.ClearContactID()
  17999. return nil
  18000. case messagerecords.FieldMeta:
  18001. m.ClearMeta()
  18002. return nil
  18003. case messagerecords.FieldSendTime:
  18004. m.ClearSendTime()
  18005. return nil
  18006. case messagerecords.FieldSourceID:
  18007. m.ClearSourceID()
  18008. return nil
  18009. case messagerecords.FieldSubSourceID:
  18010. m.ClearSubSourceID()
  18011. return nil
  18012. case messagerecords.FieldOrganizationID:
  18013. m.ClearOrganizationID()
  18014. return nil
  18015. }
  18016. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18017. }
  18018. // ResetField resets all changes in the mutation for the field with the given name.
  18019. // It returns an error if the field is not defined in the schema.
  18020. func (m *MessageRecordsMutation) ResetField(name string) error {
  18021. switch name {
  18022. case messagerecords.FieldCreatedAt:
  18023. m.ResetCreatedAt()
  18024. return nil
  18025. case messagerecords.FieldUpdatedAt:
  18026. m.ResetUpdatedAt()
  18027. return nil
  18028. case messagerecords.FieldStatus:
  18029. m.ResetStatus()
  18030. return nil
  18031. case messagerecords.FieldBotWxid:
  18032. m.ResetBotWxid()
  18033. return nil
  18034. case messagerecords.FieldContactID:
  18035. m.ResetContactID()
  18036. return nil
  18037. case messagerecords.FieldContactType:
  18038. m.ResetContactType()
  18039. return nil
  18040. case messagerecords.FieldContactWxid:
  18041. m.ResetContactWxid()
  18042. return nil
  18043. case messagerecords.FieldContentType:
  18044. m.ResetContentType()
  18045. return nil
  18046. case messagerecords.FieldContent:
  18047. m.ResetContent()
  18048. return nil
  18049. case messagerecords.FieldMeta:
  18050. m.ResetMeta()
  18051. return nil
  18052. case messagerecords.FieldErrorDetail:
  18053. m.ResetErrorDetail()
  18054. return nil
  18055. case messagerecords.FieldSendTime:
  18056. m.ResetSendTime()
  18057. return nil
  18058. case messagerecords.FieldSourceType:
  18059. m.ResetSourceType()
  18060. return nil
  18061. case messagerecords.FieldSourceID:
  18062. m.ResetSourceID()
  18063. return nil
  18064. case messagerecords.FieldSubSourceID:
  18065. m.ResetSubSourceID()
  18066. return nil
  18067. case messagerecords.FieldOrganizationID:
  18068. m.ResetOrganizationID()
  18069. return nil
  18070. }
  18071. return fmt.Errorf("unknown MessageRecords field %s", name)
  18072. }
  18073. // AddedEdges returns all edge names that were set/added in this mutation.
  18074. func (m *MessageRecordsMutation) AddedEdges() []string {
  18075. edges := make([]string, 0, 3)
  18076. if m.sop_stage != nil {
  18077. edges = append(edges, messagerecords.EdgeSopStage)
  18078. }
  18079. if m.sop_node != nil {
  18080. edges = append(edges, messagerecords.EdgeSopNode)
  18081. }
  18082. if m.message_contact != nil {
  18083. edges = append(edges, messagerecords.EdgeMessageContact)
  18084. }
  18085. return edges
  18086. }
  18087. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18088. // name in this mutation.
  18089. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18090. switch name {
  18091. case messagerecords.EdgeSopStage:
  18092. if id := m.sop_stage; id != nil {
  18093. return []ent.Value{*id}
  18094. }
  18095. case messagerecords.EdgeSopNode:
  18096. if id := m.sop_node; id != nil {
  18097. return []ent.Value{*id}
  18098. }
  18099. case messagerecords.EdgeMessageContact:
  18100. if id := m.message_contact; id != nil {
  18101. return []ent.Value{*id}
  18102. }
  18103. }
  18104. return nil
  18105. }
  18106. // RemovedEdges returns all edge names that were removed in this mutation.
  18107. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18108. edges := make([]string, 0, 3)
  18109. return edges
  18110. }
  18111. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18112. // the given name in this mutation.
  18113. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18114. return nil
  18115. }
  18116. // ClearedEdges returns all edge names that were cleared in this mutation.
  18117. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18118. edges := make([]string, 0, 3)
  18119. if m.clearedsop_stage {
  18120. edges = append(edges, messagerecords.EdgeSopStage)
  18121. }
  18122. if m.clearedsop_node {
  18123. edges = append(edges, messagerecords.EdgeSopNode)
  18124. }
  18125. if m.clearedmessage_contact {
  18126. edges = append(edges, messagerecords.EdgeMessageContact)
  18127. }
  18128. return edges
  18129. }
  18130. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18131. // was cleared in this mutation.
  18132. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18133. switch name {
  18134. case messagerecords.EdgeSopStage:
  18135. return m.clearedsop_stage
  18136. case messagerecords.EdgeSopNode:
  18137. return m.clearedsop_node
  18138. case messagerecords.EdgeMessageContact:
  18139. return m.clearedmessage_contact
  18140. }
  18141. return false
  18142. }
  18143. // ClearEdge clears the value of the edge with the given name. It returns an error
  18144. // if that edge is not defined in the schema.
  18145. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18146. switch name {
  18147. case messagerecords.EdgeSopStage:
  18148. m.ClearSopStage()
  18149. return nil
  18150. case messagerecords.EdgeSopNode:
  18151. m.ClearSopNode()
  18152. return nil
  18153. case messagerecords.EdgeMessageContact:
  18154. m.ClearMessageContact()
  18155. return nil
  18156. }
  18157. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18158. }
  18159. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18160. // It returns an error if the edge is not defined in the schema.
  18161. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18162. switch name {
  18163. case messagerecords.EdgeSopStage:
  18164. m.ResetSopStage()
  18165. return nil
  18166. case messagerecords.EdgeSopNode:
  18167. m.ResetSopNode()
  18168. return nil
  18169. case messagerecords.EdgeMessageContact:
  18170. m.ResetMessageContact()
  18171. return nil
  18172. }
  18173. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18174. }
  18175. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18176. type MsgMutation struct {
  18177. config
  18178. op Op
  18179. typ string
  18180. id *uint64
  18181. created_at *time.Time
  18182. updated_at *time.Time
  18183. deleted_at *time.Time
  18184. status *uint8
  18185. addstatus *int8
  18186. fromwxid *string
  18187. toid *string
  18188. msgtype *int32
  18189. addmsgtype *int32
  18190. msg *string
  18191. batch_no *string
  18192. clearedFields map[string]struct{}
  18193. done bool
  18194. oldValue func(context.Context) (*Msg, error)
  18195. predicates []predicate.Msg
  18196. }
  18197. var _ ent.Mutation = (*MsgMutation)(nil)
  18198. // msgOption allows management of the mutation configuration using functional options.
  18199. type msgOption func(*MsgMutation)
  18200. // newMsgMutation creates new mutation for the Msg entity.
  18201. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18202. m := &MsgMutation{
  18203. config: c,
  18204. op: op,
  18205. typ: TypeMsg,
  18206. clearedFields: make(map[string]struct{}),
  18207. }
  18208. for _, opt := range opts {
  18209. opt(m)
  18210. }
  18211. return m
  18212. }
  18213. // withMsgID sets the ID field of the mutation.
  18214. func withMsgID(id uint64) msgOption {
  18215. return func(m *MsgMutation) {
  18216. var (
  18217. err error
  18218. once sync.Once
  18219. value *Msg
  18220. )
  18221. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18222. once.Do(func() {
  18223. if m.done {
  18224. err = errors.New("querying old values post mutation is not allowed")
  18225. } else {
  18226. value, err = m.Client().Msg.Get(ctx, id)
  18227. }
  18228. })
  18229. return value, err
  18230. }
  18231. m.id = &id
  18232. }
  18233. }
  18234. // withMsg sets the old Msg of the mutation.
  18235. func withMsg(node *Msg) msgOption {
  18236. return func(m *MsgMutation) {
  18237. m.oldValue = func(context.Context) (*Msg, error) {
  18238. return node, nil
  18239. }
  18240. m.id = &node.ID
  18241. }
  18242. }
  18243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18244. // executed in a transaction (ent.Tx), a transactional client is returned.
  18245. func (m MsgMutation) Client() *Client {
  18246. client := &Client{config: m.config}
  18247. client.init()
  18248. return client
  18249. }
  18250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18251. // it returns an error otherwise.
  18252. func (m MsgMutation) Tx() (*Tx, error) {
  18253. if _, ok := m.driver.(*txDriver); !ok {
  18254. return nil, errors.New("ent: mutation is not running in a transaction")
  18255. }
  18256. tx := &Tx{config: m.config}
  18257. tx.init()
  18258. return tx, nil
  18259. }
  18260. // SetID sets the value of the id field. Note that this
  18261. // operation is only accepted on creation of Msg entities.
  18262. func (m *MsgMutation) SetID(id uint64) {
  18263. m.id = &id
  18264. }
  18265. // ID returns the ID value in the mutation. Note that the ID is only available
  18266. // if it was provided to the builder or after it was returned from the database.
  18267. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18268. if m.id == nil {
  18269. return
  18270. }
  18271. return *m.id, true
  18272. }
  18273. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18274. // That means, if the mutation is applied within a transaction with an isolation level such
  18275. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18276. // or updated by the mutation.
  18277. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18278. switch {
  18279. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18280. id, exists := m.ID()
  18281. if exists {
  18282. return []uint64{id}, nil
  18283. }
  18284. fallthrough
  18285. case m.op.Is(OpUpdate | OpDelete):
  18286. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18287. default:
  18288. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18289. }
  18290. }
  18291. // SetCreatedAt sets the "created_at" field.
  18292. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18293. m.created_at = &t
  18294. }
  18295. // CreatedAt returns the value of the "created_at" field in the mutation.
  18296. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18297. v := m.created_at
  18298. if v == nil {
  18299. return
  18300. }
  18301. return *v, true
  18302. }
  18303. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18304. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18306. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18307. if !m.op.Is(OpUpdateOne) {
  18308. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18309. }
  18310. if m.id == nil || m.oldValue == nil {
  18311. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18312. }
  18313. oldValue, err := m.oldValue(ctx)
  18314. if err != nil {
  18315. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18316. }
  18317. return oldValue.CreatedAt, nil
  18318. }
  18319. // ResetCreatedAt resets all changes to the "created_at" field.
  18320. func (m *MsgMutation) ResetCreatedAt() {
  18321. m.created_at = nil
  18322. }
  18323. // SetUpdatedAt sets the "updated_at" field.
  18324. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18325. m.updated_at = &t
  18326. }
  18327. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18328. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18329. v := m.updated_at
  18330. if v == nil {
  18331. return
  18332. }
  18333. return *v, true
  18334. }
  18335. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18336. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18338. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18339. if !m.op.Is(OpUpdateOne) {
  18340. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18341. }
  18342. if m.id == nil || m.oldValue == nil {
  18343. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18344. }
  18345. oldValue, err := m.oldValue(ctx)
  18346. if err != nil {
  18347. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18348. }
  18349. return oldValue.UpdatedAt, nil
  18350. }
  18351. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18352. func (m *MsgMutation) ResetUpdatedAt() {
  18353. m.updated_at = nil
  18354. }
  18355. // SetDeletedAt sets the "deleted_at" field.
  18356. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18357. m.deleted_at = &t
  18358. }
  18359. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18360. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18361. v := m.deleted_at
  18362. if v == nil {
  18363. return
  18364. }
  18365. return *v, true
  18366. }
  18367. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18368. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18370. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18371. if !m.op.Is(OpUpdateOne) {
  18372. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18373. }
  18374. if m.id == nil || m.oldValue == nil {
  18375. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18376. }
  18377. oldValue, err := m.oldValue(ctx)
  18378. if err != nil {
  18379. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18380. }
  18381. return oldValue.DeletedAt, nil
  18382. }
  18383. // ClearDeletedAt clears the value of the "deleted_at" field.
  18384. func (m *MsgMutation) ClearDeletedAt() {
  18385. m.deleted_at = nil
  18386. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18387. }
  18388. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18389. func (m *MsgMutation) DeletedAtCleared() bool {
  18390. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18391. return ok
  18392. }
  18393. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18394. func (m *MsgMutation) ResetDeletedAt() {
  18395. m.deleted_at = nil
  18396. delete(m.clearedFields, msg.FieldDeletedAt)
  18397. }
  18398. // SetStatus sets the "status" field.
  18399. func (m *MsgMutation) SetStatus(u uint8) {
  18400. m.status = &u
  18401. m.addstatus = nil
  18402. }
  18403. // Status returns the value of the "status" field in the mutation.
  18404. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18405. v := m.status
  18406. if v == nil {
  18407. return
  18408. }
  18409. return *v, true
  18410. }
  18411. // OldStatus returns the old "status" field's value of the Msg entity.
  18412. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18414. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18415. if !m.op.Is(OpUpdateOne) {
  18416. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18417. }
  18418. if m.id == nil || m.oldValue == nil {
  18419. return v, errors.New("OldStatus requires an ID field in the mutation")
  18420. }
  18421. oldValue, err := m.oldValue(ctx)
  18422. if err != nil {
  18423. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18424. }
  18425. return oldValue.Status, nil
  18426. }
  18427. // AddStatus adds u to the "status" field.
  18428. func (m *MsgMutation) AddStatus(u int8) {
  18429. if m.addstatus != nil {
  18430. *m.addstatus += u
  18431. } else {
  18432. m.addstatus = &u
  18433. }
  18434. }
  18435. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18436. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18437. v := m.addstatus
  18438. if v == nil {
  18439. return
  18440. }
  18441. return *v, true
  18442. }
  18443. // ClearStatus clears the value of the "status" field.
  18444. func (m *MsgMutation) ClearStatus() {
  18445. m.status = nil
  18446. m.addstatus = nil
  18447. m.clearedFields[msg.FieldStatus] = struct{}{}
  18448. }
  18449. // StatusCleared returns if the "status" field was cleared in this mutation.
  18450. func (m *MsgMutation) StatusCleared() bool {
  18451. _, ok := m.clearedFields[msg.FieldStatus]
  18452. return ok
  18453. }
  18454. // ResetStatus resets all changes to the "status" field.
  18455. func (m *MsgMutation) ResetStatus() {
  18456. m.status = nil
  18457. m.addstatus = nil
  18458. delete(m.clearedFields, msg.FieldStatus)
  18459. }
  18460. // SetFromwxid sets the "fromwxid" field.
  18461. func (m *MsgMutation) SetFromwxid(s string) {
  18462. m.fromwxid = &s
  18463. }
  18464. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18465. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18466. v := m.fromwxid
  18467. if v == nil {
  18468. return
  18469. }
  18470. return *v, true
  18471. }
  18472. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18473. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18475. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18476. if !m.op.Is(OpUpdateOne) {
  18477. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18478. }
  18479. if m.id == nil || m.oldValue == nil {
  18480. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18481. }
  18482. oldValue, err := m.oldValue(ctx)
  18483. if err != nil {
  18484. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18485. }
  18486. return oldValue.Fromwxid, nil
  18487. }
  18488. // ClearFromwxid clears the value of the "fromwxid" field.
  18489. func (m *MsgMutation) ClearFromwxid() {
  18490. m.fromwxid = nil
  18491. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18492. }
  18493. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18494. func (m *MsgMutation) FromwxidCleared() bool {
  18495. _, ok := m.clearedFields[msg.FieldFromwxid]
  18496. return ok
  18497. }
  18498. // ResetFromwxid resets all changes to the "fromwxid" field.
  18499. func (m *MsgMutation) ResetFromwxid() {
  18500. m.fromwxid = nil
  18501. delete(m.clearedFields, msg.FieldFromwxid)
  18502. }
  18503. // SetToid sets the "toid" field.
  18504. func (m *MsgMutation) SetToid(s string) {
  18505. m.toid = &s
  18506. }
  18507. // Toid returns the value of the "toid" field in the mutation.
  18508. func (m *MsgMutation) Toid() (r string, exists bool) {
  18509. v := m.toid
  18510. if v == nil {
  18511. return
  18512. }
  18513. return *v, true
  18514. }
  18515. // OldToid returns the old "toid" field's value of the Msg entity.
  18516. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18518. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18519. if !m.op.Is(OpUpdateOne) {
  18520. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18521. }
  18522. if m.id == nil || m.oldValue == nil {
  18523. return v, errors.New("OldToid requires an ID field in the mutation")
  18524. }
  18525. oldValue, err := m.oldValue(ctx)
  18526. if err != nil {
  18527. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18528. }
  18529. return oldValue.Toid, nil
  18530. }
  18531. // ClearToid clears the value of the "toid" field.
  18532. func (m *MsgMutation) ClearToid() {
  18533. m.toid = nil
  18534. m.clearedFields[msg.FieldToid] = struct{}{}
  18535. }
  18536. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18537. func (m *MsgMutation) ToidCleared() bool {
  18538. _, ok := m.clearedFields[msg.FieldToid]
  18539. return ok
  18540. }
  18541. // ResetToid resets all changes to the "toid" field.
  18542. func (m *MsgMutation) ResetToid() {
  18543. m.toid = nil
  18544. delete(m.clearedFields, msg.FieldToid)
  18545. }
  18546. // SetMsgtype sets the "msgtype" field.
  18547. func (m *MsgMutation) SetMsgtype(i int32) {
  18548. m.msgtype = &i
  18549. m.addmsgtype = nil
  18550. }
  18551. // Msgtype returns the value of the "msgtype" field in the mutation.
  18552. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18553. v := m.msgtype
  18554. if v == nil {
  18555. return
  18556. }
  18557. return *v, true
  18558. }
  18559. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18560. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18562. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18563. if !m.op.Is(OpUpdateOne) {
  18564. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18565. }
  18566. if m.id == nil || m.oldValue == nil {
  18567. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18568. }
  18569. oldValue, err := m.oldValue(ctx)
  18570. if err != nil {
  18571. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18572. }
  18573. return oldValue.Msgtype, nil
  18574. }
  18575. // AddMsgtype adds i to the "msgtype" field.
  18576. func (m *MsgMutation) AddMsgtype(i int32) {
  18577. if m.addmsgtype != nil {
  18578. *m.addmsgtype += i
  18579. } else {
  18580. m.addmsgtype = &i
  18581. }
  18582. }
  18583. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18584. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18585. v := m.addmsgtype
  18586. if v == nil {
  18587. return
  18588. }
  18589. return *v, true
  18590. }
  18591. // ClearMsgtype clears the value of the "msgtype" field.
  18592. func (m *MsgMutation) ClearMsgtype() {
  18593. m.msgtype = nil
  18594. m.addmsgtype = nil
  18595. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18596. }
  18597. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18598. func (m *MsgMutation) MsgtypeCleared() bool {
  18599. _, ok := m.clearedFields[msg.FieldMsgtype]
  18600. return ok
  18601. }
  18602. // ResetMsgtype resets all changes to the "msgtype" field.
  18603. func (m *MsgMutation) ResetMsgtype() {
  18604. m.msgtype = nil
  18605. m.addmsgtype = nil
  18606. delete(m.clearedFields, msg.FieldMsgtype)
  18607. }
  18608. // SetMsg sets the "msg" field.
  18609. func (m *MsgMutation) SetMsg(s string) {
  18610. m.msg = &s
  18611. }
  18612. // Msg returns the value of the "msg" field in the mutation.
  18613. func (m *MsgMutation) Msg() (r string, exists bool) {
  18614. v := m.msg
  18615. if v == nil {
  18616. return
  18617. }
  18618. return *v, true
  18619. }
  18620. // OldMsg returns the old "msg" field's value of the Msg entity.
  18621. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18623. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18624. if !m.op.Is(OpUpdateOne) {
  18625. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18626. }
  18627. if m.id == nil || m.oldValue == nil {
  18628. return v, errors.New("OldMsg requires an ID field in the mutation")
  18629. }
  18630. oldValue, err := m.oldValue(ctx)
  18631. if err != nil {
  18632. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18633. }
  18634. return oldValue.Msg, nil
  18635. }
  18636. // ClearMsg clears the value of the "msg" field.
  18637. func (m *MsgMutation) ClearMsg() {
  18638. m.msg = nil
  18639. m.clearedFields[msg.FieldMsg] = struct{}{}
  18640. }
  18641. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18642. func (m *MsgMutation) MsgCleared() bool {
  18643. _, ok := m.clearedFields[msg.FieldMsg]
  18644. return ok
  18645. }
  18646. // ResetMsg resets all changes to the "msg" field.
  18647. func (m *MsgMutation) ResetMsg() {
  18648. m.msg = nil
  18649. delete(m.clearedFields, msg.FieldMsg)
  18650. }
  18651. // SetBatchNo sets the "batch_no" field.
  18652. func (m *MsgMutation) SetBatchNo(s string) {
  18653. m.batch_no = &s
  18654. }
  18655. // BatchNo returns the value of the "batch_no" field in the mutation.
  18656. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18657. v := m.batch_no
  18658. if v == nil {
  18659. return
  18660. }
  18661. return *v, true
  18662. }
  18663. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18664. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18666. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18667. if !m.op.Is(OpUpdateOne) {
  18668. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18669. }
  18670. if m.id == nil || m.oldValue == nil {
  18671. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18672. }
  18673. oldValue, err := m.oldValue(ctx)
  18674. if err != nil {
  18675. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18676. }
  18677. return oldValue.BatchNo, nil
  18678. }
  18679. // ClearBatchNo clears the value of the "batch_no" field.
  18680. func (m *MsgMutation) ClearBatchNo() {
  18681. m.batch_no = nil
  18682. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18683. }
  18684. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18685. func (m *MsgMutation) BatchNoCleared() bool {
  18686. _, ok := m.clearedFields[msg.FieldBatchNo]
  18687. return ok
  18688. }
  18689. // ResetBatchNo resets all changes to the "batch_no" field.
  18690. func (m *MsgMutation) ResetBatchNo() {
  18691. m.batch_no = nil
  18692. delete(m.clearedFields, msg.FieldBatchNo)
  18693. }
  18694. // Where appends a list predicates to the MsgMutation builder.
  18695. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18696. m.predicates = append(m.predicates, ps...)
  18697. }
  18698. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18699. // users can use type-assertion to append predicates that do not depend on any generated package.
  18700. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18701. p := make([]predicate.Msg, len(ps))
  18702. for i := range ps {
  18703. p[i] = ps[i]
  18704. }
  18705. m.Where(p...)
  18706. }
  18707. // Op returns the operation name.
  18708. func (m *MsgMutation) Op() Op {
  18709. return m.op
  18710. }
  18711. // SetOp allows setting the mutation operation.
  18712. func (m *MsgMutation) SetOp(op Op) {
  18713. m.op = op
  18714. }
  18715. // Type returns the node type of this mutation (Msg).
  18716. func (m *MsgMutation) Type() string {
  18717. return m.typ
  18718. }
  18719. // Fields returns all fields that were changed during this mutation. Note that in
  18720. // order to get all numeric fields that were incremented/decremented, call
  18721. // AddedFields().
  18722. func (m *MsgMutation) Fields() []string {
  18723. fields := make([]string, 0, 9)
  18724. if m.created_at != nil {
  18725. fields = append(fields, msg.FieldCreatedAt)
  18726. }
  18727. if m.updated_at != nil {
  18728. fields = append(fields, msg.FieldUpdatedAt)
  18729. }
  18730. if m.deleted_at != nil {
  18731. fields = append(fields, msg.FieldDeletedAt)
  18732. }
  18733. if m.status != nil {
  18734. fields = append(fields, msg.FieldStatus)
  18735. }
  18736. if m.fromwxid != nil {
  18737. fields = append(fields, msg.FieldFromwxid)
  18738. }
  18739. if m.toid != nil {
  18740. fields = append(fields, msg.FieldToid)
  18741. }
  18742. if m.msgtype != nil {
  18743. fields = append(fields, msg.FieldMsgtype)
  18744. }
  18745. if m.msg != nil {
  18746. fields = append(fields, msg.FieldMsg)
  18747. }
  18748. if m.batch_no != nil {
  18749. fields = append(fields, msg.FieldBatchNo)
  18750. }
  18751. return fields
  18752. }
  18753. // Field returns the value of a field with the given name. The second boolean
  18754. // return value indicates that this field was not set, or was not defined in the
  18755. // schema.
  18756. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18757. switch name {
  18758. case msg.FieldCreatedAt:
  18759. return m.CreatedAt()
  18760. case msg.FieldUpdatedAt:
  18761. return m.UpdatedAt()
  18762. case msg.FieldDeletedAt:
  18763. return m.DeletedAt()
  18764. case msg.FieldStatus:
  18765. return m.Status()
  18766. case msg.FieldFromwxid:
  18767. return m.Fromwxid()
  18768. case msg.FieldToid:
  18769. return m.Toid()
  18770. case msg.FieldMsgtype:
  18771. return m.Msgtype()
  18772. case msg.FieldMsg:
  18773. return m.Msg()
  18774. case msg.FieldBatchNo:
  18775. return m.BatchNo()
  18776. }
  18777. return nil, false
  18778. }
  18779. // OldField returns the old value of the field from the database. An error is
  18780. // returned if the mutation operation is not UpdateOne, or the query to the
  18781. // database failed.
  18782. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18783. switch name {
  18784. case msg.FieldCreatedAt:
  18785. return m.OldCreatedAt(ctx)
  18786. case msg.FieldUpdatedAt:
  18787. return m.OldUpdatedAt(ctx)
  18788. case msg.FieldDeletedAt:
  18789. return m.OldDeletedAt(ctx)
  18790. case msg.FieldStatus:
  18791. return m.OldStatus(ctx)
  18792. case msg.FieldFromwxid:
  18793. return m.OldFromwxid(ctx)
  18794. case msg.FieldToid:
  18795. return m.OldToid(ctx)
  18796. case msg.FieldMsgtype:
  18797. return m.OldMsgtype(ctx)
  18798. case msg.FieldMsg:
  18799. return m.OldMsg(ctx)
  18800. case msg.FieldBatchNo:
  18801. return m.OldBatchNo(ctx)
  18802. }
  18803. return nil, fmt.Errorf("unknown Msg field %s", name)
  18804. }
  18805. // SetField sets the value of a field with the given name. It returns an error if
  18806. // the field is not defined in the schema, or if the type mismatched the field
  18807. // type.
  18808. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18809. switch name {
  18810. case msg.FieldCreatedAt:
  18811. v, ok := value.(time.Time)
  18812. if !ok {
  18813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18814. }
  18815. m.SetCreatedAt(v)
  18816. return nil
  18817. case msg.FieldUpdatedAt:
  18818. v, ok := value.(time.Time)
  18819. if !ok {
  18820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18821. }
  18822. m.SetUpdatedAt(v)
  18823. return nil
  18824. case msg.FieldDeletedAt:
  18825. v, ok := value.(time.Time)
  18826. if !ok {
  18827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18828. }
  18829. m.SetDeletedAt(v)
  18830. return nil
  18831. case msg.FieldStatus:
  18832. v, ok := value.(uint8)
  18833. if !ok {
  18834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18835. }
  18836. m.SetStatus(v)
  18837. return nil
  18838. case msg.FieldFromwxid:
  18839. v, ok := value.(string)
  18840. if !ok {
  18841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18842. }
  18843. m.SetFromwxid(v)
  18844. return nil
  18845. case msg.FieldToid:
  18846. v, ok := value.(string)
  18847. if !ok {
  18848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18849. }
  18850. m.SetToid(v)
  18851. return nil
  18852. case msg.FieldMsgtype:
  18853. v, ok := value.(int32)
  18854. if !ok {
  18855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18856. }
  18857. m.SetMsgtype(v)
  18858. return nil
  18859. case msg.FieldMsg:
  18860. v, ok := value.(string)
  18861. if !ok {
  18862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18863. }
  18864. m.SetMsg(v)
  18865. return nil
  18866. case msg.FieldBatchNo:
  18867. v, ok := value.(string)
  18868. if !ok {
  18869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18870. }
  18871. m.SetBatchNo(v)
  18872. return nil
  18873. }
  18874. return fmt.Errorf("unknown Msg field %s", name)
  18875. }
  18876. // AddedFields returns all numeric fields that were incremented/decremented during
  18877. // this mutation.
  18878. func (m *MsgMutation) AddedFields() []string {
  18879. var fields []string
  18880. if m.addstatus != nil {
  18881. fields = append(fields, msg.FieldStatus)
  18882. }
  18883. if m.addmsgtype != nil {
  18884. fields = append(fields, msg.FieldMsgtype)
  18885. }
  18886. return fields
  18887. }
  18888. // AddedField returns the numeric value that was incremented/decremented on a field
  18889. // with the given name. The second boolean return value indicates that this field
  18890. // was not set, or was not defined in the schema.
  18891. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18892. switch name {
  18893. case msg.FieldStatus:
  18894. return m.AddedStatus()
  18895. case msg.FieldMsgtype:
  18896. return m.AddedMsgtype()
  18897. }
  18898. return nil, false
  18899. }
  18900. // AddField adds the value to the field with the given name. It returns an error if
  18901. // the field is not defined in the schema, or if the type mismatched the field
  18902. // type.
  18903. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18904. switch name {
  18905. case msg.FieldStatus:
  18906. v, ok := value.(int8)
  18907. if !ok {
  18908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18909. }
  18910. m.AddStatus(v)
  18911. return nil
  18912. case msg.FieldMsgtype:
  18913. v, ok := value.(int32)
  18914. if !ok {
  18915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18916. }
  18917. m.AddMsgtype(v)
  18918. return nil
  18919. }
  18920. return fmt.Errorf("unknown Msg numeric field %s", name)
  18921. }
  18922. // ClearedFields returns all nullable fields that were cleared during this
  18923. // mutation.
  18924. func (m *MsgMutation) ClearedFields() []string {
  18925. var fields []string
  18926. if m.FieldCleared(msg.FieldDeletedAt) {
  18927. fields = append(fields, msg.FieldDeletedAt)
  18928. }
  18929. if m.FieldCleared(msg.FieldStatus) {
  18930. fields = append(fields, msg.FieldStatus)
  18931. }
  18932. if m.FieldCleared(msg.FieldFromwxid) {
  18933. fields = append(fields, msg.FieldFromwxid)
  18934. }
  18935. if m.FieldCleared(msg.FieldToid) {
  18936. fields = append(fields, msg.FieldToid)
  18937. }
  18938. if m.FieldCleared(msg.FieldMsgtype) {
  18939. fields = append(fields, msg.FieldMsgtype)
  18940. }
  18941. if m.FieldCleared(msg.FieldMsg) {
  18942. fields = append(fields, msg.FieldMsg)
  18943. }
  18944. if m.FieldCleared(msg.FieldBatchNo) {
  18945. fields = append(fields, msg.FieldBatchNo)
  18946. }
  18947. return fields
  18948. }
  18949. // FieldCleared returns a boolean indicating if a field with the given name was
  18950. // cleared in this mutation.
  18951. func (m *MsgMutation) FieldCleared(name string) bool {
  18952. _, ok := m.clearedFields[name]
  18953. return ok
  18954. }
  18955. // ClearField clears the value of the field with the given name. It returns an
  18956. // error if the field is not defined in the schema.
  18957. func (m *MsgMutation) ClearField(name string) error {
  18958. switch name {
  18959. case msg.FieldDeletedAt:
  18960. m.ClearDeletedAt()
  18961. return nil
  18962. case msg.FieldStatus:
  18963. m.ClearStatus()
  18964. return nil
  18965. case msg.FieldFromwxid:
  18966. m.ClearFromwxid()
  18967. return nil
  18968. case msg.FieldToid:
  18969. m.ClearToid()
  18970. return nil
  18971. case msg.FieldMsgtype:
  18972. m.ClearMsgtype()
  18973. return nil
  18974. case msg.FieldMsg:
  18975. m.ClearMsg()
  18976. return nil
  18977. case msg.FieldBatchNo:
  18978. m.ClearBatchNo()
  18979. return nil
  18980. }
  18981. return fmt.Errorf("unknown Msg nullable field %s", name)
  18982. }
  18983. // ResetField resets all changes in the mutation for the field with the given name.
  18984. // It returns an error if the field is not defined in the schema.
  18985. func (m *MsgMutation) ResetField(name string) error {
  18986. switch name {
  18987. case msg.FieldCreatedAt:
  18988. m.ResetCreatedAt()
  18989. return nil
  18990. case msg.FieldUpdatedAt:
  18991. m.ResetUpdatedAt()
  18992. return nil
  18993. case msg.FieldDeletedAt:
  18994. m.ResetDeletedAt()
  18995. return nil
  18996. case msg.FieldStatus:
  18997. m.ResetStatus()
  18998. return nil
  18999. case msg.FieldFromwxid:
  19000. m.ResetFromwxid()
  19001. return nil
  19002. case msg.FieldToid:
  19003. m.ResetToid()
  19004. return nil
  19005. case msg.FieldMsgtype:
  19006. m.ResetMsgtype()
  19007. return nil
  19008. case msg.FieldMsg:
  19009. m.ResetMsg()
  19010. return nil
  19011. case msg.FieldBatchNo:
  19012. m.ResetBatchNo()
  19013. return nil
  19014. }
  19015. return fmt.Errorf("unknown Msg field %s", name)
  19016. }
  19017. // AddedEdges returns all edge names that were set/added in this mutation.
  19018. func (m *MsgMutation) AddedEdges() []string {
  19019. edges := make([]string, 0, 0)
  19020. return edges
  19021. }
  19022. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19023. // name in this mutation.
  19024. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  19025. return nil
  19026. }
  19027. // RemovedEdges returns all edge names that were removed in this mutation.
  19028. func (m *MsgMutation) RemovedEdges() []string {
  19029. edges := make([]string, 0, 0)
  19030. return edges
  19031. }
  19032. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19033. // the given name in this mutation.
  19034. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  19035. return nil
  19036. }
  19037. // ClearedEdges returns all edge names that were cleared in this mutation.
  19038. func (m *MsgMutation) ClearedEdges() []string {
  19039. edges := make([]string, 0, 0)
  19040. return edges
  19041. }
  19042. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19043. // was cleared in this mutation.
  19044. func (m *MsgMutation) EdgeCleared(name string) bool {
  19045. return false
  19046. }
  19047. // ClearEdge clears the value of the edge with the given name. It returns an error
  19048. // if that edge is not defined in the schema.
  19049. func (m *MsgMutation) ClearEdge(name string) error {
  19050. return fmt.Errorf("unknown Msg unique edge %s", name)
  19051. }
  19052. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19053. // It returns an error if the edge is not defined in the schema.
  19054. func (m *MsgMutation) ResetEdge(name string) error {
  19055. return fmt.Errorf("unknown Msg edge %s", name)
  19056. }
  19057. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19058. type PayRechargeMutation struct {
  19059. config
  19060. op Op
  19061. typ string
  19062. id *uint64
  19063. created_at *time.Time
  19064. updated_at *time.Time
  19065. deleted_at *time.Time
  19066. user_id *string
  19067. number *float32
  19068. addnumber *float32
  19069. status *int
  19070. addstatus *int
  19071. money *float32
  19072. addmoney *float32
  19073. out_trade_no *string
  19074. organization_id *uint64
  19075. addorganization_id *int64
  19076. clearedFields map[string]struct{}
  19077. done bool
  19078. oldValue func(context.Context) (*PayRecharge, error)
  19079. predicates []predicate.PayRecharge
  19080. }
  19081. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19082. // payrechargeOption allows management of the mutation configuration using functional options.
  19083. type payrechargeOption func(*PayRechargeMutation)
  19084. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19085. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19086. m := &PayRechargeMutation{
  19087. config: c,
  19088. op: op,
  19089. typ: TypePayRecharge,
  19090. clearedFields: make(map[string]struct{}),
  19091. }
  19092. for _, opt := range opts {
  19093. opt(m)
  19094. }
  19095. return m
  19096. }
  19097. // withPayRechargeID sets the ID field of the mutation.
  19098. func withPayRechargeID(id uint64) payrechargeOption {
  19099. return func(m *PayRechargeMutation) {
  19100. var (
  19101. err error
  19102. once sync.Once
  19103. value *PayRecharge
  19104. )
  19105. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19106. once.Do(func() {
  19107. if m.done {
  19108. err = errors.New("querying old values post mutation is not allowed")
  19109. } else {
  19110. value, err = m.Client().PayRecharge.Get(ctx, id)
  19111. }
  19112. })
  19113. return value, err
  19114. }
  19115. m.id = &id
  19116. }
  19117. }
  19118. // withPayRecharge sets the old PayRecharge of the mutation.
  19119. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19120. return func(m *PayRechargeMutation) {
  19121. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19122. return node, nil
  19123. }
  19124. m.id = &node.ID
  19125. }
  19126. }
  19127. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19128. // executed in a transaction (ent.Tx), a transactional client is returned.
  19129. func (m PayRechargeMutation) Client() *Client {
  19130. client := &Client{config: m.config}
  19131. client.init()
  19132. return client
  19133. }
  19134. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19135. // it returns an error otherwise.
  19136. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19137. if _, ok := m.driver.(*txDriver); !ok {
  19138. return nil, errors.New("ent: mutation is not running in a transaction")
  19139. }
  19140. tx := &Tx{config: m.config}
  19141. tx.init()
  19142. return tx, nil
  19143. }
  19144. // SetID sets the value of the id field. Note that this
  19145. // operation is only accepted on creation of PayRecharge entities.
  19146. func (m *PayRechargeMutation) SetID(id uint64) {
  19147. m.id = &id
  19148. }
  19149. // ID returns the ID value in the mutation. Note that the ID is only available
  19150. // if it was provided to the builder or after it was returned from the database.
  19151. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19152. if m.id == nil {
  19153. return
  19154. }
  19155. return *m.id, true
  19156. }
  19157. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19158. // That means, if the mutation is applied within a transaction with an isolation level such
  19159. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19160. // or updated by the mutation.
  19161. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19162. switch {
  19163. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19164. id, exists := m.ID()
  19165. if exists {
  19166. return []uint64{id}, nil
  19167. }
  19168. fallthrough
  19169. case m.op.Is(OpUpdate | OpDelete):
  19170. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19171. default:
  19172. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19173. }
  19174. }
  19175. // SetCreatedAt sets the "created_at" field.
  19176. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19177. m.created_at = &t
  19178. }
  19179. // CreatedAt returns the value of the "created_at" field in the mutation.
  19180. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19181. v := m.created_at
  19182. if v == nil {
  19183. return
  19184. }
  19185. return *v, true
  19186. }
  19187. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19188. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19190. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19191. if !m.op.Is(OpUpdateOne) {
  19192. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19193. }
  19194. if m.id == nil || m.oldValue == nil {
  19195. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19196. }
  19197. oldValue, err := m.oldValue(ctx)
  19198. if err != nil {
  19199. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19200. }
  19201. return oldValue.CreatedAt, nil
  19202. }
  19203. // ResetCreatedAt resets all changes to the "created_at" field.
  19204. func (m *PayRechargeMutation) ResetCreatedAt() {
  19205. m.created_at = nil
  19206. }
  19207. // SetUpdatedAt sets the "updated_at" field.
  19208. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19209. m.updated_at = &t
  19210. }
  19211. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19212. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19213. v := m.updated_at
  19214. if v == nil {
  19215. return
  19216. }
  19217. return *v, true
  19218. }
  19219. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19220. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19222. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19223. if !m.op.Is(OpUpdateOne) {
  19224. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19225. }
  19226. if m.id == nil || m.oldValue == nil {
  19227. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19228. }
  19229. oldValue, err := m.oldValue(ctx)
  19230. if err != nil {
  19231. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19232. }
  19233. return oldValue.UpdatedAt, nil
  19234. }
  19235. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19236. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19237. m.updated_at = nil
  19238. }
  19239. // SetDeletedAt sets the "deleted_at" field.
  19240. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19241. m.deleted_at = &t
  19242. }
  19243. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19244. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19245. v := m.deleted_at
  19246. if v == nil {
  19247. return
  19248. }
  19249. return *v, true
  19250. }
  19251. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19252. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19254. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19255. if !m.op.Is(OpUpdateOne) {
  19256. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19257. }
  19258. if m.id == nil || m.oldValue == nil {
  19259. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19260. }
  19261. oldValue, err := m.oldValue(ctx)
  19262. if err != nil {
  19263. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19264. }
  19265. return oldValue.DeletedAt, nil
  19266. }
  19267. // ClearDeletedAt clears the value of the "deleted_at" field.
  19268. func (m *PayRechargeMutation) ClearDeletedAt() {
  19269. m.deleted_at = nil
  19270. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19271. }
  19272. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19273. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19274. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19275. return ok
  19276. }
  19277. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19278. func (m *PayRechargeMutation) ResetDeletedAt() {
  19279. m.deleted_at = nil
  19280. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19281. }
  19282. // SetUserID sets the "user_id" field.
  19283. func (m *PayRechargeMutation) SetUserID(s string) {
  19284. m.user_id = &s
  19285. }
  19286. // UserID returns the value of the "user_id" field in the mutation.
  19287. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19288. v := m.user_id
  19289. if v == nil {
  19290. return
  19291. }
  19292. return *v, true
  19293. }
  19294. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19295. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19297. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19298. if !m.op.Is(OpUpdateOne) {
  19299. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19300. }
  19301. if m.id == nil || m.oldValue == nil {
  19302. return v, errors.New("OldUserID requires an ID field in the mutation")
  19303. }
  19304. oldValue, err := m.oldValue(ctx)
  19305. if err != nil {
  19306. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19307. }
  19308. return oldValue.UserID, nil
  19309. }
  19310. // ResetUserID resets all changes to the "user_id" field.
  19311. func (m *PayRechargeMutation) ResetUserID() {
  19312. m.user_id = nil
  19313. }
  19314. // SetNumber sets the "number" field.
  19315. func (m *PayRechargeMutation) SetNumber(f float32) {
  19316. m.number = &f
  19317. m.addnumber = nil
  19318. }
  19319. // Number returns the value of the "number" field in the mutation.
  19320. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19321. v := m.number
  19322. if v == nil {
  19323. return
  19324. }
  19325. return *v, true
  19326. }
  19327. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19328. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19330. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19331. if !m.op.Is(OpUpdateOne) {
  19332. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19333. }
  19334. if m.id == nil || m.oldValue == nil {
  19335. return v, errors.New("OldNumber requires an ID field in the mutation")
  19336. }
  19337. oldValue, err := m.oldValue(ctx)
  19338. if err != nil {
  19339. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19340. }
  19341. return oldValue.Number, nil
  19342. }
  19343. // AddNumber adds f to the "number" field.
  19344. func (m *PayRechargeMutation) AddNumber(f float32) {
  19345. if m.addnumber != nil {
  19346. *m.addnumber += f
  19347. } else {
  19348. m.addnumber = &f
  19349. }
  19350. }
  19351. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19352. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19353. v := m.addnumber
  19354. if v == nil {
  19355. return
  19356. }
  19357. return *v, true
  19358. }
  19359. // ResetNumber resets all changes to the "number" field.
  19360. func (m *PayRechargeMutation) ResetNumber() {
  19361. m.number = nil
  19362. m.addnumber = nil
  19363. }
  19364. // SetStatus sets the "status" field.
  19365. func (m *PayRechargeMutation) SetStatus(i int) {
  19366. m.status = &i
  19367. m.addstatus = nil
  19368. }
  19369. // Status returns the value of the "status" field in the mutation.
  19370. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19371. v := m.status
  19372. if v == nil {
  19373. return
  19374. }
  19375. return *v, true
  19376. }
  19377. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19378. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19380. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19381. if !m.op.Is(OpUpdateOne) {
  19382. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19383. }
  19384. if m.id == nil || m.oldValue == nil {
  19385. return v, errors.New("OldStatus requires an ID field in the mutation")
  19386. }
  19387. oldValue, err := m.oldValue(ctx)
  19388. if err != nil {
  19389. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19390. }
  19391. return oldValue.Status, nil
  19392. }
  19393. // AddStatus adds i to the "status" field.
  19394. func (m *PayRechargeMutation) AddStatus(i int) {
  19395. if m.addstatus != nil {
  19396. *m.addstatus += i
  19397. } else {
  19398. m.addstatus = &i
  19399. }
  19400. }
  19401. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19402. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19403. v := m.addstatus
  19404. if v == nil {
  19405. return
  19406. }
  19407. return *v, true
  19408. }
  19409. // ClearStatus clears the value of the "status" field.
  19410. func (m *PayRechargeMutation) ClearStatus() {
  19411. m.status = nil
  19412. m.addstatus = nil
  19413. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19414. }
  19415. // StatusCleared returns if the "status" field was cleared in this mutation.
  19416. func (m *PayRechargeMutation) StatusCleared() bool {
  19417. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19418. return ok
  19419. }
  19420. // ResetStatus resets all changes to the "status" field.
  19421. func (m *PayRechargeMutation) ResetStatus() {
  19422. m.status = nil
  19423. m.addstatus = nil
  19424. delete(m.clearedFields, payrecharge.FieldStatus)
  19425. }
  19426. // SetMoney sets the "money" field.
  19427. func (m *PayRechargeMutation) SetMoney(f float32) {
  19428. m.money = &f
  19429. m.addmoney = nil
  19430. }
  19431. // Money returns the value of the "money" field in the mutation.
  19432. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19433. v := m.money
  19434. if v == nil {
  19435. return
  19436. }
  19437. return *v, true
  19438. }
  19439. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19440. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19442. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19443. if !m.op.Is(OpUpdateOne) {
  19444. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19445. }
  19446. if m.id == nil || m.oldValue == nil {
  19447. return v, errors.New("OldMoney requires an ID field in the mutation")
  19448. }
  19449. oldValue, err := m.oldValue(ctx)
  19450. if err != nil {
  19451. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19452. }
  19453. return oldValue.Money, nil
  19454. }
  19455. // AddMoney adds f to the "money" field.
  19456. func (m *PayRechargeMutation) AddMoney(f float32) {
  19457. if m.addmoney != nil {
  19458. *m.addmoney += f
  19459. } else {
  19460. m.addmoney = &f
  19461. }
  19462. }
  19463. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19464. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19465. v := m.addmoney
  19466. if v == nil {
  19467. return
  19468. }
  19469. return *v, true
  19470. }
  19471. // ClearMoney clears the value of the "money" field.
  19472. func (m *PayRechargeMutation) ClearMoney() {
  19473. m.money = nil
  19474. m.addmoney = nil
  19475. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19476. }
  19477. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19478. func (m *PayRechargeMutation) MoneyCleared() bool {
  19479. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19480. return ok
  19481. }
  19482. // ResetMoney resets all changes to the "money" field.
  19483. func (m *PayRechargeMutation) ResetMoney() {
  19484. m.money = nil
  19485. m.addmoney = nil
  19486. delete(m.clearedFields, payrecharge.FieldMoney)
  19487. }
  19488. // SetOutTradeNo sets the "out_trade_no" field.
  19489. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19490. m.out_trade_no = &s
  19491. }
  19492. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19493. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19494. v := m.out_trade_no
  19495. if v == nil {
  19496. return
  19497. }
  19498. return *v, true
  19499. }
  19500. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19501. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19503. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19504. if !m.op.Is(OpUpdateOne) {
  19505. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19506. }
  19507. if m.id == nil || m.oldValue == nil {
  19508. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19509. }
  19510. oldValue, err := m.oldValue(ctx)
  19511. if err != nil {
  19512. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19513. }
  19514. return oldValue.OutTradeNo, nil
  19515. }
  19516. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19517. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19518. m.out_trade_no = nil
  19519. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19520. }
  19521. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19522. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19523. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19524. return ok
  19525. }
  19526. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19527. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19528. m.out_trade_no = nil
  19529. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19530. }
  19531. // SetOrganizationID sets the "organization_id" field.
  19532. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19533. m.organization_id = &u
  19534. m.addorganization_id = nil
  19535. }
  19536. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19537. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19538. v := m.organization_id
  19539. if v == nil {
  19540. return
  19541. }
  19542. return *v, true
  19543. }
  19544. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19545. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19547. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19548. if !m.op.Is(OpUpdateOne) {
  19549. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19550. }
  19551. if m.id == nil || m.oldValue == nil {
  19552. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19553. }
  19554. oldValue, err := m.oldValue(ctx)
  19555. if err != nil {
  19556. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19557. }
  19558. return oldValue.OrganizationID, nil
  19559. }
  19560. // AddOrganizationID adds u to the "organization_id" field.
  19561. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19562. if m.addorganization_id != nil {
  19563. *m.addorganization_id += u
  19564. } else {
  19565. m.addorganization_id = &u
  19566. }
  19567. }
  19568. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19569. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19570. v := m.addorganization_id
  19571. if v == nil {
  19572. return
  19573. }
  19574. return *v, true
  19575. }
  19576. // ResetOrganizationID resets all changes to the "organization_id" field.
  19577. func (m *PayRechargeMutation) ResetOrganizationID() {
  19578. m.organization_id = nil
  19579. m.addorganization_id = nil
  19580. }
  19581. // Where appends a list predicates to the PayRechargeMutation builder.
  19582. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19583. m.predicates = append(m.predicates, ps...)
  19584. }
  19585. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19586. // users can use type-assertion to append predicates that do not depend on any generated package.
  19587. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19588. p := make([]predicate.PayRecharge, len(ps))
  19589. for i := range ps {
  19590. p[i] = ps[i]
  19591. }
  19592. m.Where(p...)
  19593. }
  19594. // Op returns the operation name.
  19595. func (m *PayRechargeMutation) Op() Op {
  19596. return m.op
  19597. }
  19598. // SetOp allows setting the mutation operation.
  19599. func (m *PayRechargeMutation) SetOp(op Op) {
  19600. m.op = op
  19601. }
  19602. // Type returns the node type of this mutation (PayRecharge).
  19603. func (m *PayRechargeMutation) Type() string {
  19604. return m.typ
  19605. }
  19606. // Fields returns all fields that were changed during this mutation. Note that in
  19607. // order to get all numeric fields that were incremented/decremented, call
  19608. // AddedFields().
  19609. func (m *PayRechargeMutation) Fields() []string {
  19610. fields := make([]string, 0, 9)
  19611. if m.created_at != nil {
  19612. fields = append(fields, payrecharge.FieldCreatedAt)
  19613. }
  19614. if m.updated_at != nil {
  19615. fields = append(fields, payrecharge.FieldUpdatedAt)
  19616. }
  19617. if m.deleted_at != nil {
  19618. fields = append(fields, payrecharge.FieldDeletedAt)
  19619. }
  19620. if m.user_id != nil {
  19621. fields = append(fields, payrecharge.FieldUserID)
  19622. }
  19623. if m.number != nil {
  19624. fields = append(fields, payrecharge.FieldNumber)
  19625. }
  19626. if m.status != nil {
  19627. fields = append(fields, payrecharge.FieldStatus)
  19628. }
  19629. if m.money != nil {
  19630. fields = append(fields, payrecharge.FieldMoney)
  19631. }
  19632. if m.out_trade_no != nil {
  19633. fields = append(fields, payrecharge.FieldOutTradeNo)
  19634. }
  19635. if m.organization_id != nil {
  19636. fields = append(fields, payrecharge.FieldOrganizationID)
  19637. }
  19638. return fields
  19639. }
  19640. // Field returns the value of a field with the given name. The second boolean
  19641. // return value indicates that this field was not set, or was not defined in the
  19642. // schema.
  19643. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19644. switch name {
  19645. case payrecharge.FieldCreatedAt:
  19646. return m.CreatedAt()
  19647. case payrecharge.FieldUpdatedAt:
  19648. return m.UpdatedAt()
  19649. case payrecharge.FieldDeletedAt:
  19650. return m.DeletedAt()
  19651. case payrecharge.FieldUserID:
  19652. return m.UserID()
  19653. case payrecharge.FieldNumber:
  19654. return m.Number()
  19655. case payrecharge.FieldStatus:
  19656. return m.Status()
  19657. case payrecharge.FieldMoney:
  19658. return m.Money()
  19659. case payrecharge.FieldOutTradeNo:
  19660. return m.OutTradeNo()
  19661. case payrecharge.FieldOrganizationID:
  19662. return m.OrganizationID()
  19663. }
  19664. return nil, false
  19665. }
  19666. // OldField returns the old value of the field from the database. An error is
  19667. // returned if the mutation operation is not UpdateOne, or the query to the
  19668. // database failed.
  19669. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19670. switch name {
  19671. case payrecharge.FieldCreatedAt:
  19672. return m.OldCreatedAt(ctx)
  19673. case payrecharge.FieldUpdatedAt:
  19674. return m.OldUpdatedAt(ctx)
  19675. case payrecharge.FieldDeletedAt:
  19676. return m.OldDeletedAt(ctx)
  19677. case payrecharge.FieldUserID:
  19678. return m.OldUserID(ctx)
  19679. case payrecharge.FieldNumber:
  19680. return m.OldNumber(ctx)
  19681. case payrecharge.FieldStatus:
  19682. return m.OldStatus(ctx)
  19683. case payrecharge.FieldMoney:
  19684. return m.OldMoney(ctx)
  19685. case payrecharge.FieldOutTradeNo:
  19686. return m.OldOutTradeNo(ctx)
  19687. case payrecharge.FieldOrganizationID:
  19688. return m.OldOrganizationID(ctx)
  19689. }
  19690. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19691. }
  19692. // SetField sets the value of a field with the given name. It returns an error if
  19693. // the field is not defined in the schema, or if the type mismatched the field
  19694. // type.
  19695. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19696. switch name {
  19697. case payrecharge.FieldCreatedAt:
  19698. v, ok := value.(time.Time)
  19699. if !ok {
  19700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19701. }
  19702. m.SetCreatedAt(v)
  19703. return nil
  19704. case payrecharge.FieldUpdatedAt:
  19705. v, ok := value.(time.Time)
  19706. if !ok {
  19707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19708. }
  19709. m.SetUpdatedAt(v)
  19710. return nil
  19711. case payrecharge.FieldDeletedAt:
  19712. v, ok := value.(time.Time)
  19713. if !ok {
  19714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19715. }
  19716. m.SetDeletedAt(v)
  19717. return nil
  19718. case payrecharge.FieldUserID:
  19719. v, ok := value.(string)
  19720. if !ok {
  19721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19722. }
  19723. m.SetUserID(v)
  19724. return nil
  19725. case payrecharge.FieldNumber:
  19726. v, ok := value.(float32)
  19727. if !ok {
  19728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19729. }
  19730. m.SetNumber(v)
  19731. return nil
  19732. case payrecharge.FieldStatus:
  19733. v, ok := value.(int)
  19734. if !ok {
  19735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19736. }
  19737. m.SetStatus(v)
  19738. return nil
  19739. case payrecharge.FieldMoney:
  19740. v, ok := value.(float32)
  19741. if !ok {
  19742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19743. }
  19744. m.SetMoney(v)
  19745. return nil
  19746. case payrecharge.FieldOutTradeNo:
  19747. v, ok := value.(string)
  19748. if !ok {
  19749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19750. }
  19751. m.SetOutTradeNo(v)
  19752. return nil
  19753. case payrecharge.FieldOrganizationID:
  19754. v, ok := value.(uint64)
  19755. if !ok {
  19756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19757. }
  19758. m.SetOrganizationID(v)
  19759. return nil
  19760. }
  19761. return fmt.Errorf("unknown PayRecharge field %s", name)
  19762. }
  19763. // AddedFields returns all numeric fields that were incremented/decremented during
  19764. // this mutation.
  19765. func (m *PayRechargeMutation) AddedFields() []string {
  19766. var fields []string
  19767. if m.addnumber != nil {
  19768. fields = append(fields, payrecharge.FieldNumber)
  19769. }
  19770. if m.addstatus != nil {
  19771. fields = append(fields, payrecharge.FieldStatus)
  19772. }
  19773. if m.addmoney != nil {
  19774. fields = append(fields, payrecharge.FieldMoney)
  19775. }
  19776. if m.addorganization_id != nil {
  19777. fields = append(fields, payrecharge.FieldOrganizationID)
  19778. }
  19779. return fields
  19780. }
  19781. // AddedField returns the numeric value that was incremented/decremented on a field
  19782. // with the given name. The second boolean return value indicates that this field
  19783. // was not set, or was not defined in the schema.
  19784. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19785. switch name {
  19786. case payrecharge.FieldNumber:
  19787. return m.AddedNumber()
  19788. case payrecharge.FieldStatus:
  19789. return m.AddedStatus()
  19790. case payrecharge.FieldMoney:
  19791. return m.AddedMoney()
  19792. case payrecharge.FieldOrganizationID:
  19793. return m.AddedOrganizationID()
  19794. }
  19795. return nil, false
  19796. }
  19797. // AddField adds the value to the field with the given name. It returns an error if
  19798. // the field is not defined in the schema, or if the type mismatched the field
  19799. // type.
  19800. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19801. switch name {
  19802. case payrecharge.FieldNumber:
  19803. v, ok := value.(float32)
  19804. if !ok {
  19805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19806. }
  19807. m.AddNumber(v)
  19808. return nil
  19809. case payrecharge.FieldStatus:
  19810. v, ok := value.(int)
  19811. if !ok {
  19812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19813. }
  19814. m.AddStatus(v)
  19815. return nil
  19816. case payrecharge.FieldMoney:
  19817. v, ok := value.(float32)
  19818. if !ok {
  19819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19820. }
  19821. m.AddMoney(v)
  19822. return nil
  19823. case payrecharge.FieldOrganizationID:
  19824. v, ok := value.(int64)
  19825. if !ok {
  19826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19827. }
  19828. m.AddOrganizationID(v)
  19829. return nil
  19830. }
  19831. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19832. }
  19833. // ClearedFields returns all nullable fields that were cleared during this
  19834. // mutation.
  19835. func (m *PayRechargeMutation) ClearedFields() []string {
  19836. var fields []string
  19837. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19838. fields = append(fields, payrecharge.FieldDeletedAt)
  19839. }
  19840. if m.FieldCleared(payrecharge.FieldStatus) {
  19841. fields = append(fields, payrecharge.FieldStatus)
  19842. }
  19843. if m.FieldCleared(payrecharge.FieldMoney) {
  19844. fields = append(fields, payrecharge.FieldMoney)
  19845. }
  19846. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19847. fields = append(fields, payrecharge.FieldOutTradeNo)
  19848. }
  19849. return fields
  19850. }
  19851. // FieldCleared returns a boolean indicating if a field with the given name was
  19852. // cleared in this mutation.
  19853. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19854. _, ok := m.clearedFields[name]
  19855. return ok
  19856. }
  19857. // ClearField clears the value of the field with the given name. It returns an
  19858. // error if the field is not defined in the schema.
  19859. func (m *PayRechargeMutation) ClearField(name string) error {
  19860. switch name {
  19861. case payrecharge.FieldDeletedAt:
  19862. m.ClearDeletedAt()
  19863. return nil
  19864. case payrecharge.FieldStatus:
  19865. m.ClearStatus()
  19866. return nil
  19867. case payrecharge.FieldMoney:
  19868. m.ClearMoney()
  19869. return nil
  19870. case payrecharge.FieldOutTradeNo:
  19871. m.ClearOutTradeNo()
  19872. return nil
  19873. }
  19874. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19875. }
  19876. // ResetField resets all changes in the mutation for the field with the given name.
  19877. // It returns an error if the field is not defined in the schema.
  19878. func (m *PayRechargeMutation) ResetField(name string) error {
  19879. switch name {
  19880. case payrecharge.FieldCreatedAt:
  19881. m.ResetCreatedAt()
  19882. return nil
  19883. case payrecharge.FieldUpdatedAt:
  19884. m.ResetUpdatedAt()
  19885. return nil
  19886. case payrecharge.FieldDeletedAt:
  19887. m.ResetDeletedAt()
  19888. return nil
  19889. case payrecharge.FieldUserID:
  19890. m.ResetUserID()
  19891. return nil
  19892. case payrecharge.FieldNumber:
  19893. m.ResetNumber()
  19894. return nil
  19895. case payrecharge.FieldStatus:
  19896. m.ResetStatus()
  19897. return nil
  19898. case payrecharge.FieldMoney:
  19899. m.ResetMoney()
  19900. return nil
  19901. case payrecharge.FieldOutTradeNo:
  19902. m.ResetOutTradeNo()
  19903. return nil
  19904. case payrecharge.FieldOrganizationID:
  19905. m.ResetOrganizationID()
  19906. return nil
  19907. }
  19908. return fmt.Errorf("unknown PayRecharge field %s", name)
  19909. }
  19910. // AddedEdges returns all edge names that were set/added in this mutation.
  19911. func (m *PayRechargeMutation) AddedEdges() []string {
  19912. edges := make([]string, 0, 0)
  19913. return edges
  19914. }
  19915. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19916. // name in this mutation.
  19917. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19918. return nil
  19919. }
  19920. // RemovedEdges returns all edge names that were removed in this mutation.
  19921. func (m *PayRechargeMutation) RemovedEdges() []string {
  19922. edges := make([]string, 0, 0)
  19923. return edges
  19924. }
  19925. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19926. // the given name in this mutation.
  19927. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19928. return nil
  19929. }
  19930. // ClearedEdges returns all edge names that were cleared in this mutation.
  19931. func (m *PayRechargeMutation) ClearedEdges() []string {
  19932. edges := make([]string, 0, 0)
  19933. return edges
  19934. }
  19935. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19936. // was cleared in this mutation.
  19937. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19938. return false
  19939. }
  19940. // ClearEdge clears the value of the edge with the given name. It returns an error
  19941. // if that edge is not defined in the schema.
  19942. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19943. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19944. }
  19945. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19946. // It returns an error if the edge is not defined in the schema.
  19947. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19948. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19949. }
  19950. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19951. type ServerMutation struct {
  19952. config
  19953. op Op
  19954. typ string
  19955. id *uint64
  19956. created_at *time.Time
  19957. updated_at *time.Time
  19958. status *uint8
  19959. addstatus *int8
  19960. deleted_at *time.Time
  19961. name *string
  19962. public_ip *string
  19963. private_ip *string
  19964. admin_port *string
  19965. clearedFields map[string]struct{}
  19966. wxs map[uint64]struct{}
  19967. removedwxs map[uint64]struct{}
  19968. clearedwxs bool
  19969. done bool
  19970. oldValue func(context.Context) (*Server, error)
  19971. predicates []predicate.Server
  19972. }
  19973. var _ ent.Mutation = (*ServerMutation)(nil)
  19974. // serverOption allows management of the mutation configuration using functional options.
  19975. type serverOption func(*ServerMutation)
  19976. // newServerMutation creates new mutation for the Server entity.
  19977. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19978. m := &ServerMutation{
  19979. config: c,
  19980. op: op,
  19981. typ: TypeServer,
  19982. clearedFields: make(map[string]struct{}),
  19983. }
  19984. for _, opt := range opts {
  19985. opt(m)
  19986. }
  19987. return m
  19988. }
  19989. // withServerID sets the ID field of the mutation.
  19990. func withServerID(id uint64) serverOption {
  19991. return func(m *ServerMutation) {
  19992. var (
  19993. err error
  19994. once sync.Once
  19995. value *Server
  19996. )
  19997. m.oldValue = func(ctx context.Context) (*Server, error) {
  19998. once.Do(func() {
  19999. if m.done {
  20000. err = errors.New("querying old values post mutation is not allowed")
  20001. } else {
  20002. value, err = m.Client().Server.Get(ctx, id)
  20003. }
  20004. })
  20005. return value, err
  20006. }
  20007. m.id = &id
  20008. }
  20009. }
  20010. // withServer sets the old Server of the mutation.
  20011. func withServer(node *Server) serverOption {
  20012. return func(m *ServerMutation) {
  20013. m.oldValue = func(context.Context) (*Server, error) {
  20014. return node, nil
  20015. }
  20016. m.id = &node.ID
  20017. }
  20018. }
  20019. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20020. // executed in a transaction (ent.Tx), a transactional client is returned.
  20021. func (m ServerMutation) Client() *Client {
  20022. client := &Client{config: m.config}
  20023. client.init()
  20024. return client
  20025. }
  20026. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20027. // it returns an error otherwise.
  20028. func (m ServerMutation) Tx() (*Tx, error) {
  20029. if _, ok := m.driver.(*txDriver); !ok {
  20030. return nil, errors.New("ent: mutation is not running in a transaction")
  20031. }
  20032. tx := &Tx{config: m.config}
  20033. tx.init()
  20034. return tx, nil
  20035. }
  20036. // SetID sets the value of the id field. Note that this
  20037. // operation is only accepted on creation of Server entities.
  20038. func (m *ServerMutation) SetID(id uint64) {
  20039. m.id = &id
  20040. }
  20041. // ID returns the ID value in the mutation. Note that the ID is only available
  20042. // if it was provided to the builder or after it was returned from the database.
  20043. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20044. if m.id == nil {
  20045. return
  20046. }
  20047. return *m.id, true
  20048. }
  20049. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20050. // That means, if the mutation is applied within a transaction with an isolation level such
  20051. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20052. // or updated by the mutation.
  20053. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20054. switch {
  20055. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20056. id, exists := m.ID()
  20057. if exists {
  20058. return []uint64{id}, nil
  20059. }
  20060. fallthrough
  20061. case m.op.Is(OpUpdate | OpDelete):
  20062. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20063. default:
  20064. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20065. }
  20066. }
  20067. // SetCreatedAt sets the "created_at" field.
  20068. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20069. m.created_at = &t
  20070. }
  20071. // CreatedAt returns the value of the "created_at" field in the mutation.
  20072. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20073. v := m.created_at
  20074. if v == nil {
  20075. return
  20076. }
  20077. return *v, true
  20078. }
  20079. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20080. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20082. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20083. if !m.op.Is(OpUpdateOne) {
  20084. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20085. }
  20086. if m.id == nil || m.oldValue == nil {
  20087. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20088. }
  20089. oldValue, err := m.oldValue(ctx)
  20090. if err != nil {
  20091. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20092. }
  20093. return oldValue.CreatedAt, nil
  20094. }
  20095. // ResetCreatedAt resets all changes to the "created_at" field.
  20096. func (m *ServerMutation) ResetCreatedAt() {
  20097. m.created_at = nil
  20098. }
  20099. // SetUpdatedAt sets the "updated_at" field.
  20100. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20101. m.updated_at = &t
  20102. }
  20103. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20104. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20105. v := m.updated_at
  20106. if v == nil {
  20107. return
  20108. }
  20109. return *v, true
  20110. }
  20111. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20112. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20114. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20115. if !m.op.Is(OpUpdateOne) {
  20116. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20117. }
  20118. if m.id == nil || m.oldValue == nil {
  20119. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20120. }
  20121. oldValue, err := m.oldValue(ctx)
  20122. if err != nil {
  20123. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20124. }
  20125. return oldValue.UpdatedAt, nil
  20126. }
  20127. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20128. func (m *ServerMutation) ResetUpdatedAt() {
  20129. m.updated_at = nil
  20130. }
  20131. // SetStatus sets the "status" field.
  20132. func (m *ServerMutation) SetStatus(u uint8) {
  20133. m.status = &u
  20134. m.addstatus = nil
  20135. }
  20136. // Status returns the value of the "status" field in the mutation.
  20137. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20138. v := m.status
  20139. if v == nil {
  20140. return
  20141. }
  20142. return *v, true
  20143. }
  20144. // OldStatus returns the old "status" field's value of the Server entity.
  20145. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20147. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20148. if !m.op.Is(OpUpdateOne) {
  20149. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20150. }
  20151. if m.id == nil || m.oldValue == nil {
  20152. return v, errors.New("OldStatus requires an ID field in the mutation")
  20153. }
  20154. oldValue, err := m.oldValue(ctx)
  20155. if err != nil {
  20156. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20157. }
  20158. return oldValue.Status, nil
  20159. }
  20160. // AddStatus adds u to the "status" field.
  20161. func (m *ServerMutation) AddStatus(u int8) {
  20162. if m.addstatus != nil {
  20163. *m.addstatus += u
  20164. } else {
  20165. m.addstatus = &u
  20166. }
  20167. }
  20168. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20169. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20170. v := m.addstatus
  20171. if v == nil {
  20172. return
  20173. }
  20174. return *v, true
  20175. }
  20176. // ClearStatus clears the value of the "status" field.
  20177. func (m *ServerMutation) ClearStatus() {
  20178. m.status = nil
  20179. m.addstatus = nil
  20180. m.clearedFields[server.FieldStatus] = struct{}{}
  20181. }
  20182. // StatusCleared returns if the "status" field was cleared in this mutation.
  20183. func (m *ServerMutation) StatusCleared() bool {
  20184. _, ok := m.clearedFields[server.FieldStatus]
  20185. return ok
  20186. }
  20187. // ResetStatus resets all changes to the "status" field.
  20188. func (m *ServerMutation) ResetStatus() {
  20189. m.status = nil
  20190. m.addstatus = nil
  20191. delete(m.clearedFields, server.FieldStatus)
  20192. }
  20193. // SetDeletedAt sets the "deleted_at" field.
  20194. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20195. m.deleted_at = &t
  20196. }
  20197. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20198. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20199. v := m.deleted_at
  20200. if v == nil {
  20201. return
  20202. }
  20203. return *v, true
  20204. }
  20205. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20206. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20208. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20209. if !m.op.Is(OpUpdateOne) {
  20210. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20211. }
  20212. if m.id == nil || m.oldValue == nil {
  20213. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20214. }
  20215. oldValue, err := m.oldValue(ctx)
  20216. if err != nil {
  20217. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20218. }
  20219. return oldValue.DeletedAt, nil
  20220. }
  20221. // ClearDeletedAt clears the value of the "deleted_at" field.
  20222. func (m *ServerMutation) ClearDeletedAt() {
  20223. m.deleted_at = nil
  20224. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20225. }
  20226. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20227. func (m *ServerMutation) DeletedAtCleared() bool {
  20228. _, ok := m.clearedFields[server.FieldDeletedAt]
  20229. return ok
  20230. }
  20231. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20232. func (m *ServerMutation) ResetDeletedAt() {
  20233. m.deleted_at = nil
  20234. delete(m.clearedFields, server.FieldDeletedAt)
  20235. }
  20236. // SetName sets the "name" field.
  20237. func (m *ServerMutation) SetName(s string) {
  20238. m.name = &s
  20239. }
  20240. // Name returns the value of the "name" field in the mutation.
  20241. func (m *ServerMutation) Name() (r string, exists bool) {
  20242. v := m.name
  20243. if v == nil {
  20244. return
  20245. }
  20246. return *v, true
  20247. }
  20248. // OldName returns the old "name" field's value of the Server entity.
  20249. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20251. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20252. if !m.op.Is(OpUpdateOne) {
  20253. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20254. }
  20255. if m.id == nil || m.oldValue == nil {
  20256. return v, errors.New("OldName requires an ID field in the mutation")
  20257. }
  20258. oldValue, err := m.oldValue(ctx)
  20259. if err != nil {
  20260. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20261. }
  20262. return oldValue.Name, nil
  20263. }
  20264. // ResetName resets all changes to the "name" field.
  20265. func (m *ServerMutation) ResetName() {
  20266. m.name = nil
  20267. }
  20268. // SetPublicIP sets the "public_ip" field.
  20269. func (m *ServerMutation) SetPublicIP(s string) {
  20270. m.public_ip = &s
  20271. }
  20272. // PublicIP returns the value of the "public_ip" field in the mutation.
  20273. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20274. v := m.public_ip
  20275. if v == nil {
  20276. return
  20277. }
  20278. return *v, true
  20279. }
  20280. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20281. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20283. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20284. if !m.op.Is(OpUpdateOne) {
  20285. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20286. }
  20287. if m.id == nil || m.oldValue == nil {
  20288. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20289. }
  20290. oldValue, err := m.oldValue(ctx)
  20291. if err != nil {
  20292. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20293. }
  20294. return oldValue.PublicIP, nil
  20295. }
  20296. // ResetPublicIP resets all changes to the "public_ip" field.
  20297. func (m *ServerMutation) ResetPublicIP() {
  20298. m.public_ip = nil
  20299. }
  20300. // SetPrivateIP sets the "private_ip" field.
  20301. func (m *ServerMutation) SetPrivateIP(s string) {
  20302. m.private_ip = &s
  20303. }
  20304. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20305. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20306. v := m.private_ip
  20307. if v == nil {
  20308. return
  20309. }
  20310. return *v, true
  20311. }
  20312. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20313. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20315. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20316. if !m.op.Is(OpUpdateOne) {
  20317. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20318. }
  20319. if m.id == nil || m.oldValue == nil {
  20320. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20321. }
  20322. oldValue, err := m.oldValue(ctx)
  20323. if err != nil {
  20324. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20325. }
  20326. return oldValue.PrivateIP, nil
  20327. }
  20328. // ResetPrivateIP resets all changes to the "private_ip" field.
  20329. func (m *ServerMutation) ResetPrivateIP() {
  20330. m.private_ip = nil
  20331. }
  20332. // SetAdminPort sets the "admin_port" field.
  20333. func (m *ServerMutation) SetAdminPort(s string) {
  20334. m.admin_port = &s
  20335. }
  20336. // AdminPort returns the value of the "admin_port" field in the mutation.
  20337. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20338. v := m.admin_port
  20339. if v == nil {
  20340. return
  20341. }
  20342. return *v, true
  20343. }
  20344. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20345. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20347. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20348. if !m.op.Is(OpUpdateOne) {
  20349. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20350. }
  20351. if m.id == nil || m.oldValue == nil {
  20352. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20353. }
  20354. oldValue, err := m.oldValue(ctx)
  20355. if err != nil {
  20356. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20357. }
  20358. return oldValue.AdminPort, nil
  20359. }
  20360. // ResetAdminPort resets all changes to the "admin_port" field.
  20361. func (m *ServerMutation) ResetAdminPort() {
  20362. m.admin_port = nil
  20363. }
  20364. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20365. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20366. if m.wxs == nil {
  20367. m.wxs = make(map[uint64]struct{})
  20368. }
  20369. for i := range ids {
  20370. m.wxs[ids[i]] = struct{}{}
  20371. }
  20372. }
  20373. // ClearWxs clears the "wxs" edge to the Wx entity.
  20374. func (m *ServerMutation) ClearWxs() {
  20375. m.clearedwxs = true
  20376. }
  20377. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20378. func (m *ServerMutation) WxsCleared() bool {
  20379. return m.clearedwxs
  20380. }
  20381. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20382. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20383. if m.removedwxs == nil {
  20384. m.removedwxs = make(map[uint64]struct{})
  20385. }
  20386. for i := range ids {
  20387. delete(m.wxs, ids[i])
  20388. m.removedwxs[ids[i]] = struct{}{}
  20389. }
  20390. }
  20391. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20392. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20393. for id := range m.removedwxs {
  20394. ids = append(ids, id)
  20395. }
  20396. return
  20397. }
  20398. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20399. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20400. for id := range m.wxs {
  20401. ids = append(ids, id)
  20402. }
  20403. return
  20404. }
  20405. // ResetWxs resets all changes to the "wxs" edge.
  20406. func (m *ServerMutation) ResetWxs() {
  20407. m.wxs = nil
  20408. m.clearedwxs = false
  20409. m.removedwxs = nil
  20410. }
  20411. // Where appends a list predicates to the ServerMutation builder.
  20412. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20413. m.predicates = append(m.predicates, ps...)
  20414. }
  20415. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20416. // users can use type-assertion to append predicates that do not depend on any generated package.
  20417. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20418. p := make([]predicate.Server, len(ps))
  20419. for i := range ps {
  20420. p[i] = ps[i]
  20421. }
  20422. m.Where(p...)
  20423. }
  20424. // Op returns the operation name.
  20425. func (m *ServerMutation) Op() Op {
  20426. return m.op
  20427. }
  20428. // SetOp allows setting the mutation operation.
  20429. func (m *ServerMutation) SetOp(op Op) {
  20430. m.op = op
  20431. }
  20432. // Type returns the node type of this mutation (Server).
  20433. func (m *ServerMutation) Type() string {
  20434. return m.typ
  20435. }
  20436. // Fields returns all fields that were changed during this mutation. Note that in
  20437. // order to get all numeric fields that were incremented/decremented, call
  20438. // AddedFields().
  20439. func (m *ServerMutation) Fields() []string {
  20440. fields := make([]string, 0, 8)
  20441. if m.created_at != nil {
  20442. fields = append(fields, server.FieldCreatedAt)
  20443. }
  20444. if m.updated_at != nil {
  20445. fields = append(fields, server.FieldUpdatedAt)
  20446. }
  20447. if m.status != nil {
  20448. fields = append(fields, server.FieldStatus)
  20449. }
  20450. if m.deleted_at != nil {
  20451. fields = append(fields, server.FieldDeletedAt)
  20452. }
  20453. if m.name != nil {
  20454. fields = append(fields, server.FieldName)
  20455. }
  20456. if m.public_ip != nil {
  20457. fields = append(fields, server.FieldPublicIP)
  20458. }
  20459. if m.private_ip != nil {
  20460. fields = append(fields, server.FieldPrivateIP)
  20461. }
  20462. if m.admin_port != nil {
  20463. fields = append(fields, server.FieldAdminPort)
  20464. }
  20465. return fields
  20466. }
  20467. // Field returns the value of a field with the given name. The second boolean
  20468. // return value indicates that this field was not set, or was not defined in the
  20469. // schema.
  20470. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20471. switch name {
  20472. case server.FieldCreatedAt:
  20473. return m.CreatedAt()
  20474. case server.FieldUpdatedAt:
  20475. return m.UpdatedAt()
  20476. case server.FieldStatus:
  20477. return m.Status()
  20478. case server.FieldDeletedAt:
  20479. return m.DeletedAt()
  20480. case server.FieldName:
  20481. return m.Name()
  20482. case server.FieldPublicIP:
  20483. return m.PublicIP()
  20484. case server.FieldPrivateIP:
  20485. return m.PrivateIP()
  20486. case server.FieldAdminPort:
  20487. return m.AdminPort()
  20488. }
  20489. return nil, false
  20490. }
  20491. // OldField returns the old value of the field from the database. An error is
  20492. // returned if the mutation operation is not UpdateOne, or the query to the
  20493. // database failed.
  20494. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20495. switch name {
  20496. case server.FieldCreatedAt:
  20497. return m.OldCreatedAt(ctx)
  20498. case server.FieldUpdatedAt:
  20499. return m.OldUpdatedAt(ctx)
  20500. case server.FieldStatus:
  20501. return m.OldStatus(ctx)
  20502. case server.FieldDeletedAt:
  20503. return m.OldDeletedAt(ctx)
  20504. case server.FieldName:
  20505. return m.OldName(ctx)
  20506. case server.FieldPublicIP:
  20507. return m.OldPublicIP(ctx)
  20508. case server.FieldPrivateIP:
  20509. return m.OldPrivateIP(ctx)
  20510. case server.FieldAdminPort:
  20511. return m.OldAdminPort(ctx)
  20512. }
  20513. return nil, fmt.Errorf("unknown Server field %s", name)
  20514. }
  20515. // SetField sets the value of a field with the given name. It returns an error if
  20516. // the field is not defined in the schema, or if the type mismatched the field
  20517. // type.
  20518. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20519. switch name {
  20520. case server.FieldCreatedAt:
  20521. v, ok := value.(time.Time)
  20522. if !ok {
  20523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20524. }
  20525. m.SetCreatedAt(v)
  20526. return nil
  20527. case server.FieldUpdatedAt:
  20528. v, ok := value.(time.Time)
  20529. if !ok {
  20530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20531. }
  20532. m.SetUpdatedAt(v)
  20533. return nil
  20534. case server.FieldStatus:
  20535. v, ok := value.(uint8)
  20536. if !ok {
  20537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20538. }
  20539. m.SetStatus(v)
  20540. return nil
  20541. case server.FieldDeletedAt:
  20542. v, ok := value.(time.Time)
  20543. if !ok {
  20544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20545. }
  20546. m.SetDeletedAt(v)
  20547. return nil
  20548. case server.FieldName:
  20549. v, ok := value.(string)
  20550. if !ok {
  20551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20552. }
  20553. m.SetName(v)
  20554. return nil
  20555. case server.FieldPublicIP:
  20556. v, ok := value.(string)
  20557. if !ok {
  20558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20559. }
  20560. m.SetPublicIP(v)
  20561. return nil
  20562. case server.FieldPrivateIP:
  20563. v, ok := value.(string)
  20564. if !ok {
  20565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20566. }
  20567. m.SetPrivateIP(v)
  20568. return nil
  20569. case server.FieldAdminPort:
  20570. v, ok := value.(string)
  20571. if !ok {
  20572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20573. }
  20574. m.SetAdminPort(v)
  20575. return nil
  20576. }
  20577. return fmt.Errorf("unknown Server field %s", name)
  20578. }
  20579. // AddedFields returns all numeric fields that were incremented/decremented during
  20580. // this mutation.
  20581. func (m *ServerMutation) AddedFields() []string {
  20582. var fields []string
  20583. if m.addstatus != nil {
  20584. fields = append(fields, server.FieldStatus)
  20585. }
  20586. return fields
  20587. }
  20588. // AddedField returns the numeric value that was incremented/decremented on a field
  20589. // with the given name. The second boolean return value indicates that this field
  20590. // was not set, or was not defined in the schema.
  20591. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20592. switch name {
  20593. case server.FieldStatus:
  20594. return m.AddedStatus()
  20595. }
  20596. return nil, false
  20597. }
  20598. // AddField adds the value to the field with the given name. It returns an error if
  20599. // the field is not defined in the schema, or if the type mismatched the field
  20600. // type.
  20601. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20602. switch name {
  20603. case server.FieldStatus:
  20604. v, ok := value.(int8)
  20605. if !ok {
  20606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20607. }
  20608. m.AddStatus(v)
  20609. return nil
  20610. }
  20611. return fmt.Errorf("unknown Server numeric field %s", name)
  20612. }
  20613. // ClearedFields returns all nullable fields that were cleared during this
  20614. // mutation.
  20615. func (m *ServerMutation) ClearedFields() []string {
  20616. var fields []string
  20617. if m.FieldCleared(server.FieldStatus) {
  20618. fields = append(fields, server.FieldStatus)
  20619. }
  20620. if m.FieldCleared(server.FieldDeletedAt) {
  20621. fields = append(fields, server.FieldDeletedAt)
  20622. }
  20623. return fields
  20624. }
  20625. // FieldCleared returns a boolean indicating if a field with the given name was
  20626. // cleared in this mutation.
  20627. func (m *ServerMutation) FieldCleared(name string) bool {
  20628. _, ok := m.clearedFields[name]
  20629. return ok
  20630. }
  20631. // ClearField clears the value of the field with the given name. It returns an
  20632. // error if the field is not defined in the schema.
  20633. func (m *ServerMutation) ClearField(name string) error {
  20634. switch name {
  20635. case server.FieldStatus:
  20636. m.ClearStatus()
  20637. return nil
  20638. case server.FieldDeletedAt:
  20639. m.ClearDeletedAt()
  20640. return nil
  20641. }
  20642. return fmt.Errorf("unknown Server nullable field %s", name)
  20643. }
  20644. // ResetField resets all changes in the mutation for the field with the given name.
  20645. // It returns an error if the field is not defined in the schema.
  20646. func (m *ServerMutation) ResetField(name string) error {
  20647. switch name {
  20648. case server.FieldCreatedAt:
  20649. m.ResetCreatedAt()
  20650. return nil
  20651. case server.FieldUpdatedAt:
  20652. m.ResetUpdatedAt()
  20653. return nil
  20654. case server.FieldStatus:
  20655. m.ResetStatus()
  20656. return nil
  20657. case server.FieldDeletedAt:
  20658. m.ResetDeletedAt()
  20659. return nil
  20660. case server.FieldName:
  20661. m.ResetName()
  20662. return nil
  20663. case server.FieldPublicIP:
  20664. m.ResetPublicIP()
  20665. return nil
  20666. case server.FieldPrivateIP:
  20667. m.ResetPrivateIP()
  20668. return nil
  20669. case server.FieldAdminPort:
  20670. m.ResetAdminPort()
  20671. return nil
  20672. }
  20673. return fmt.Errorf("unknown Server field %s", name)
  20674. }
  20675. // AddedEdges returns all edge names that were set/added in this mutation.
  20676. func (m *ServerMutation) AddedEdges() []string {
  20677. edges := make([]string, 0, 1)
  20678. if m.wxs != nil {
  20679. edges = append(edges, server.EdgeWxs)
  20680. }
  20681. return edges
  20682. }
  20683. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20684. // name in this mutation.
  20685. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20686. switch name {
  20687. case server.EdgeWxs:
  20688. ids := make([]ent.Value, 0, len(m.wxs))
  20689. for id := range m.wxs {
  20690. ids = append(ids, id)
  20691. }
  20692. return ids
  20693. }
  20694. return nil
  20695. }
  20696. // RemovedEdges returns all edge names that were removed in this mutation.
  20697. func (m *ServerMutation) RemovedEdges() []string {
  20698. edges := make([]string, 0, 1)
  20699. if m.removedwxs != nil {
  20700. edges = append(edges, server.EdgeWxs)
  20701. }
  20702. return edges
  20703. }
  20704. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20705. // the given name in this mutation.
  20706. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20707. switch name {
  20708. case server.EdgeWxs:
  20709. ids := make([]ent.Value, 0, len(m.removedwxs))
  20710. for id := range m.removedwxs {
  20711. ids = append(ids, id)
  20712. }
  20713. return ids
  20714. }
  20715. return nil
  20716. }
  20717. // ClearedEdges returns all edge names that were cleared in this mutation.
  20718. func (m *ServerMutation) ClearedEdges() []string {
  20719. edges := make([]string, 0, 1)
  20720. if m.clearedwxs {
  20721. edges = append(edges, server.EdgeWxs)
  20722. }
  20723. return edges
  20724. }
  20725. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20726. // was cleared in this mutation.
  20727. func (m *ServerMutation) EdgeCleared(name string) bool {
  20728. switch name {
  20729. case server.EdgeWxs:
  20730. return m.clearedwxs
  20731. }
  20732. return false
  20733. }
  20734. // ClearEdge clears the value of the edge with the given name. It returns an error
  20735. // if that edge is not defined in the schema.
  20736. func (m *ServerMutation) ClearEdge(name string) error {
  20737. switch name {
  20738. }
  20739. return fmt.Errorf("unknown Server unique edge %s", name)
  20740. }
  20741. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20742. // It returns an error if the edge is not defined in the schema.
  20743. func (m *ServerMutation) ResetEdge(name string) error {
  20744. switch name {
  20745. case server.EdgeWxs:
  20746. m.ResetWxs()
  20747. return nil
  20748. }
  20749. return fmt.Errorf("unknown Server edge %s", name)
  20750. }
  20751. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20752. type SopNodeMutation struct {
  20753. config
  20754. op Op
  20755. typ string
  20756. id *uint64
  20757. created_at *time.Time
  20758. updated_at *time.Time
  20759. status *uint8
  20760. addstatus *int8
  20761. deleted_at *time.Time
  20762. parent_id *uint64
  20763. addparent_id *int64
  20764. name *string
  20765. condition_type *int
  20766. addcondition_type *int
  20767. condition_list *[]string
  20768. appendcondition_list []string
  20769. no_reply_condition *uint64
  20770. addno_reply_condition *int64
  20771. no_reply_unit *string
  20772. action_message *[]custom_types.Action
  20773. appendaction_message []custom_types.Action
  20774. action_label_add *[]uint64
  20775. appendaction_label_add []uint64
  20776. action_label_del *[]uint64
  20777. appendaction_label_del []uint64
  20778. action_forward **custom_types.ActionForward
  20779. clearedFields map[string]struct{}
  20780. sop_stage *uint64
  20781. clearedsop_stage bool
  20782. node_messages map[uint64]struct{}
  20783. removednode_messages map[uint64]struct{}
  20784. clearednode_messages bool
  20785. done bool
  20786. oldValue func(context.Context) (*SopNode, error)
  20787. predicates []predicate.SopNode
  20788. }
  20789. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20790. // sopnodeOption allows management of the mutation configuration using functional options.
  20791. type sopnodeOption func(*SopNodeMutation)
  20792. // newSopNodeMutation creates new mutation for the SopNode entity.
  20793. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20794. m := &SopNodeMutation{
  20795. config: c,
  20796. op: op,
  20797. typ: TypeSopNode,
  20798. clearedFields: make(map[string]struct{}),
  20799. }
  20800. for _, opt := range opts {
  20801. opt(m)
  20802. }
  20803. return m
  20804. }
  20805. // withSopNodeID sets the ID field of the mutation.
  20806. func withSopNodeID(id uint64) sopnodeOption {
  20807. return func(m *SopNodeMutation) {
  20808. var (
  20809. err error
  20810. once sync.Once
  20811. value *SopNode
  20812. )
  20813. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20814. once.Do(func() {
  20815. if m.done {
  20816. err = errors.New("querying old values post mutation is not allowed")
  20817. } else {
  20818. value, err = m.Client().SopNode.Get(ctx, id)
  20819. }
  20820. })
  20821. return value, err
  20822. }
  20823. m.id = &id
  20824. }
  20825. }
  20826. // withSopNode sets the old SopNode of the mutation.
  20827. func withSopNode(node *SopNode) sopnodeOption {
  20828. return func(m *SopNodeMutation) {
  20829. m.oldValue = func(context.Context) (*SopNode, error) {
  20830. return node, nil
  20831. }
  20832. m.id = &node.ID
  20833. }
  20834. }
  20835. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20836. // executed in a transaction (ent.Tx), a transactional client is returned.
  20837. func (m SopNodeMutation) Client() *Client {
  20838. client := &Client{config: m.config}
  20839. client.init()
  20840. return client
  20841. }
  20842. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20843. // it returns an error otherwise.
  20844. func (m SopNodeMutation) Tx() (*Tx, error) {
  20845. if _, ok := m.driver.(*txDriver); !ok {
  20846. return nil, errors.New("ent: mutation is not running in a transaction")
  20847. }
  20848. tx := &Tx{config: m.config}
  20849. tx.init()
  20850. return tx, nil
  20851. }
  20852. // SetID sets the value of the id field. Note that this
  20853. // operation is only accepted on creation of SopNode entities.
  20854. func (m *SopNodeMutation) SetID(id uint64) {
  20855. m.id = &id
  20856. }
  20857. // ID returns the ID value in the mutation. Note that the ID is only available
  20858. // if it was provided to the builder or after it was returned from the database.
  20859. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20860. if m.id == nil {
  20861. return
  20862. }
  20863. return *m.id, true
  20864. }
  20865. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20866. // That means, if the mutation is applied within a transaction with an isolation level such
  20867. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20868. // or updated by the mutation.
  20869. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20870. switch {
  20871. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20872. id, exists := m.ID()
  20873. if exists {
  20874. return []uint64{id}, nil
  20875. }
  20876. fallthrough
  20877. case m.op.Is(OpUpdate | OpDelete):
  20878. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20879. default:
  20880. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20881. }
  20882. }
  20883. // SetCreatedAt sets the "created_at" field.
  20884. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20885. m.created_at = &t
  20886. }
  20887. // CreatedAt returns the value of the "created_at" field in the mutation.
  20888. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20889. v := m.created_at
  20890. if v == nil {
  20891. return
  20892. }
  20893. return *v, true
  20894. }
  20895. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20896. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20898. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20899. if !m.op.Is(OpUpdateOne) {
  20900. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20901. }
  20902. if m.id == nil || m.oldValue == nil {
  20903. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20904. }
  20905. oldValue, err := m.oldValue(ctx)
  20906. if err != nil {
  20907. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20908. }
  20909. return oldValue.CreatedAt, nil
  20910. }
  20911. // ResetCreatedAt resets all changes to the "created_at" field.
  20912. func (m *SopNodeMutation) ResetCreatedAt() {
  20913. m.created_at = nil
  20914. }
  20915. // SetUpdatedAt sets the "updated_at" field.
  20916. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20917. m.updated_at = &t
  20918. }
  20919. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20920. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20921. v := m.updated_at
  20922. if v == nil {
  20923. return
  20924. }
  20925. return *v, true
  20926. }
  20927. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20928. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20930. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20931. if !m.op.Is(OpUpdateOne) {
  20932. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20933. }
  20934. if m.id == nil || m.oldValue == nil {
  20935. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20936. }
  20937. oldValue, err := m.oldValue(ctx)
  20938. if err != nil {
  20939. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20940. }
  20941. return oldValue.UpdatedAt, nil
  20942. }
  20943. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20944. func (m *SopNodeMutation) ResetUpdatedAt() {
  20945. m.updated_at = nil
  20946. }
  20947. // SetStatus sets the "status" field.
  20948. func (m *SopNodeMutation) SetStatus(u uint8) {
  20949. m.status = &u
  20950. m.addstatus = nil
  20951. }
  20952. // Status returns the value of the "status" field in the mutation.
  20953. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20954. v := m.status
  20955. if v == nil {
  20956. return
  20957. }
  20958. return *v, true
  20959. }
  20960. // OldStatus returns the old "status" field's value of the SopNode entity.
  20961. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20963. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20964. if !m.op.Is(OpUpdateOne) {
  20965. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20966. }
  20967. if m.id == nil || m.oldValue == nil {
  20968. return v, errors.New("OldStatus requires an ID field in the mutation")
  20969. }
  20970. oldValue, err := m.oldValue(ctx)
  20971. if err != nil {
  20972. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20973. }
  20974. return oldValue.Status, nil
  20975. }
  20976. // AddStatus adds u to the "status" field.
  20977. func (m *SopNodeMutation) AddStatus(u int8) {
  20978. if m.addstatus != nil {
  20979. *m.addstatus += u
  20980. } else {
  20981. m.addstatus = &u
  20982. }
  20983. }
  20984. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20985. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20986. v := m.addstatus
  20987. if v == nil {
  20988. return
  20989. }
  20990. return *v, true
  20991. }
  20992. // ClearStatus clears the value of the "status" field.
  20993. func (m *SopNodeMutation) ClearStatus() {
  20994. m.status = nil
  20995. m.addstatus = nil
  20996. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20997. }
  20998. // StatusCleared returns if the "status" field was cleared in this mutation.
  20999. func (m *SopNodeMutation) StatusCleared() bool {
  21000. _, ok := m.clearedFields[sopnode.FieldStatus]
  21001. return ok
  21002. }
  21003. // ResetStatus resets all changes to the "status" field.
  21004. func (m *SopNodeMutation) ResetStatus() {
  21005. m.status = nil
  21006. m.addstatus = nil
  21007. delete(m.clearedFields, sopnode.FieldStatus)
  21008. }
  21009. // SetDeletedAt sets the "deleted_at" field.
  21010. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  21011. m.deleted_at = &t
  21012. }
  21013. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21014. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  21015. v := m.deleted_at
  21016. if v == nil {
  21017. return
  21018. }
  21019. return *v, true
  21020. }
  21021. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  21022. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21024. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21025. if !m.op.Is(OpUpdateOne) {
  21026. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21027. }
  21028. if m.id == nil || m.oldValue == nil {
  21029. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21030. }
  21031. oldValue, err := m.oldValue(ctx)
  21032. if err != nil {
  21033. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21034. }
  21035. return oldValue.DeletedAt, nil
  21036. }
  21037. // ClearDeletedAt clears the value of the "deleted_at" field.
  21038. func (m *SopNodeMutation) ClearDeletedAt() {
  21039. m.deleted_at = nil
  21040. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21041. }
  21042. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21043. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21044. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21045. return ok
  21046. }
  21047. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21048. func (m *SopNodeMutation) ResetDeletedAt() {
  21049. m.deleted_at = nil
  21050. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21051. }
  21052. // SetStageID sets the "stage_id" field.
  21053. func (m *SopNodeMutation) SetStageID(u uint64) {
  21054. m.sop_stage = &u
  21055. }
  21056. // StageID returns the value of the "stage_id" field in the mutation.
  21057. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21058. v := m.sop_stage
  21059. if v == nil {
  21060. return
  21061. }
  21062. return *v, true
  21063. }
  21064. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21065. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21067. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21068. if !m.op.Is(OpUpdateOne) {
  21069. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21070. }
  21071. if m.id == nil || m.oldValue == nil {
  21072. return v, errors.New("OldStageID requires an ID field in the mutation")
  21073. }
  21074. oldValue, err := m.oldValue(ctx)
  21075. if err != nil {
  21076. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21077. }
  21078. return oldValue.StageID, nil
  21079. }
  21080. // ResetStageID resets all changes to the "stage_id" field.
  21081. func (m *SopNodeMutation) ResetStageID() {
  21082. m.sop_stage = nil
  21083. }
  21084. // SetParentID sets the "parent_id" field.
  21085. func (m *SopNodeMutation) SetParentID(u uint64) {
  21086. m.parent_id = &u
  21087. m.addparent_id = nil
  21088. }
  21089. // ParentID returns the value of the "parent_id" field in the mutation.
  21090. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21091. v := m.parent_id
  21092. if v == nil {
  21093. return
  21094. }
  21095. return *v, true
  21096. }
  21097. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21098. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21100. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21101. if !m.op.Is(OpUpdateOne) {
  21102. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21103. }
  21104. if m.id == nil || m.oldValue == nil {
  21105. return v, errors.New("OldParentID requires an ID field in the mutation")
  21106. }
  21107. oldValue, err := m.oldValue(ctx)
  21108. if err != nil {
  21109. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21110. }
  21111. return oldValue.ParentID, nil
  21112. }
  21113. // AddParentID adds u to the "parent_id" field.
  21114. func (m *SopNodeMutation) AddParentID(u int64) {
  21115. if m.addparent_id != nil {
  21116. *m.addparent_id += u
  21117. } else {
  21118. m.addparent_id = &u
  21119. }
  21120. }
  21121. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21122. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21123. v := m.addparent_id
  21124. if v == nil {
  21125. return
  21126. }
  21127. return *v, true
  21128. }
  21129. // ResetParentID resets all changes to the "parent_id" field.
  21130. func (m *SopNodeMutation) ResetParentID() {
  21131. m.parent_id = nil
  21132. m.addparent_id = nil
  21133. }
  21134. // SetName sets the "name" field.
  21135. func (m *SopNodeMutation) SetName(s string) {
  21136. m.name = &s
  21137. }
  21138. // Name returns the value of the "name" field in the mutation.
  21139. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21140. v := m.name
  21141. if v == nil {
  21142. return
  21143. }
  21144. return *v, true
  21145. }
  21146. // OldName returns the old "name" field's value of the SopNode entity.
  21147. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21149. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21150. if !m.op.Is(OpUpdateOne) {
  21151. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21152. }
  21153. if m.id == nil || m.oldValue == nil {
  21154. return v, errors.New("OldName requires an ID field in the mutation")
  21155. }
  21156. oldValue, err := m.oldValue(ctx)
  21157. if err != nil {
  21158. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21159. }
  21160. return oldValue.Name, nil
  21161. }
  21162. // ResetName resets all changes to the "name" field.
  21163. func (m *SopNodeMutation) ResetName() {
  21164. m.name = nil
  21165. }
  21166. // SetConditionType sets the "condition_type" field.
  21167. func (m *SopNodeMutation) SetConditionType(i int) {
  21168. m.condition_type = &i
  21169. m.addcondition_type = nil
  21170. }
  21171. // ConditionType returns the value of the "condition_type" field in the mutation.
  21172. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21173. v := m.condition_type
  21174. if v == nil {
  21175. return
  21176. }
  21177. return *v, true
  21178. }
  21179. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21180. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21182. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21183. if !m.op.Is(OpUpdateOne) {
  21184. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21185. }
  21186. if m.id == nil || m.oldValue == nil {
  21187. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21188. }
  21189. oldValue, err := m.oldValue(ctx)
  21190. if err != nil {
  21191. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21192. }
  21193. return oldValue.ConditionType, nil
  21194. }
  21195. // AddConditionType adds i to the "condition_type" field.
  21196. func (m *SopNodeMutation) AddConditionType(i int) {
  21197. if m.addcondition_type != nil {
  21198. *m.addcondition_type += i
  21199. } else {
  21200. m.addcondition_type = &i
  21201. }
  21202. }
  21203. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21204. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21205. v := m.addcondition_type
  21206. if v == nil {
  21207. return
  21208. }
  21209. return *v, true
  21210. }
  21211. // ResetConditionType resets all changes to the "condition_type" field.
  21212. func (m *SopNodeMutation) ResetConditionType() {
  21213. m.condition_type = nil
  21214. m.addcondition_type = nil
  21215. }
  21216. // SetConditionList sets the "condition_list" field.
  21217. func (m *SopNodeMutation) SetConditionList(s []string) {
  21218. m.condition_list = &s
  21219. m.appendcondition_list = nil
  21220. }
  21221. // ConditionList returns the value of the "condition_list" field in the mutation.
  21222. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21223. v := m.condition_list
  21224. if v == nil {
  21225. return
  21226. }
  21227. return *v, true
  21228. }
  21229. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21230. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21232. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21233. if !m.op.Is(OpUpdateOne) {
  21234. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21235. }
  21236. if m.id == nil || m.oldValue == nil {
  21237. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21238. }
  21239. oldValue, err := m.oldValue(ctx)
  21240. if err != nil {
  21241. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21242. }
  21243. return oldValue.ConditionList, nil
  21244. }
  21245. // AppendConditionList adds s to the "condition_list" field.
  21246. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21247. m.appendcondition_list = append(m.appendcondition_list, s...)
  21248. }
  21249. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21250. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21251. if len(m.appendcondition_list) == 0 {
  21252. return nil, false
  21253. }
  21254. return m.appendcondition_list, true
  21255. }
  21256. // ClearConditionList clears the value of the "condition_list" field.
  21257. func (m *SopNodeMutation) ClearConditionList() {
  21258. m.condition_list = nil
  21259. m.appendcondition_list = nil
  21260. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21261. }
  21262. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21263. func (m *SopNodeMutation) ConditionListCleared() bool {
  21264. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21265. return ok
  21266. }
  21267. // ResetConditionList resets all changes to the "condition_list" field.
  21268. func (m *SopNodeMutation) ResetConditionList() {
  21269. m.condition_list = nil
  21270. m.appendcondition_list = nil
  21271. delete(m.clearedFields, sopnode.FieldConditionList)
  21272. }
  21273. // SetNoReplyCondition sets the "no_reply_condition" field.
  21274. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21275. m.no_reply_condition = &u
  21276. m.addno_reply_condition = nil
  21277. }
  21278. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21279. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21280. v := m.no_reply_condition
  21281. if v == nil {
  21282. return
  21283. }
  21284. return *v, true
  21285. }
  21286. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21287. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21289. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21290. if !m.op.Is(OpUpdateOne) {
  21291. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21292. }
  21293. if m.id == nil || m.oldValue == nil {
  21294. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21295. }
  21296. oldValue, err := m.oldValue(ctx)
  21297. if err != nil {
  21298. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21299. }
  21300. return oldValue.NoReplyCondition, nil
  21301. }
  21302. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21303. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21304. if m.addno_reply_condition != nil {
  21305. *m.addno_reply_condition += u
  21306. } else {
  21307. m.addno_reply_condition = &u
  21308. }
  21309. }
  21310. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21311. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21312. v := m.addno_reply_condition
  21313. if v == nil {
  21314. return
  21315. }
  21316. return *v, true
  21317. }
  21318. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21319. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21320. m.no_reply_condition = nil
  21321. m.addno_reply_condition = nil
  21322. }
  21323. // SetNoReplyUnit sets the "no_reply_unit" field.
  21324. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21325. m.no_reply_unit = &s
  21326. }
  21327. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21328. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21329. v := m.no_reply_unit
  21330. if v == nil {
  21331. return
  21332. }
  21333. return *v, true
  21334. }
  21335. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21336. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21338. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21339. if !m.op.Is(OpUpdateOne) {
  21340. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21341. }
  21342. if m.id == nil || m.oldValue == nil {
  21343. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21344. }
  21345. oldValue, err := m.oldValue(ctx)
  21346. if err != nil {
  21347. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21348. }
  21349. return oldValue.NoReplyUnit, nil
  21350. }
  21351. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21352. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21353. m.no_reply_unit = nil
  21354. }
  21355. // SetActionMessage sets the "action_message" field.
  21356. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21357. m.action_message = &ct
  21358. m.appendaction_message = nil
  21359. }
  21360. // ActionMessage returns the value of the "action_message" field in the mutation.
  21361. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21362. v := m.action_message
  21363. if v == nil {
  21364. return
  21365. }
  21366. return *v, true
  21367. }
  21368. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21369. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21371. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21372. if !m.op.Is(OpUpdateOne) {
  21373. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21374. }
  21375. if m.id == nil || m.oldValue == nil {
  21376. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21377. }
  21378. oldValue, err := m.oldValue(ctx)
  21379. if err != nil {
  21380. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21381. }
  21382. return oldValue.ActionMessage, nil
  21383. }
  21384. // AppendActionMessage adds ct to the "action_message" field.
  21385. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21386. m.appendaction_message = append(m.appendaction_message, ct...)
  21387. }
  21388. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21389. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21390. if len(m.appendaction_message) == 0 {
  21391. return nil, false
  21392. }
  21393. return m.appendaction_message, true
  21394. }
  21395. // ClearActionMessage clears the value of the "action_message" field.
  21396. func (m *SopNodeMutation) ClearActionMessage() {
  21397. m.action_message = nil
  21398. m.appendaction_message = nil
  21399. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21400. }
  21401. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21402. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21403. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21404. return ok
  21405. }
  21406. // ResetActionMessage resets all changes to the "action_message" field.
  21407. func (m *SopNodeMutation) ResetActionMessage() {
  21408. m.action_message = nil
  21409. m.appendaction_message = nil
  21410. delete(m.clearedFields, sopnode.FieldActionMessage)
  21411. }
  21412. // SetActionLabelAdd sets the "action_label_add" field.
  21413. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21414. m.action_label_add = &u
  21415. m.appendaction_label_add = nil
  21416. }
  21417. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21418. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21419. v := m.action_label_add
  21420. if v == nil {
  21421. return
  21422. }
  21423. return *v, true
  21424. }
  21425. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21426. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21428. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21429. if !m.op.Is(OpUpdateOne) {
  21430. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21431. }
  21432. if m.id == nil || m.oldValue == nil {
  21433. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21434. }
  21435. oldValue, err := m.oldValue(ctx)
  21436. if err != nil {
  21437. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21438. }
  21439. return oldValue.ActionLabelAdd, nil
  21440. }
  21441. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21442. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21443. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21444. }
  21445. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21446. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21447. if len(m.appendaction_label_add) == 0 {
  21448. return nil, false
  21449. }
  21450. return m.appendaction_label_add, true
  21451. }
  21452. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21453. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21454. m.action_label_add = nil
  21455. m.appendaction_label_add = nil
  21456. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21457. }
  21458. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21459. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21460. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21461. return ok
  21462. }
  21463. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21464. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21465. m.action_label_add = nil
  21466. m.appendaction_label_add = nil
  21467. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21468. }
  21469. // SetActionLabelDel sets the "action_label_del" field.
  21470. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21471. m.action_label_del = &u
  21472. m.appendaction_label_del = nil
  21473. }
  21474. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21475. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21476. v := m.action_label_del
  21477. if v == nil {
  21478. return
  21479. }
  21480. return *v, true
  21481. }
  21482. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21483. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21485. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21486. if !m.op.Is(OpUpdateOne) {
  21487. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21488. }
  21489. if m.id == nil || m.oldValue == nil {
  21490. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21491. }
  21492. oldValue, err := m.oldValue(ctx)
  21493. if err != nil {
  21494. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21495. }
  21496. return oldValue.ActionLabelDel, nil
  21497. }
  21498. // AppendActionLabelDel adds u to the "action_label_del" field.
  21499. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21500. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21501. }
  21502. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21503. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21504. if len(m.appendaction_label_del) == 0 {
  21505. return nil, false
  21506. }
  21507. return m.appendaction_label_del, true
  21508. }
  21509. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21510. func (m *SopNodeMutation) ClearActionLabelDel() {
  21511. m.action_label_del = nil
  21512. m.appendaction_label_del = nil
  21513. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21514. }
  21515. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21516. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21517. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21518. return ok
  21519. }
  21520. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21521. func (m *SopNodeMutation) ResetActionLabelDel() {
  21522. m.action_label_del = nil
  21523. m.appendaction_label_del = nil
  21524. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21525. }
  21526. // SetActionForward sets the "action_forward" field.
  21527. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21528. m.action_forward = &ctf
  21529. }
  21530. // ActionForward returns the value of the "action_forward" field in the mutation.
  21531. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21532. v := m.action_forward
  21533. if v == nil {
  21534. return
  21535. }
  21536. return *v, true
  21537. }
  21538. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21539. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21541. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21542. if !m.op.Is(OpUpdateOne) {
  21543. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21544. }
  21545. if m.id == nil || m.oldValue == nil {
  21546. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21547. }
  21548. oldValue, err := m.oldValue(ctx)
  21549. if err != nil {
  21550. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21551. }
  21552. return oldValue.ActionForward, nil
  21553. }
  21554. // ClearActionForward clears the value of the "action_forward" field.
  21555. func (m *SopNodeMutation) ClearActionForward() {
  21556. m.action_forward = nil
  21557. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21558. }
  21559. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21560. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21561. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21562. return ok
  21563. }
  21564. // ResetActionForward resets all changes to the "action_forward" field.
  21565. func (m *SopNodeMutation) ResetActionForward() {
  21566. m.action_forward = nil
  21567. delete(m.clearedFields, sopnode.FieldActionForward)
  21568. }
  21569. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21570. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21571. m.sop_stage = &id
  21572. }
  21573. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21574. func (m *SopNodeMutation) ClearSopStage() {
  21575. m.clearedsop_stage = true
  21576. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21577. }
  21578. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21579. func (m *SopNodeMutation) SopStageCleared() bool {
  21580. return m.clearedsop_stage
  21581. }
  21582. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21583. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21584. if m.sop_stage != nil {
  21585. return *m.sop_stage, true
  21586. }
  21587. return
  21588. }
  21589. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21590. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21591. // SopStageID instead. It exists only for internal usage by the builders.
  21592. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21593. if id := m.sop_stage; id != nil {
  21594. ids = append(ids, *id)
  21595. }
  21596. return
  21597. }
  21598. // ResetSopStage resets all changes to the "sop_stage" edge.
  21599. func (m *SopNodeMutation) ResetSopStage() {
  21600. m.sop_stage = nil
  21601. m.clearedsop_stage = false
  21602. }
  21603. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21604. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21605. if m.node_messages == nil {
  21606. m.node_messages = make(map[uint64]struct{})
  21607. }
  21608. for i := range ids {
  21609. m.node_messages[ids[i]] = struct{}{}
  21610. }
  21611. }
  21612. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21613. func (m *SopNodeMutation) ClearNodeMessages() {
  21614. m.clearednode_messages = true
  21615. }
  21616. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21617. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21618. return m.clearednode_messages
  21619. }
  21620. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21621. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21622. if m.removednode_messages == nil {
  21623. m.removednode_messages = make(map[uint64]struct{})
  21624. }
  21625. for i := range ids {
  21626. delete(m.node_messages, ids[i])
  21627. m.removednode_messages[ids[i]] = struct{}{}
  21628. }
  21629. }
  21630. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21631. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21632. for id := range m.removednode_messages {
  21633. ids = append(ids, id)
  21634. }
  21635. return
  21636. }
  21637. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21638. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21639. for id := range m.node_messages {
  21640. ids = append(ids, id)
  21641. }
  21642. return
  21643. }
  21644. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21645. func (m *SopNodeMutation) ResetNodeMessages() {
  21646. m.node_messages = nil
  21647. m.clearednode_messages = false
  21648. m.removednode_messages = nil
  21649. }
  21650. // Where appends a list predicates to the SopNodeMutation builder.
  21651. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21652. m.predicates = append(m.predicates, ps...)
  21653. }
  21654. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21655. // users can use type-assertion to append predicates that do not depend on any generated package.
  21656. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21657. p := make([]predicate.SopNode, len(ps))
  21658. for i := range ps {
  21659. p[i] = ps[i]
  21660. }
  21661. m.Where(p...)
  21662. }
  21663. // Op returns the operation name.
  21664. func (m *SopNodeMutation) Op() Op {
  21665. return m.op
  21666. }
  21667. // SetOp allows setting the mutation operation.
  21668. func (m *SopNodeMutation) SetOp(op Op) {
  21669. m.op = op
  21670. }
  21671. // Type returns the node type of this mutation (SopNode).
  21672. func (m *SopNodeMutation) Type() string {
  21673. return m.typ
  21674. }
  21675. // Fields returns all fields that were changed during this mutation. Note that in
  21676. // order to get all numeric fields that were incremented/decremented, call
  21677. // AddedFields().
  21678. func (m *SopNodeMutation) Fields() []string {
  21679. fields := make([]string, 0, 15)
  21680. if m.created_at != nil {
  21681. fields = append(fields, sopnode.FieldCreatedAt)
  21682. }
  21683. if m.updated_at != nil {
  21684. fields = append(fields, sopnode.FieldUpdatedAt)
  21685. }
  21686. if m.status != nil {
  21687. fields = append(fields, sopnode.FieldStatus)
  21688. }
  21689. if m.deleted_at != nil {
  21690. fields = append(fields, sopnode.FieldDeletedAt)
  21691. }
  21692. if m.sop_stage != nil {
  21693. fields = append(fields, sopnode.FieldStageID)
  21694. }
  21695. if m.parent_id != nil {
  21696. fields = append(fields, sopnode.FieldParentID)
  21697. }
  21698. if m.name != nil {
  21699. fields = append(fields, sopnode.FieldName)
  21700. }
  21701. if m.condition_type != nil {
  21702. fields = append(fields, sopnode.FieldConditionType)
  21703. }
  21704. if m.condition_list != nil {
  21705. fields = append(fields, sopnode.FieldConditionList)
  21706. }
  21707. if m.no_reply_condition != nil {
  21708. fields = append(fields, sopnode.FieldNoReplyCondition)
  21709. }
  21710. if m.no_reply_unit != nil {
  21711. fields = append(fields, sopnode.FieldNoReplyUnit)
  21712. }
  21713. if m.action_message != nil {
  21714. fields = append(fields, sopnode.FieldActionMessage)
  21715. }
  21716. if m.action_label_add != nil {
  21717. fields = append(fields, sopnode.FieldActionLabelAdd)
  21718. }
  21719. if m.action_label_del != nil {
  21720. fields = append(fields, sopnode.FieldActionLabelDel)
  21721. }
  21722. if m.action_forward != nil {
  21723. fields = append(fields, sopnode.FieldActionForward)
  21724. }
  21725. return fields
  21726. }
  21727. // Field returns the value of a field with the given name. The second boolean
  21728. // return value indicates that this field was not set, or was not defined in the
  21729. // schema.
  21730. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21731. switch name {
  21732. case sopnode.FieldCreatedAt:
  21733. return m.CreatedAt()
  21734. case sopnode.FieldUpdatedAt:
  21735. return m.UpdatedAt()
  21736. case sopnode.FieldStatus:
  21737. return m.Status()
  21738. case sopnode.FieldDeletedAt:
  21739. return m.DeletedAt()
  21740. case sopnode.FieldStageID:
  21741. return m.StageID()
  21742. case sopnode.FieldParentID:
  21743. return m.ParentID()
  21744. case sopnode.FieldName:
  21745. return m.Name()
  21746. case sopnode.FieldConditionType:
  21747. return m.ConditionType()
  21748. case sopnode.FieldConditionList:
  21749. return m.ConditionList()
  21750. case sopnode.FieldNoReplyCondition:
  21751. return m.NoReplyCondition()
  21752. case sopnode.FieldNoReplyUnit:
  21753. return m.NoReplyUnit()
  21754. case sopnode.FieldActionMessage:
  21755. return m.ActionMessage()
  21756. case sopnode.FieldActionLabelAdd:
  21757. return m.ActionLabelAdd()
  21758. case sopnode.FieldActionLabelDel:
  21759. return m.ActionLabelDel()
  21760. case sopnode.FieldActionForward:
  21761. return m.ActionForward()
  21762. }
  21763. return nil, false
  21764. }
  21765. // OldField returns the old value of the field from the database. An error is
  21766. // returned if the mutation operation is not UpdateOne, or the query to the
  21767. // database failed.
  21768. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21769. switch name {
  21770. case sopnode.FieldCreatedAt:
  21771. return m.OldCreatedAt(ctx)
  21772. case sopnode.FieldUpdatedAt:
  21773. return m.OldUpdatedAt(ctx)
  21774. case sopnode.FieldStatus:
  21775. return m.OldStatus(ctx)
  21776. case sopnode.FieldDeletedAt:
  21777. return m.OldDeletedAt(ctx)
  21778. case sopnode.FieldStageID:
  21779. return m.OldStageID(ctx)
  21780. case sopnode.FieldParentID:
  21781. return m.OldParentID(ctx)
  21782. case sopnode.FieldName:
  21783. return m.OldName(ctx)
  21784. case sopnode.FieldConditionType:
  21785. return m.OldConditionType(ctx)
  21786. case sopnode.FieldConditionList:
  21787. return m.OldConditionList(ctx)
  21788. case sopnode.FieldNoReplyCondition:
  21789. return m.OldNoReplyCondition(ctx)
  21790. case sopnode.FieldNoReplyUnit:
  21791. return m.OldNoReplyUnit(ctx)
  21792. case sopnode.FieldActionMessage:
  21793. return m.OldActionMessage(ctx)
  21794. case sopnode.FieldActionLabelAdd:
  21795. return m.OldActionLabelAdd(ctx)
  21796. case sopnode.FieldActionLabelDel:
  21797. return m.OldActionLabelDel(ctx)
  21798. case sopnode.FieldActionForward:
  21799. return m.OldActionForward(ctx)
  21800. }
  21801. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21802. }
  21803. // SetField sets the value of a field with the given name. It returns an error if
  21804. // the field is not defined in the schema, or if the type mismatched the field
  21805. // type.
  21806. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21807. switch name {
  21808. case sopnode.FieldCreatedAt:
  21809. v, ok := value.(time.Time)
  21810. if !ok {
  21811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21812. }
  21813. m.SetCreatedAt(v)
  21814. return nil
  21815. case sopnode.FieldUpdatedAt:
  21816. v, ok := value.(time.Time)
  21817. if !ok {
  21818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21819. }
  21820. m.SetUpdatedAt(v)
  21821. return nil
  21822. case sopnode.FieldStatus:
  21823. v, ok := value.(uint8)
  21824. if !ok {
  21825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21826. }
  21827. m.SetStatus(v)
  21828. return nil
  21829. case sopnode.FieldDeletedAt:
  21830. v, ok := value.(time.Time)
  21831. if !ok {
  21832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21833. }
  21834. m.SetDeletedAt(v)
  21835. return nil
  21836. case sopnode.FieldStageID:
  21837. v, ok := value.(uint64)
  21838. if !ok {
  21839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21840. }
  21841. m.SetStageID(v)
  21842. return nil
  21843. case sopnode.FieldParentID:
  21844. v, ok := value.(uint64)
  21845. if !ok {
  21846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21847. }
  21848. m.SetParentID(v)
  21849. return nil
  21850. case sopnode.FieldName:
  21851. v, ok := value.(string)
  21852. if !ok {
  21853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21854. }
  21855. m.SetName(v)
  21856. return nil
  21857. case sopnode.FieldConditionType:
  21858. v, ok := value.(int)
  21859. if !ok {
  21860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21861. }
  21862. m.SetConditionType(v)
  21863. return nil
  21864. case sopnode.FieldConditionList:
  21865. v, ok := value.([]string)
  21866. if !ok {
  21867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21868. }
  21869. m.SetConditionList(v)
  21870. return nil
  21871. case sopnode.FieldNoReplyCondition:
  21872. v, ok := value.(uint64)
  21873. if !ok {
  21874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21875. }
  21876. m.SetNoReplyCondition(v)
  21877. return nil
  21878. case sopnode.FieldNoReplyUnit:
  21879. v, ok := value.(string)
  21880. if !ok {
  21881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21882. }
  21883. m.SetNoReplyUnit(v)
  21884. return nil
  21885. case sopnode.FieldActionMessage:
  21886. v, ok := value.([]custom_types.Action)
  21887. if !ok {
  21888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21889. }
  21890. m.SetActionMessage(v)
  21891. return nil
  21892. case sopnode.FieldActionLabelAdd:
  21893. v, ok := value.([]uint64)
  21894. if !ok {
  21895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21896. }
  21897. m.SetActionLabelAdd(v)
  21898. return nil
  21899. case sopnode.FieldActionLabelDel:
  21900. v, ok := value.([]uint64)
  21901. if !ok {
  21902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21903. }
  21904. m.SetActionLabelDel(v)
  21905. return nil
  21906. case sopnode.FieldActionForward:
  21907. v, ok := value.(*custom_types.ActionForward)
  21908. if !ok {
  21909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21910. }
  21911. m.SetActionForward(v)
  21912. return nil
  21913. }
  21914. return fmt.Errorf("unknown SopNode field %s", name)
  21915. }
  21916. // AddedFields returns all numeric fields that were incremented/decremented during
  21917. // this mutation.
  21918. func (m *SopNodeMutation) AddedFields() []string {
  21919. var fields []string
  21920. if m.addstatus != nil {
  21921. fields = append(fields, sopnode.FieldStatus)
  21922. }
  21923. if m.addparent_id != nil {
  21924. fields = append(fields, sopnode.FieldParentID)
  21925. }
  21926. if m.addcondition_type != nil {
  21927. fields = append(fields, sopnode.FieldConditionType)
  21928. }
  21929. if m.addno_reply_condition != nil {
  21930. fields = append(fields, sopnode.FieldNoReplyCondition)
  21931. }
  21932. return fields
  21933. }
  21934. // AddedField returns the numeric value that was incremented/decremented on a field
  21935. // with the given name. The second boolean return value indicates that this field
  21936. // was not set, or was not defined in the schema.
  21937. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21938. switch name {
  21939. case sopnode.FieldStatus:
  21940. return m.AddedStatus()
  21941. case sopnode.FieldParentID:
  21942. return m.AddedParentID()
  21943. case sopnode.FieldConditionType:
  21944. return m.AddedConditionType()
  21945. case sopnode.FieldNoReplyCondition:
  21946. return m.AddedNoReplyCondition()
  21947. }
  21948. return nil, false
  21949. }
  21950. // AddField adds the value to the field with the given name. It returns an error if
  21951. // the field is not defined in the schema, or if the type mismatched the field
  21952. // type.
  21953. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21954. switch name {
  21955. case sopnode.FieldStatus:
  21956. v, ok := value.(int8)
  21957. if !ok {
  21958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21959. }
  21960. m.AddStatus(v)
  21961. return nil
  21962. case sopnode.FieldParentID:
  21963. v, ok := value.(int64)
  21964. if !ok {
  21965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21966. }
  21967. m.AddParentID(v)
  21968. return nil
  21969. case sopnode.FieldConditionType:
  21970. v, ok := value.(int)
  21971. if !ok {
  21972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21973. }
  21974. m.AddConditionType(v)
  21975. return nil
  21976. case sopnode.FieldNoReplyCondition:
  21977. v, ok := value.(int64)
  21978. if !ok {
  21979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21980. }
  21981. m.AddNoReplyCondition(v)
  21982. return nil
  21983. }
  21984. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21985. }
  21986. // ClearedFields returns all nullable fields that were cleared during this
  21987. // mutation.
  21988. func (m *SopNodeMutation) ClearedFields() []string {
  21989. var fields []string
  21990. if m.FieldCleared(sopnode.FieldStatus) {
  21991. fields = append(fields, sopnode.FieldStatus)
  21992. }
  21993. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21994. fields = append(fields, sopnode.FieldDeletedAt)
  21995. }
  21996. if m.FieldCleared(sopnode.FieldConditionList) {
  21997. fields = append(fields, sopnode.FieldConditionList)
  21998. }
  21999. if m.FieldCleared(sopnode.FieldActionMessage) {
  22000. fields = append(fields, sopnode.FieldActionMessage)
  22001. }
  22002. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  22003. fields = append(fields, sopnode.FieldActionLabelAdd)
  22004. }
  22005. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  22006. fields = append(fields, sopnode.FieldActionLabelDel)
  22007. }
  22008. if m.FieldCleared(sopnode.FieldActionForward) {
  22009. fields = append(fields, sopnode.FieldActionForward)
  22010. }
  22011. return fields
  22012. }
  22013. // FieldCleared returns a boolean indicating if a field with the given name was
  22014. // cleared in this mutation.
  22015. func (m *SopNodeMutation) FieldCleared(name string) bool {
  22016. _, ok := m.clearedFields[name]
  22017. return ok
  22018. }
  22019. // ClearField clears the value of the field with the given name. It returns an
  22020. // error if the field is not defined in the schema.
  22021. func (m *SopNodeMutation) ClearField(name string) error {
  22022. switch name {
  22023. case sopnode.FieldStatus:
  22024. m.ClearStatus()
  22025. return nil
  22026. case sopnode.FieldDeletedAt:
  22027. m.ClearDeletedAt()
  22028. return nil
  22029. case sopnode.FieldConditionList:
  22030. m.ClearConditionList()
  22031. return nil
  22032. case sopnode.FieldActionMessage:
  22033. m.ClearActionMessage()
  22034. return nil
  22035. case sopnode.FieldActionLabelAdd:
  22036. m.ClearActionLabelAdd()
  22037. return nil
  22038. case sopnode.FieldActionLabelDel:
  22039. m.ClearActionLabelDel()
  22040. return nil
  22041. case sopnode.FieldActionForward:
  22042. m.ClearActionForward()
  22043. return nil
  22044. }
  22045. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22046. }
  22047. // ResetField resets all changes in the mutation for the field with the given name.
  22048. // It returns an error if the field is not defined in the schema.
  22049. func (m *SopNodeMutation) ResetField(name string) error {
  22050. switch name {
  22051. case sopnode.FieldCreatedAt:
  22052. m.ResetCreatedAt()
  22053. return nil
  22054. case sopnode.FieldUpdatedAt:
  22055. m.ResetUpdatedAt()
  22056. return nil
  22057. case sopnode.FieldStatus:
  22058. m.ResetStatus()
  22059. return nil
  22060. case sopnode.FieldDeletedAt:
  22061. m.ResetDeletedAt()
  22062. return nil
  22063. case sopnode.FieldStageID:
  22064. m.ResetStageID()
  22065. return nil
  22066. case sopnode.FieldParentID:
  22067. m.ResetParentID()
  22068. return nil
  22069. case sopnode.FieldName:
  22070. m.ResetName()
  22071. return nil
  22072. case sopnode.FieldConditionType:
  22073. m.ResetConditionType()
  22074. return nil
  22075. case sopnode.FieldConditionList:
  22076. m.ResetConditionList()
  22077. return nil
  22078. case sopnode.FieldNoReplyCondition:
  22079. m.ResetNoReplyCondition()
  22080. return nil
  22081. case sopnode.FieldNoReplyUnit:
  22082. m.ResetNoReplyUnit()
  22083. return nil
  22084. case sopnode.FieldActionMessage:
  22085. m.ResetActionMessage()
  22086. return nil
  22087. case sopnode.FieldActionLabelAdd:
  22088. m.ResetActionLabelAdd()
  22089. return nil
  22090. case sopnode.FieldActionLabelDel:
  22091. m.ResetActionLabelDel()
  22092. return nil
  22093. case sopnode.FieldActionForward:
  22094. m.ResetActionForward()
  22095. return nil
  22096. }
  22097. return fmt.Errorf("unknown SopNode field %s", name)
  22098. }
  22099. // AddedEdges returns all edge names that were set/added in this mutation.
  22100. func (m *SopNodeMutation) AddedEdges() []string {
  22101. edges := make([]string, 0, 2)
  22102. if m.sop_stage != nil {
  22103. edges = append(edges, sopnode.EdgeSopStage)
  22104. }
  22105. if m.node_messages != nil {
  22106. edges = append(edges, sopnode.EdgeNodeMessages)
  22107. }
  22108. return edges
  22109. }
  22110. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22111. // name in this mutation.
  22112. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22113. switch name {
  22114. case sopnode.EdgeSopStage:
  22115. if id := m.sop_stage; id != nil {
  22116. return []ent.Value{*id}
  22117. }
  22118. case sopnode.EdgeNodeMessages:
  22119. ids := make([]ent.Value, 0, len(m.node_messages))
  22120. for id := range m.node_messages {
  22121. ids = append(ids, id)
  22122. }
  22123. return ids
  22124. }
  22125. return nil
  22126. }
  22127. // RemovedEdges returns all edge names that were removed in this mutation.
  22128. func (m *SopNodeMutation) RemovedEdges() []string {
  22129. edges := make([]string, 0, 2)
  22130. if m.removednode_messages != nil {
  22131. edges = append(edges, sopnode.EdgeNodeMessages)
  22132. }
  22133. return edges
  22134. }
  22135. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22136. // the given name in this mutation.
  22137. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22138. switch name {
  22139. case sopnode.EdgeNodeMessages:
  22140. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22141. for id := range m.removednode_messages {
  22142. ids = append(ids, id)
  22143. }
  22144. return ids
  22145. }
  22146. return nil
  22147. }
  22148. // ClearedEdges returns all edge names that were cleared in this mutation.
  22149. func (m *SopNodeMutation) ClearedEdges() []string {
  22150. edges := make([]string, 0, 2)
  22151. if m.clearedsop_stage {
  22152. edges = append(edges, sopnode.EdgeSopStage)
  22153. }
  22154. if m.clearednode_messages {
  22155. edges = append(edges, sopnode.EdgeNodeMessages)
  22156. }
  22157. return edges
  22158. }
  22159. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22160. // was cleared in this mutation.
  22161. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22162. switch name {
  22163. case sopnode.EdgeSopStage:
  22164. return m.clearedsop_stage
  22165. case sopnode.EdgeNodeMessages:
  22166. return m.clearednode_messages
  22167. }
  22168. return false
  22169. }
  22170. // ClearEdge clears the value of the edge with the given name. It returns an error
  22171. // if that edge is not defined in the schema.
  22172. func (m *SopNodeMutation) ClearEdge(name string) error {
  22173. switch name {
  22174. case sopnode.EdgeSopStage:
  22175. m.ClearSopStage()
  22176. return nil
  22177. }
  22178. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22179. }
  22180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22181. // It returns an error if the edge is not defined in the schema.
  22182. func (m *SopNodeMutation) ResetEdge(name string) error {
  22183. switch name {
  22184. case sopnode.EdgeSopStage:
  22185. m.ResetSopStage()
  22186. return nil
  22187. case sopnode.EdgeNodeMessages:
  22188. m.ResetNodeMessages()
  22189. return nil
  22190. }
  22191. return fmt.Errorf("unknown SopNode edge %s", name)
  22192. }
  22193. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22194. type SopStageMutation struct {
  22195. config
  22196. op Op
  22197. typ string
  22198. id *uint64
  22199. created_at *time.Time
  22200. updated_at *time.Time
  22201. status *uint8
  22202. addstatus *int8
  22203. deleted_at *time.Time
  22204. name *string
  22205. condition_type *int
  22206. addcondition_type *int
  22207. condition_operator *int
  22208. addcondition_operator *int
  22209. condition_list *[]custom_types.Condition
  22210. appendcondition_list []custom_types.Condition
  22211. action_message *[]custom_types.Action
  22212. appendaction_message []custom_types.Action
  22213. action_label_add *[]uint64
  22214. appendaction_label_add []uint64
  22215. action_label_del *[]uint64
  22216. appendaction_label_del []uint64
  22217. action_forward **custom_types.ActionForward
  22218. index_sort *int
  22219. addindex_sort *int
  22220. clearedFields map[string]struct{}
  22221. sop_task *uint64
  22222. clearedsop_task bool
  22223. stage_nodes map[uint64]struct{}
  22224. removedstage_nodes map[uint64]struct{}
  22225. clearedstage_nodes bool
  22226. stage_messages map[uint64]struct{}
  22227. removedstage_messages map[uint64]struct{}
  22228. clearedstage_messages bool
  22229. done bool
  22230. oldValue func(context.Context) (*SopStage, error)
  22231. predicates []predicate.SopStage
  22232. }
  22233. var _ ent.Mutation = (*SopStageMutation)(nil)
  22234. // sopstageOption allows management of the mutation configuration using functional options.
  22235. type sopstageOption func(*SopStageMutation)
  22236. // newSopStageMutation creates new mutation for the SopStage entity.
  22237. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22238. m := &SopStageMutation{
  22239. config: c,
  22240. op: op,
  22241. typ: TypeSopStage,
  22242. clearedFields: make(map[string]struct{}),
  22243. }
  22244. for _, opt := range opts {
  22245. opt(m)
  22246. }
  22247. return m
  22248. }
  22249. // withSopStageID sets the ID field of the mutation.
  22250. func withSopStageID(id uint64) sopstageOption {
  22251. return func(m *SopStageMutation) {
  22252. var (
  22253. err error
  22254. once sync.Once
  22255. value *SopStage
  22256. )
  22257. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22258. once.Do(func() {
  22259. if m.done {
  22260. err = errors.New("querying old values post mutation is not allowed")
  22261. } else {
  22262. value, err = m.Client().SopStage.Get(ctx, id)
  22263. }
  22264. })
  22265. return value, err
  22266. }
  22267. m.id = &id
  22268. }
  22269. }
  22270. // withSopStage sets the old SopStage of the mutation.
  22271. func withSopStage(node *SopStage) sopstageOption {
  22272. return func(m *SopStageMutation) {
  22273. m.oldValue = func(context.Context) (*SopStage, error) {
  22274. return node, nil
  22275. }
  22276. m.id = &node.ID
  22277. }
  22278. }
  22279. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22280. // executed in a transaction (ent.Tx), a transactional client is returned.
  22281. func (m SopStageMutation) Client() *Client {
  22282. client := &Client{config: m.config}
  22283. client.init()
  22284. return client
  22285. }
  22286. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22287. // it returns an error otherwise.
  22288. func (m SopStageMutation) Tx() (*Tx, error) {
  22289. if _, ok := m.driver.(*txDriver); !ok {
  22290. return nil, errors.New("ent: mutation is not running in a transaction")
  22291. }
  22292. tx := &Tx{config: m.config}
  22293. tx.init()
  22294. return tx, nil
  22295. }
  22296. // SetID sets the value of the id field. Note that this
  22297. // operation is only accepted on creation of SopStage entities.
  22298. func (m *SopStageMutation) SetID(id uint64) {
  22299. m.id = &id
  22300. }
  22301. // ID returns the ID value in the mutation. Note that the ID is only available
  22302. // if it was provided to the builder or after it was returned from the database.
  22303. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22304. if m.id == nil {
  22305. return
  22306. }
  22307. return *m.id, true
  22308. }
  22309. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22310. // That means, if the mutation is applied within a transaction with an isolation level such
  22311. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22312. // or updated by the mutation.
  22313. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22314. switch {
  22315. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22316. id, exists := m.ID()
  22317. if exists {
  22318. return []uint64{id}, nil
  22319. }
  22320. fallthrough
  22321. case m.op.Is(OpUpdate | OpDelete):
  22322. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22323. default:
  22324. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22325. }
  22326. }
  22327. // SetCreatedAt sets the "created_at" field.
  22328. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22329. m.created_at = &t
  22330. }
  22331. // CreatedAt returns the value of the "created_at" field in the mutation.
  22332. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22333. v := m.created_at
  22334. if v == nil {
  22335. return
  22336. }
  22337. return *v, true
  22338. }
  22339. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22340. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22342. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22343. if !m.op.Is(OpUpdateOne) {
  22344. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22345. }
  22346. if m.id == nil || m.oldValue == nil {
  22347. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22348. }
  22349. oldValue, err := m.oldValue(ctx)
  22350. if err != nil {
  22351. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22352. }
  22353. return oldValue.CreatedAt, nil
  22354. }
  22355. // ResetCreatedAt resets all changes to the "created_at" field.
  22356. func (m *SopStageMutation) ResetCreatedAt() {
  22357. m.created_at = nil
  22358. }
  22359. // SetUpdatedAt sets the "updated_at" field.
  22360. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22361. m.updated_at = &t
  22362. }
  22363. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22364. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22365. v := m.updated_at
  22366. if v == nil {
  22367. return
  22368. }
  22369. return *v, true
  22370. }
  22371. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22372. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22374. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22375. if !m.op.Is(OpUpdateOne) {
  22376. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22377. }
  22378. if m.id == nil || m.oldValue == nil {
  22379. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22380. }
  22381. oldValue, err := m.oldValue(ctx)
  22382. if err != nil {
  22383. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22384. }
  22385. return oldValue.UpdatedAt, nil
  22386. }
  22387. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22388. func (m *SopStageMutation) ResetUpdatedAt() {
  22389. m.updated_at = nil
  22390. }
  22391. // SetStatus sets the "status" field.
  22392. func (m *SopStageMutation) SetStatus(u uint8) {
  22393. m.status = &u
  22394. m.addstatus = nil
  22395. }
  22396. // Status returns the value of the "status" field in the mutation.
  22397. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22398. v := m.status
  22399. if v == nil {
  22400. return
  22401. }
  22402. return *v, true
  22403. }
  22404. // OldStatus returns the old "status" field's value of the SopStage entity.
  22405. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22407. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22408. if !m.op.Is(OpUpdateOne) {
  22409. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22410. }
  22411. if m.id == nil || m.oldValue == nil {
  22412. return v, errors.New("OldStatus requires an ID field in the mutation")
  22413. }
  22414. oldValue, err := m.oldValue(ctx)
  22415. if err != nil {
  22416. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22417. }
  22418. return oldValue.Status, nil
  22419. }
  22420. // AddStatus adds u to the "status" field.
  22421. func (m *SopStageMutation) AddStatus(u int8) {
  22422. if m.addstatus != nil {
  22423. *m.addstatus += u
  22424. } else {
  22425. m.addstatus = &u
  22426. }
  22427. }
  22428. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22429. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22430. v := m.addstatus
  22431. if v == nil {
  22432. return
  22433. }
  22434. return *v, true
  22435. }
  22436. // ClearStatus clears the value of the "status" field.
  22437. func (m *SopStageMutation) ClearStatus() {
  22438. m.status = nil
  22439. m.addstatus = nil
  22440. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22441. }
  22442. // StatusCleared returns if the "status" field was cleared in this mutation.
  22443. func (m *SopStageMutation) StatusCleared() bool {
  22444. _, ok := m.clearedFields[sopstage.FieldStatus]
  22445. return ok
  22446. }
  22447. // ResetStatus resets all changes to the "status" field.
  22448. func (m *SopStageMutation) ResetStatus() {
  22449. m.status = nil
  22450. m.addstatus = nil
  22451. delete(m.clearedFields, sopstage.FieldStatus)
  22452. }
  22453. // SetDeletedAt sets the "deleted_at" field.
  22454. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22455. m.deleted_at = &t
  22456. }
  22457. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22458. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22459. v := m.deleted_at
  22460. if v == nil {
  22461. return
  22462. }
  22463. return *v, true
  22464. }
  22465. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22466. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22468. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22469. if !m.op.Is(OpUpdateOne) {
  22470. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22471. }
  22472. if m.id == nil || m.oldValue == nil {
  22473. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22474. }
  22475. oldValue, err := m.oldValue(ctx)
  22476. if err != nil {
  22477. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22478. }
  22479. return oldValue.DeletedAt, nil
  22480. }
  22481. // ClearDeletedAt clears the value of the "deleted_at" field.
  22482. func (m *SopStageMutation) ClearDeletedAt() {
  22483. m.deleted_at = nil
  22484. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22485. }
  22486. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22487. func (m *SopStageMutation) DeletedAtCleared() bool {
  22488. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22489. return ok
  22490. }
  22491. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22492. func (m *SopStageMutation) ResetDeletedAt() {
  22493. m.deleted_at = nil
  22494. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22495. }
  22496. // SetTaskID sets the "task_id" field.
  22497. func (m *SopStageMutation) SetTaskID(u uint64) {
  22498. m.sop_task = &u
  22499. }
  22500. // TaskID returns the value of the "task_id" field in the mutation.
  22501. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22502. v := m.sop_task
  22503. if v == nil {
  22504. return
  22505. }
  22506. return *v, true
  22507. }
  22508. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22509. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22511. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22512. if !m.op.Is(OpUpdateOne) {
  22513. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22514. }
  22515. if m.id == nil || m.oldValue == nil {
  22516. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22517. }
  22518. oldValue, err := m.oldValue(ctx)
  22519. if err != nil {
  22520. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22521. }
  22522. return oldValue.TaskID, nil
  22523. }
  22524. // ResetTaskID resets all changes to the "task_id" field.
  22525. func (m *SopStageMutation) ResetTaskID() {
  22526. m.sop_task = nil
  22527. }
  22528. // SetName sets the "name" field.
  22529. func (m *SopStageMutation) SetName(s string) {
  22530. m.name = &s
  22531. }
  22532. // Name returns the value of the "name" field in the mutation.
  22533. func (m *SopStageMutation) Name() (r string, exists bool) {
  22534. v := m.name
  22535. if v == nil {
  22536. return
  22537. }
  22538. return *v, true
  22539. }
  22540. // OldName returns the old "name" field's value of the SopStage entity.
  22541. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22543. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22544. if !m.op.Is(OpUpdateOne) {
  22545. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22546. }
  22547. if m.id == nil || m.oldValue == nil {
  22548. return v, errors.New("OldName requires an ID field in the mutation")
  22549. }
  22550. oldValue, err := m.oldValue(ctx)
  22551. if err != nil {
  22552. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22553. }
  22554. return oldValue.Name, nil
  22555. }
  22556. // ResetName resets all changes to the "name" field.
  22557. func (m *SopStageMutation) ResetName() {
  22558. m.name = nil
  22559. }
  22560. // SetConditionType sets the "condition_type" field.
  22561. func (m *SopStageMutation) SetConditionType(i int) {
  22562. m.condition_type = &i
  22563. m.addcondition_type = nil
  22564. }
  22565. // ConditionType returns the value of the "condition_type" field in the mutation.
  22566. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22567. v := m.condition_type
  22568. if v == nil {
  22569. return
  22570. }
  22571. return *v, true
  22572. }
  22573. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22574. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22576. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22577. if !m.op.Is(OpUpdateOne) {
  22578. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22579. }
  22580. if m.id == nil || m.oldValue == nil {
  22581. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22582. }
  22583. oldValue, err := m.oldValue(ctx)
  22584. if err != nil {
  22585. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22586. }
  22587. return oldValue.ConditionType, nil
  22588. }
  22589. // AddConditionType adds i to the "condition_type" field.
  22590. func (m *SopStageMutation) AddConditionType(i int) {
  22591. if m.addcondition_type != nil {
  22592. *m.addcondition_type += i
  22593. } else {
  22594. m.addcondition_type = &i
  22595. }
  22596. }
  22597. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22598. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22599. v := m.addcondition_type
  22600. if v == nil {
  22601. return
  22602. }
  22603. return *v, true
  22604. }
  22605. // ResetConditionType resets all changes to the "condition_type" field.
  22606. func (m *SopStageMutation) ResetConditionType() {
  22607. m.condition_type = nil
  22608. m.addcondition_type = nil
  22609. }
  22610. // SetConditionOperator sets the "condition_operator" field.
  22611. func (m *SopStageMutation) SetConditionOperator(i int) {
  22612. m.condition_operator = &i
  22613. m.addcondition_operator = nil
  22614. }
  22615. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22616. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22617. v := m.condition_operator
  22618. if v == nil {
  22619. return
  22620. }
  22621. return *v, true
  22622. }
  22623. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22624. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22626. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22627. if !m.op.Is(OpUpdateOne) {
  22628. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22629. }
  22630. if m.id == nil || m.oldValue == nil {
  22631. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22632. }
  22633. oldValue, err := m.oldValue(ctx)
  22634. if err != nil {
  22635. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22636. }
  22637. return oldValue.ConditionOperator, nil
  22638. }
  22639. // AddConditionOperator adds i to the "condition_operator" field.
  22640. func (m *SopStageMutation) AddConditionOperator(i int) {
  22641. if m.addcondition_operator != nil {
  22642. *m.addcondition_operator += i
  22643. } else {
  22644. m.addcondition_operator = &i
  22645. }
  22646. }
  22647. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22648. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22649. v := m.addcondition_operator
  22650. if v == nil {
  22651. return
  22652. }
  22653. return *v, true
  22654. }
  22655. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22656. func (m *SopStageMutation) ResetConditionOperator() {
  22657. m.condition_operator = nil
  22658. m.addcondition_operator = nil
  22659. }
  22660. // SetConditionList sets the "condition_list" field.
  22661. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22662. m.condition_list = &ct
  22663. m.appendcondition_list = nil
  22664. }
  22665. // ConditionList returns the value of the "condition_list" field in the mutation.
  22666. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22667. v := m.condition_list
  22668. if v == nil {
  22669. return
  22670. }
  22671. return *v, true
  22672. }
  22673. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22674. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22676. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22677. if !m.op.Is(OpUpdateOne) {
  22678. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22679. }
  22680. if m.id == nil || m.oldValue == nil {
  22681. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22682. }
  22683. oldValue, err := m.oldValue(ctx)
  22684. if err != nil {
  22685. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22686. }
  22687. return oldValue.ConditionList, nil
  22688. }
  22689. // AppendConditionList adds ct to the "condition_list" field.
  22690. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22691. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22692. }
  22693. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22694. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22695. if len(m.appendcondition_list) == 0 {
  22696. return nil, false
  22697. }
  22698. return m.appendcondition_list, true
  22699. }
  22700. // ResetConditionList resets all changes to the "condition_list" field.
  22701. func (m *SopStageMutation) ResetConditionList() {
  22702. m.condition_list = nil
  22703. m.appendcondition_list = nil
  22704. }
  22705. // SetActionMessage sets the "action_message" field.
  22706. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22707. m.action_message = &ct
  22708. m.appendaction_message = nil
  22709. }
  22710. // ActionMessage returns the value of the "action_message" field in the mutation.
  22711. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22712. v := m.action_message
  22713. if v == nil {
  22714. return
  22715. }
  22716. return *v, true
  22717. }
  22718. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22719. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22721. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22722. if !m.op.Is(OpUpdateOne) {
  22723. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22724. }
  22725. if m.id == nil || m.oldValue == nil {
  22726. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22727. }
  22728. oldValue, err := m.oldValue(ctx)
  22729. if err != nil {
  22730. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22731. }
  22732. return oldValue.ActionMessage, nil
  22733. }
  22734. // AppendActionMessage adds ct to the "action_message" field.
  22735. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22736. m.appendaction_message = append(m.appendaction_message, ct...)
  22737. }
  22738. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22739. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22740. if len(m.appendaction_message) == 0 {
  22741. return nil, false
  22742. }
  22743. return m.appendaction_message, true
  22744. }
  22745. // ClearActionMessage clears the value of the "action_message" field.
  22746. func (m *SopStageMutation) ClearActionMessage() {
  22747. m.action_message = nil
  22748. m.appendaction_message = nil
  22749. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22750. }
  22751. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22752. func (m *SopStageMutation) ActionMessageCleared() bool {
  22753. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22754. return ok
  22755. }
  22756. // ResetActionMessage resets all changes to the "action_message" field.
  22757. func (m *SopStageMutation) ResetActionMessage() {
  22758. m.action_message = nil
  22759. m.appendaction_message = nil
  22760. delete(m.clearedFields, sopstage.FieldActionMessage)
  22761. }
  22762. // SetActionLabelAdd sets the "action_label_add" field.
  22763. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22764. m.action_label_add = &u
  22765. m.appendaction_label_add = nil
  22766. }
  22767. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22768. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22769. v := m.action_label_add
  22770. if v == nil {
  22771. return
  22772. }
  22773. return *v, true
  22774. }
  22775. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22776. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22778. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22779. if !m.op.Is(OpUpdateOne) {
  22780. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22781. }
  22782. if m.id == nil || m.oldValue == nil {
  22783. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22784. }
  22785. oldValue, err := m.oldValue(ctx)
  22786. if err != nil {
  22787. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22788. }
  22789. return oldValue.ActionLabelAdd, nil
  22790. }
  22791. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22792. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22793. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22794. }
  22795. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22796. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22797. if len(m.appendaction_label_add) == 0 {
  22798. return nil, false
  22799. }
  22800. return m.appendaction_label_add, true
  22801. }
  22802. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22803. func (m *SopStageMutation) ClearActionLabelAdd() {
  22804. m.action_label_add = nil
  22805. m.appendaction_label_add = nil
  22806. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22807. }
  22808. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22809. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22810. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22811. return ok
  22812. }
  22813. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22814. func (m *SopStageMutation) ResetActionLabelAdd() {
  22815. m.action_label_add = nil
  22816. m.appendaction_label_add = nil
  22817. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22818. }
  22819. // SetActionLabelDel sets the "action_label_del" field.
  22820. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22821. m.action_label_del = &u
  22822. m.appendaction_label_del = nil
  22823. }
  22824. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22825. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22826. v := m.action_label_del
  22827. if v == nil {
  22828. return
  22829. }
  22830. return *v, true
  22831. }
  22832. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22833. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22835. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22836. if !m.op.Is(OpUpdateOne) {
  22837. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22838. }
  22839. if m.id == nil || m.oldValue == nil {
  22840. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22841. }
  22842. oldValue, err := m.oldValue(ctx)
  22843. if err != nil {
  22844. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22845. }
  22846. return oldValue.ActionLabelDel, nil
  22847. }
  22848. // AppendActionLabelDel adds u to the "action_label_del" field.
  22849. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22850. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22851. }
  22852. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22853. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22854. if len(m.appendaction_label_del) == 0 {
  22855. return nil, false
  22856. }
  22857. return m.appendaction_label_del, true
  22858. }
  22859. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22860. func (m *SopStageMutation) ClearActionLabelDel() {
  22861. m.action_label_del = nil
  22862. m.appendaction_label_del = nil
  22863. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22864. }
  22865. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22866. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22867. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22868. return ok
  22869. }
  22870. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22871. func (m *SopStageMutation) ResetActionLabelDel() {
  22872. m.action_label_del = nil
  22873. m.appendaction_label_del = nil
  22874. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22875. }
  22876. // SetActionForward sets the "action_forward" field.
  22877. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22878. m.action_forward = &ctf
  22879. }
  22880. // ActionForward returns the value of the "action_forward" field in the mutation.
  22881. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22882. v := m.action_forward
  22883. if v == nil {
  22884. return
  22885. }
  22886. return *v, true
  22887. }
  22888. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22889. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22891. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22892. if !m.op.Is(OpUpdateOne) {
  22893. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22894. }
  22895. if m.id == nil || m.oldValue == nil {
  22896. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22897. }
  22898. oldValue, err := m.oldValue(ctx)
  22899. if err != nil {
  22900. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22901. }
  22902. return oldValue.ActionForward, nil
  22903. }
  22904. // ClearActionForward clears the value of the "action_forward" field.
  22905. func (m *SopStageMutation) ClearActionForward() {
  22906. m.action_forward = nil
  22907. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22908. }
  22909. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22910. func (m *SopStageMutation) ActionForwardCleared() bool {
  22911. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22912. return ok
  22913. }
  22914. // ResetActionForward resets all changes to the "action_forward" field.
  22915. func (m *SopStageMutation) ResetActionForward() {
  22916. m.action_forward = nil
  22917. delete(m.clearedFields, sopstage.FieldActionForward)
  22918. }
  22919. // SetIndexSort sets the "index_sort" field.
  22920. func (m *SopStageMutation) SetIndexSort(i int) {
  22921. m.index_sort = &i
  22922. m.addindex_sort = nil
  22923. }
  22924. // IndexSort returns the value of the "index_sort" field in the mutation.
  22925. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22926. v := m.index_sort
  22927. if v == nil {
  22928. return
  22929. }
  22930. return *v, true
  22931. }
  22932. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22933. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22935. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22936. if !m.op.Is(OpUpdateOne) {
  22937. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22938. }
  22939. if m.id == nil || m.oldValue == nil {
  22940. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22941. }
  22942. oldValue, err := m.oldValue(ctx)
  22943. if err != nil {
  22944. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22945. }
  22946. return oldValue.IndexSort, nil
  22947. }
  22948. // AddIndexSort adds i to the "index_sort" field.
  22949. func (m *SopStageMutation) AddIndexSort(i int) {
  22950. if m.addindex_sort != nil {
  22951. *m.addindex_sort += i
  22952. } else {
  22953. m.addindex_sort = &i
  22954. }
  22955. }
  22956. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22957. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22958. v := m.addindex_sort
  22959. if v == nil {
  22960. return
  22961. }
  22962. return *v, true
  22963. }
  22964. // ClearIndexSort clears the value of the "index_sort" field.
  22965. func (m *SopStageMutation) ClearIndexSort() {
  22966. m.index_sort = nil
  22967. m.addindex_sort = nil
  22968. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22969. }
  22970. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22971. func (m *SopStageMutation) IndexSortCleared() bool {
  22972. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22973. return ok
  22974. }
  22975. // ResetIndexSort resets all changes to the "index_sort" field.
  22976. func (m *SopStageMutation) ResetIndexSort() {
  22977. m.index_sort = nil
  22978. m.addindex_sort = nil
  22979. delete(m.clearedFields, sopstage.FieldIndexSort)
  22980. }
  22981. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22982. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22983. m.sop_task = &id
  22984. }
  22985. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22986. func (m *SopStageMutation) ClearSopTask() {
  22987. m.clearedsop_task = true
  22988. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22989. }
  22990. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22991. func (m *SopStageMutation) SopTaskCleared() bool {
  22992. return m.clearedsop_task
  22993. }
  22994. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22995. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22996. if m.sop_task != nil {
  22997. return *m.sop_task, true
  22998. }
  22999. return
  23000. }
  23001. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  23002. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23003. // SopTaskID instead. It exists only for internal usage by the builders.
  23004. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  23005. if id := m.sop_task; id != nil {
  23006. ids = append(ids, *id)
  23007. }
  23008. return
  23009. }
  23010. // ResetSopTask resets all changes to the "sop_task" edge.
  23011. func (m *SopStageMutation) ResetSopTask() {
  23012. m.sop_task = nil
  23013. m.clearedsop_task = false
  23014. }
  23015. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  23016. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  23017. if m.stage_nodes == nil {
  23018. m.stage_nodes = make(map[uint64]struct{})
  23019. }
  23020. for i := range ids {
  23021. m.stage_nodes[ids[i]] = struct{}{}
  23022. }
  23023. }
  23024. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  23025. func (m *SopStageMutation) ClearStageNodes() {
  23026. m.clearedstage_nodes = true
  23027. }
  23028. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  23029. func (m *SopStageMutation) StageNodesCleared() bool {
  23030. return m.clearedstage_nodes
  23031. }
  23032. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  23033. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  23034. if m.removedstage_nodes == nil {
  23035. m.removedstage_nodes = make(map[uint64]struct{})
  23036. }
  23037. for i := range ids {
  23038. delete(m.stage_nodes, ids[i])
  23039. m.removedstage_nodes[ids[i]] = struct{}{}
  23040. }
  23041. }
  23042. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23043. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23044. for id := range m.removedstage_nodes {
  23045. ids = append(ids, id)
  23046. }
  23047. return
  23048. }
  23049. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23050. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23051. for id := range m.stage_nodes {
  23052. ids = append(ids, id)
  23053. }
  23054. return
  23055. }
  23056. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23057. func (m *SopStageMutation) ResetStageNodes() {
  23058. m.stage_nodes = nil
  23059. m.clearedstage_nodes = false
  23060. m.removedstage_nodes = nil
  23061. }
  23062. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23063. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23064. if m.stage_messages == nil {
  23065. m.stage_messages = make(map[uint64]struct{})
  23066. }
  23067. for i := range ids {
  23068. m.stage_messages[ids[i]] = struct{}{}
  23069. }
  23070. }
  23071. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23072. func (m *SopStageMutation) ClearStageMessages() {
  23073. m.clearedstage_messages = true
  23074. }
  23075. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23076. func (m *SopStageMutation) StageMessagesCleared() bool {
  23077. return m.clearedstage_messages
  23078. }
  23079. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23080. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23081. if m.removedstage_messages == nil {
  23082. m.removedstage_messages = make(map[uint64]struct{})
  23083. }
  23084. for i := range ids {
  23085. delete(m.stage_messages, ids[i])
  23086. m.removedstage_messages[ids[i]] = struct{}{}
  23087. }
  23088. }
  23089. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23090. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23091. for id := range m.removedstage_messages {
  23092. ids = append(ids, id)
  23093. }
  23094. return
  23095. }
  23096. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23097. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23098. for id := range m.stage_messages {
  23099. ids = append(ids, id)
  23100. }
  23101. return
  23102. }
  23103. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23104. func (m *SopStageMutation) ResetStageMessages() {
  23105. m.stage_messages = nil
  23106. m.clearedstage_messages = false
  23107. m.removedstage_messages = nil
  23108. }
  23109. // Where appends a list predicates to the SopStageMutation builder.
  23110. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23111. m.predicates = append(m.predicates, ps...)
  23112. }
  23113. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23114. // users can use type-assertion to append predicates that do not depend on any generated package.
  23115. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23116. p := make([]predicate.SopStage, len(ps))
  23117. for i := range ps {
  23118. p[i] = ps[i]
  23119. }
  23120. m.Where(p...)
  23121. }
  23122. // Op returns the operation name.
  23123. func (m *SopStageMutation) Op() Op {
  23124. return m.op
  23125. }
  23126. // SetOp allows setting the mutation operation.
  23127. func (m *SopStageMutation) SetOp(op Op) {
  23128. m.op = op
  23129. }
  23130. // Type returns the node type of this mutation (SopStage).
  23131. func (m *SopStageMutation) Type() string {
  23132. return m.typ
  23133. }
  23134. // Fields returns all fields that were changed during this mutation. Note that in
  23135. // order to get all numeric fields that were incremented/decremented, call
  23136. // AddedFields().
  23137. func (m *SopStageMutation) Fields() []string {
  23138. fields := make([]string, 0, 14)
  23139. if m.created_at != nil {
  23140. fields = append(fields, sopstage.FieldCreatedAt)
  23141. }
  23142. if m.updated_at != nil {
  23143. fields = append(fields, sopstage.FieldUpdatedAt)
  23144. }
  23145. if m.status != nil {
  23146. fields = append(fields, sopstage.FieldStatus)
  23147. }
  23148. if m.deleted_at != nil {
  23149. fields = append(fields, sopstage.FieldDeletedAt)
  23150. }
  23151. if m.sop_task != nil {
  23152. fields = append(fields, sopstage.FieldTaskID)
  23153. }
  23154. if m.name != nil {
  23155. fields = append(fields, sopstage.FieldName)
  23156. }
  23157. if m.condition_type != nil {
  23158. fields = append(fields, sopstage.FieldConditionType)
  23159. }
  23160. if m.condition_operator != nil {
  23161. fields = append(fields, sopstage.FieldConditionOperator)
  23162. }
  23163. if m.condition_list != nil {
  23164. fields = append(fields, sopstage.FieldConditionList)
  23165. }
  23166. if m.action_message != nil {
  23167. fields = append(fields, sopstage.FieldActionMessage)
  23168. }
  23169. if m.action_label_add != nil {
  23170. fields = append(fields, sopstage.FieldActionLabelAdd)
  23171. }
  23172. if m.action_label_del != nil {
  23173. fields = append(fields, sopstage.FieldActionLabelDel)
  23174. }
  23175. if m.action_forward != nil {
  23176. fields = append(fields, sopstage.FieldActionForward)
  23177. }
  23178. if m.index_sort != nil {
  23179. fields = append(fields, sopstage.FieldIndexSort)
  23180. }
  23181. return fields
  23182. }
  23183. // Field returns the value of a field with the given name. The second boolean
  23184. // return value indicates that this field was not set, or was not defined in the
  23185. // schema.
  23186. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23187. switch name {
  23188. case sopstage.FieldCreatedAt:
  23189. return m.CreatedAt()
  23190. case sopstage.FieldUpdatedAt:
  23191. return m.UpdatedAt()
  23192. case sopstage.FieldStatus:
  23193. return m.Status()
  23194. case sopstage.FieldDeletedAt:
  23195. return m.DeletedAt()
  23196. case sopstage.FieldTaskID:
  23197. return m.TaskID()
  23198. case sopstage.FieldName:
  23199. return m.Name()
  23200. case sopstage.FieldConditionType:
  23201. return m.ConditionType()
  23202. case sopstage.FieldConditionOperator:
  23203. return m.ConditionOperator()
  23204. case sopstage.FieldConditionList:
  23205. return m.ConditionList()
  23206. case sopstage.FieldActionMessage:
  23207. return m.ActionMessage()
  23208. case sopstage.FieldActionLabelAdd:
  23209. return m.ActionLabelAdd()
  23210. case sopstage.FieldActionLabelDel:
  23211. return m.ActionLabelDel()
  23212. case sopstage.FieldActionForward:
  23213. return m.ActionForward()
  23214. case sopstage.FieldIndexSort:
  23215. return m.IndexSort()
  23216. }
  23217. return nil, false
  23218. }
  23219. // OldField returns the old value of the field from the database. An error is
  23220. // returned if the mutation operation is not UpdateOne, or the query to the
  23221. // database failed.
  23222. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23223. switch name {
  23224. case sopstage.FieldCreatedAt:
  23225. return m.OldCreatedAt(ctx)
  23226. case sopstage.FieldUpdatedAt:
  23227. return m.OldUpdatedAt(ctx)
  23228. case sopstage.FieldStatus:
  23229. return m.OldStatus(ctx)
  23230. case sopstage.FieldDeletedAt:
  23231. return m.OldDeletedAt(ctx)
  23232. case sopstage.FieldTaskID:
  23233. return m.OldTaskID(ctx)
  23234. case sopstage.FieldName:
  23235. return m.OldName(ctx)
  23236. case sopstage.FieldConditionType:
  23237. return m.OldConditionType(ctx)
  23238. case sopstage.FieldConditionOperator:
  23239. return m.OldConditionOperator(ctx)
  23240. case sopstage.FieldConditionList:
  23241. return m.OldConditionList(ctx)
  23242. case sopstage.FieldActionMessage:
  23243. return m.OldActionMessage(ctx)
  23244. case sopstage.FieldActionLabelAdd:
  23245. return m.OldActionLabelAdd(ctx)
  23246. case sopstage.FieldActionLabelDel:
  23247. return m.OldActionLabelDel(ctx)
  23248. case sopstage.FieldActionForward:
  23249. return m.OldActionForward(ctx)
  23250. case sopstage.FieldIndexSort:
  23251. return m.OldIndexSort(ctx)
  23252. }
  23253. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23254. }
  23255. // SetField sets the value of a field with the given name. It returns an error if
  23256. // the field is not defined in the schema, or if the type mismatched the field
  23257. // type.
  23258. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23259. switch name {
  23260. case sopstage.FieldCreatedAt:
  23261. v, ok := value.(time.Time)
  23262. if !ok {
  23263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23264. }
  23265. m.SetCreatedAt(v)
  23266. return nil
  23267. case sopstage.FieldUpdatedAt:
  23268. v, ok := value.(time.Time)
  23269. if !ok {
  23270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23271. }
  23272. m.SetUpdatedAt(v)
  23273. return nil
  23274. case sopstage.FieldStatus:
  23275. v, ok := value.(uint8)
  23276. if !ok {
  23277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23278. }
  23279. m.SetStatus(v)
  23280. return nil
  23281. case sopstage.FieldDeletedAt:
  23282. v, ok := value.(time.Time)
  23283. if !ok {
  23284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23285. }
  23286. m.SetDeletedAt(v)
  23287. return nil
  23288. case sopstage.FieldTaskID:
  23289. v, ok := value.(uint64)
  23290. if !ok {
  23291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23292. }
  23293. m.SetTaskID(v)
  23294. return nil
  23295. case sopstage.FieldName:
  23296. v, ok := value.(string)
  23297. if !ok {
  23298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23299. }
  23300. m.SetName(v)
  23301. return nil
  23302. case sopstage.FieldConditionType:
  23303. v, ok := value.(int)
  23304. if !ok {
  23305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23306. }
  23307. m.SetConditionType(v)
  23308. return nil
  23309. case sopstage.FieldConditionOperator:
  23310. v, ok := value.(int)
  23311. if !ok {
  23312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23313. }
  23314. m.SetConditionOperator(v)
  23315. return nil
  23316. case sopstage.FieldConditionList:
  23317. v, ok := value.([]custom_types.Condition)
  23318. if !ok {
  23319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23320. }
  23321. m.SetConditionList(v)
  23322. return nil
  23323. case sopstage.FieldActionMessage:
  23324. v, ok := value.([]custom_types.Action)
  23325. if !ok {
  23326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23327. }
  23328. m.SetActionMessage(v)
  23329. return nil
  23330. case sopstage.FieldActionLabelAdd:
  23331. v, ok := value.([]uint64)
  23332. if !ok {
  23333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23334. }
  23335. m.SetActionLabelAdd(v)
  23336. return nil
  23337. case sopstage.FieldActionLabelDel:
  23338. v, ok := value.([]uint64)
  23339. if !ok {
  23340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23341. }
  23342. m.SetActionLabelDel(v)
  23343. return nil
  23344. case sopstage.FieldActionForward:
  23345. v, ok := value.(*custom_types.ActionForward)
  23346. if !ok {
  23347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23348. }
  23349. m.SetActionForward(v)
  23350. return nil
  23351. case sopstage.FieldIndexSort:
  23352. v, ok := value.(int)
  23353. if !ok {
  23354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23355. }
  23356. m.SetIndexSort(v)
  23357. return nil
  23358. }
  23359. return fmt.Errorf("unknown SopStage field %s", name)
  23360. }
  23361. // AddedFields returns all numeric fields that were incremented/decremented during
  23362. // this mutation.
  23363. func (m *SopStageMutation) AddedFields() []string {
  23364. var fields []string
  23365. if m.addstatus != nil {
  23366. fields = append(fields, sopstage.FieldStatus)
  23367. }
  23368. if m.addcondition_type != nil {
  23369. fields = append(fields, sopstage.FieldConditionType)
  23370. }
  23371. if m.addcondition_operator != nil {
  23372. fields = append(fields, sopstage.FieldConditionOperator)
  23373. }
  23374. if m.addindex_sort != nil {
  23375. fields = append(fields, sopstage.FieldIndexSort)
  23376. }
  23377. return fields
  23378. }
  23379. // AddedField returns the numeric value that was incremented/decremented on a field
  23380. // with the given name. The second boolean return value indicates that this field
  23381. // was not set, or was not defined in the schema.
  23382. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23383. switch name {
  23384. case sopstage.FieldStatus:
  23385. return m.AddedStatus()
  23386. case sopstage.FieldConditionType:
  23387. return m.AddedConditionType()
  23388. case sopstage.FieldConditionOperator:
  23389. return m.AddedConditionOperator()
  23390. case sopstage.FieldIndexSort:
  23391. return m.AddedIndexSort()
  23392. }
  23393. return nil, false
  23394. }
  23395. // AddField adds the value to the field with the given name. It returns an error if
  23396. // the field is not defined in the schema, or if the type mismatched the field
  23397. // type.
  23398. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23399. switch name {
  23400. case sopstage.FieldStatus:
  23401. v, ok := value.(int8)
  23402. if !ok {
  23403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23404. }
  23405. m.AddStatus(v)
  23406. return nil
  23407. case sopstage.FieldConditionType:
  23408. v, ok := value.(int)
  23409. if !ok {
  23410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23411. }
  23412. m.AddConditionType(v)
  23413. return nil
  23414. case sopstage.FieldConditionOperator:
  23415. v, ok := value.(int)
  23416. if !ok {
  23417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23418. }
  23419. m.AddConditionOperator(v)
  23420. return nil
  23421. case sopstage.FieldIndexSort:
  23422. v, ok := value.(int)
  23423. if !ok {
  23424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23425. }
  23426. m.AddIndexSort(v)
  23427. return nil
  23428. }
  23429. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23430. }
  23431. // ClearedFields returns all nullable fields that were cleared during this
  23432. // mutation.
  23433. func (m *SopStageMutation) ClearedFields() []string {
  23434. var fields []string
  23435. if m.FieldCleared(sopstage.FieldStatus) {
  23436. fields = append(fields, sopstage.FieldStatus)
  23437. }
  23438. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23439. fields = append(fields, sopstage.FieldDeletedAt)
  23440. }
  23441. if m.FieldCleared(sopstage.FieldActionMessage) {
  23442. fields = append(fields, sopstage.FieldActionMessage)
  23443. }
  23444. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23445. fields = append(fields, sopstage.FieldActionLabelAdd)
  23446. }
  23447. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23448. fields = append(fields, sopstage.FieldActionLabelDel)
  23449. }
  23450. if m.FieldCleared(sopstage.FieldActionForward) {
  23451. fields = append(fields, sopstage.FieldActionForward)
  23452. }
  23453. if m.FieldCleared(sopstage.FieldIndexSort) {
  23454. fields = append(fields, sopstage.FieldIndexSort)
  23455. }
  23456. return fields
  23457. }
  23458. // FieldCleared returns a boolean indicating if a field with the given name was
  23459. // cleared in this mutation.
  23460. func (m *SopStageMutation) FieldCleared(name string) bool {
  23461. _, ok := m.clearedFields[name]
  23462. return ok
  23463. }
  23464. // ClearField clears the value of the field with the given name. It returns an
  23465. // error if the field is not defined in the schema.
  23466. func (m *SopStageMutation) ClearField(name string) error {
  23467. switch name {
  23468. case sopstage.FieldStatus:
  23469. m.ClearStatus()
  23470. return nil
  23471. case sopstage.FieldDeletedAt:
  23472. m.ClearDeletedAt()
  23473. return nil
  23474. case sopstage.FieldActionMessage:
  23475. m.ClearActionMessage()
  23476. return nil
  23477. case sopstage.FieldActionLabelAdd:
  23478. m.ClearActionLabelAdd()
  23479. return nil
  23480. case sopstage.FieldActionLabelDel:
  23481. m.ClearActionLabelDel()
  23482. return nil
  23483. case sopstage.FieldActionForward:
  23484. m.ClearActionForward()
  23485. return nil
  23486. case sopstage.FieldIndexSort:
  23487. m.ClearIndexSort()
  23488. return nil
  23489. }
  23490. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23491. }
  23492. // ResetField resets all changes in the mutation for the field with the given name.
  23493. // It returns an error if the field is not defined in the schema.
  23494. func (m *SopStageMutation) ResetField(name string) error {
  23495. switch name {
  23496. case sopstage.FieldCreatedAt:
  23497. m.ResetCreatedAt()
  23498. return nil
  23499. case sopstage.FieldUpdatedAt:
  23500. m.ResetUpdatedAt()
  23501. return nil
  23502. case sopstage.FieldStatus:
  23503. m.ResetStatus()
  23504. return nil
  23505. case sopstage.FieldDeletedAt:
  23506. m.ResetDeletedAt()
  23507. return nil
  23508. case sopstage.FieldTaskID:
  23509. m.ResetTaskID()
  23510. return nil
  23511. case sopstage.FieldName:
  23512. m.ResetName()
  23513. return nil
  23514. case sopstage.FieldConditionType:
  23515. m.ResetConditionType()
  23516. return nil
  23517. case sopstage.FieldConditionOperator:
  23518. m.ResetConditionOperator()
  23519. return nil
  23520. case sopstage.FieldConditionList:
  23521. m.ResetConditionList()
  23522. return nil
  23523. case sopstage.FieldActionMessage:
  23524. m.ResetActionMessage()
  23525. return nil
  23526. case sopstage.FieldActionLabelAdd:
  23527. m.ResetActionLabelAdd()
  23528. return nil
  23529. case sopstage.FieldActionLabelDel:
  23530. m.ResetActionLabelDel()
  23531. return nil
  23532. case sopstage.FieldActionForward:
  23533. m.ResetActionForward()
  23534. return nil
  23535. case sopstage.FieldIndexSort:
  23536. m.ResetIndexSort()
  23537. return nil
  23538. }
  23539. return fmt.Errorf("unknown SopStage field %s", name)
  23540. }
  23541. // AddedEdges returns all edge names that were set/added in this mutation.
  23542. func (m *SopStageMutation) AddedEdges() []string {
  23543. edges := make([]string, 0, 3)
  23544. if m.sop_task != nil {
  23545. edges = append(edges, sopstage.EdgeSopTask)
  23546. }
  23547. if m.stage_nodes != nil {
  23548. edges = append(edges, sopstage.EdgeStageNodes)
  23549. }
  23550. if m.stage_messages != nil {
  23551. edges = append(edges, sopstage.EdgeStageMessages)
  23552. }
  23553. return edges
  23554. }
  23555. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23556. // name in this mutation.
  23557. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23558. switch name {
  23559. case sopstage.EdgeSopTask:
  23560. if id := m.sop_task; id != nil {
  23561. return []ent.Value{*id}
  23562. }
  23563. case sopstage.EdgeStageNodes:
  23564. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23565. for id := range m.stage_nodes {
  23566. ids = append(ids, id)
  23567. }
  23568. return ids
  23569. case sopstage.EdgeStageMessages:
  23570. ids := make([]ent.Value, 0, len(m.stage_messages))
  23571. for id := range m.stage_messages {
  23572. ids = append(ids, id)
  23573. }
  23574. return ids
  23575. }
  23576. return nil
  23577. }
  23578. // RemovedEdges returns all edge names that were removed in this mutation.
  23579. func (m *SopStageMutation) RemovedEdges() []string {
  23580. edges := make([]string, 0, 3)
  23581. if m.removedstage_nodes != nil {
  23582. edges = append(edges, sopstage.EdgeStageNodes)
  23583. }
  23584. if m.removedstage_messages != nil {
  23585. edges = append(edges, sopstage.EdgeStageMessages)
  23586. }
  23587. return edges
  23588. }
  23589. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23590. // the given name in this mutation.
  23591. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23592. switch name {
  23593. case sopstage.EdgeStageNodes:
  23594. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23595. for id := range m.removedstage_nodes {
  23596. ids = append(ids, id)
  23597. }
  23598. return ids
  23599. case sopstage.EdgeStageMessages:
  23600. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23601. for id := range m.removedstage_messages {
  23602. ids = append(ids, id)
  23603. }
  23604. return ids
  23605. }
  23606. return nil
  23607. }
  23608. // ClearedEdges returns all edge names that were cleared in this mutation.
  23609. func (m *SopStageMutation) ClearedEdges() []string {
  23610. edges := make([]string, 0, 3)
  23611. if m.clearedsop_task {
  23612. edges = append(edges, sopstage.EdgeSopTask)
  23613. }
  23614. if m.clearedstage_nodes {
  23615. edges = append(edges, sopstage.EdgeStageNodes)
  23616. }
  23617. if m.clearedstage_messages {
  23618. edges = append(edges, sopstage.EdgeStageMessages)
  23619. }
  23620. return edges
  23621. }
  23622. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23623. // was cleared in this mutation.
  23624. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23625. switch name {
  23626. case sopstage.EdgeSopTask:
  23627. return m.clearedsop_task
  23628. case sopstage.EdgeStageNodes:
  23629. return m.clearedstage_nodes
  23630. case sopstage.EdgeStageMessages:
  23631. return m.clearedstage_messages
  23632. }
  23633. return false
  23634. }
  23635. // ClearEdge clears the value of the edge with the given name. It returns an error
  23636. // if that edge is not defined in the schema.
  23637. func (m *SopStageMutation) ClearEdge(name string) error {
  23638. switch name {
  23639. case sopstage.EdgeSopTask:
  23640. m.ClearSopTask()
  23641. return nil
  23642. }
  23643. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23644. }
  23645. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23646. // It returns an error if the edge is not defined in the schema.
  23647. func (m *SopStageMutation) ResetEdge(name string) error {
  23648. switch name {
  23649. case sopstage.EdgeSopTask:
  23650. m.ResetSopTask()
  23651. return nil
  23652. case sopstage.EdgeStageNodes:
  23653. m.ResetStageNodes()
  23654. return nil
  23655. case sopstage.EdgeStageMessages:
  23656. m.ResetStageMessages()
  23657. return nil
  23658. }
  23659. return fmt.Errorf("unknown SopStage edge %s", name)
  23660. }
  23661. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23662. type SopTaskMutation struct {
  23663. config
  23664. op Op
  23665. typ string
  23666. id *uint64
  23667. created_at *time.Time
  23668. updated_at *time.Time
  23669. status *uint8
  23670. addstatus *int8
  23671. deleted_at *time.Time
  23672. name *string
  23673. bot_wxid_list *[]string
  23674. appendbot_wxid_list []string
  23675. _type *int
  23676. add_type *int
  23677. plan_start_time *time.Time
  23678. plan_end_time *time.Time
  23679. creator_id *string
  23680. organization_id *uint64
  23681. addorganization_id *int64
  23682. token *[]string
  23683. appendtoken []string
  23684. clearedFields map[string]struct{}
  23685. task_stages map[uint64]struct{}
  23686. removedtask_stages map[uint64]struct{}
  23687. clearedtask_stages bool
  23688. done bool
  23689. oldValue func(context.Context) (*SopTask, error)
  23690. predicates []predicate.SopTask
  23691. }
  23692. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23693. // soptaskOption allows management of the mutation configuration using functional options.
  23694. type soptaskOption func(*SopTaskMutation)
  23695. // newSopTaskMutation creates new mutation for the SopTask entity.
  23696. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23697. m := &SopTaskMutation{
  23698. config: c,
  23699. op: op,
  23700. typ: TypeSopTask,
  23701. clearedFields: make(map[string]struct{}),
  23702. }
  23703. for _, opt := range opts {
  23704. opt(m)
  23705. }
  23706. return m
  23707. }
  23708. // withSopTaskID sets the ID field of the mutation.
  23709. func withSopTaskID(id uint64) soptaskOption {
  23710. return func(m *SopTaskMutation) {
  23711. var (
  23712. err error
  23713. once sync.Once
  23714. value *SopTask
  23715. )
  23716. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23717. once.Do(func() {
  23718. if m.done {
  23719. err = errors.New("querying old values post mutation is not allowed")
  23720. } else {
  23721. value, err = m.Client().SopTask.Get(ctx, id)
  23722. }
  23723. })
  23724. return value, err
  23725. }
  23726. m.id = &id
  23727. }
  23728. }
  23729. // withSopTask sets the old SopTask of the mutation.
  23730. func withSopTask(node *SopTask) soptaskOption {
  23731. return func(m *SopTaskMutation) {
  23732. m.oldValue = func(context.Context) (*SopTask, error) {
  23733. return node, nil
  23734. }
  23735. m.id = &node.ID
  23736. }
  23737. }
  23738. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23739. // executed in a transaction (ent.Tx), a transactional client is returned.
  23740. func (m SopTaskMutation) Client() *Client {
  23741. client := &Client{config: m.config}
  23742. client.init()
  23743. return client
  23744. }
  23745. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23746. // it returns an error otherwise.
  23747. func (m SopTaskMutation) Tx() (*Tx, error) {
  23748. if _, ok := m.driver.(*txDriver); !ok {
  23749. return nil, errors.New("ent: mutation is not running in a transaction")
  23750. }
  23751. tx := &Tx{config: m.config}
  23752. tx.init()
  23753. return tx, nil
  23754. }
  23755. // SetID sets the value of the id field. Note that this
  23756. // operation is only accepted on creation of SopTask entities.
  23757. func (m *SopTaskMutation) SetID(id uint64) {
  23758. m.id = &id
  23759. }
  23760. // ID returns the ID value in the mutation. Note that the ID is only available
  23761. // if it was provided to the builder or after it was returned from the database.
  23762. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23763. if m.id == nil {
  23764. return
  23765. }
  23766. return *m.id, true
  23767. }
  23768. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23769. // That means, if the mutation is applied within a transaction with an isolation level such
  23770. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23771. // or updated by the mutation.
  23772. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23773. switch {
  23774. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23775. id, exists := m.ID()
  23776. if exists {
  23777. return []uint64{id}, nil
  23778. }
  23779. fallthrough
  23780. case m.op.Is(OpUpdate | OpDelete):
  23781. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23782. default:
  23783. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23784. }
  23785. }
  23786. // SetCreatedAt sets the "created_at" field.
  23787. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23788. m.created_at = &t
  23789. }
  23790. // CreatedAt returns the value of the "created_at" field in the mutation.
  23791. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23792. v := m.created_at
  23793. if v == nil {
  23794. return
  23795. }
  23796. return *v, true
  23797. }
  23798. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23799. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23801. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23802. if !m.op.Is(OpUpdateOne) {
  23803. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23804. }
  23805. if m.id == nil || m.oldValue == nil {
  23806. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23807. }
  23808. oldValue, err := m.oldValue(ctx)
  23809. if err != nil {
  23810. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23811. }
  23812. return oldValue.CreatedAt, nil
  23813. }
  23814. // ResetCreatedAt resets all changes to the "created_at" field.
  23815. func (m *SopTaskMutation) ResetCreatedAt() {
  23816. m.created_at = nil
  23817. }
  23818. // SetUpdatedAt sets the "updated_at" field.
  23819. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23820. m.updated_at = &t
  23821. }
  23822. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23823. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23824. v := m.updated_at
  23825. if v == nil {
  23826. return
  23827. }
  23828. return *v, true
  23829. }
  23830. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23831. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23833. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23834. if !m.op.Is(OpUpdateOne) {
  23835. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23836. }
  23837. if m.id == nil || m.oldValue == nil {
  23838. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23839. }
  23840. oldValue, err := m.oldValue(ctx)
  23841. if err != nil {
  23842. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23843. }
  23844. return oldValue.UpdatedAt, nil
  23845. }
  23846. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23847. func (m *SopTaskMutation) ResetUpdatedAt() {
  23848. m.updated_at = nil
  23849. }
  23850. // SetStatus sets the "status" field.
  23851. func (m *SopTaskMutation) SetStatus(u uint8) {
  23852. m.status = &u
  23853. m.addstatus = nil
  23854. }
  23855. // Status returns the value of the "status" field in the mutation.
  23856. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23857. v := m.status
  23858. if v == nil {
  23859. return
  23860. }
  23861. return *v, true
  23862. }
  23863. // OldStatus returns the old "status" field's value of the SopTask entity.
  23864. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23866. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23867. if !m.op.Is(OpUpdateOne) {
  23868. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23869. }
  23870. if m.id == nil || m.oldValue == nil {
  23871. return v, errors.New("OldStatus requires an ID field in the mutation")
  23872. }
  23873. oldValue, err := m.oldValue(ctx)
  23874. if err != nil {
  23875. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23876. }
  23877. return oldValue.Status, nil
  23878. }
  23879. // AddStatus adds u to the "status" field.
  23880. func (m *SopTaskMutation) AddStatus(u int8) {
  23881. if m.addstatus != nil {
  23882. *m.addstatus += u
  23883. } else {
  23884. m.addstatus = &u
  23885. }
  23886. }
  23887. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23888. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23889. v := m.addstatus
  23890. if v == nil {
  23891. return
  23892. }
  23893. return *v, true
  23894. }
  23895. // ClearStatus clears the value of the "status" field.
  23896. func (m *SopTaskMutation) ClearStatus() {
  23897. m.status = nil
  23898. m.addstatus = nil
  23899. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23900. }
  23901. // StatusCleared returns if the "status" field was cleared in this mutation.
  23902. func (m *SopTaskMutation) StatusCleared() bool {
  23903. _, ok := m.clearedFields[soptask.FieldStatus]
  23904. return ok
  23905. }
  23906. // ResetStatus resets all changes to the "status" field.
  23907. func (m *SopTaskMutation) ResetStatus() {
  23908. m.status = nil
  23909. m.addstatus = nil
  23910. delete(m.clearedFields, soptask.FieldStatus)
  23911. }
  23912. // SetDeletedAt sets the "deleted_at" field.
  23913. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23914. m.deleted_at = &t
  23915. }
  23916. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23917. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23918. v := m.deleted_at
  23919. if v == nil {
  23920. return
  23921. }
  23922. return *v, true
  23923. }
  23924. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23925. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23927. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23928. if !m.op.Is(OpUpdateOne) {
  23929. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23930. }
  23931. if m.id == nil || m.oldValue == nil {
  23932. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23933. }
  23934. oldValue, err := m.oldValue(ctx)
  23935. if err != nil {
  23936. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23937. }
  23938. return oldValue.DeletedAt, nil
  23939. }
  23940. // ClearDeletedAt clears the value of the "deleted_at" field.
  23941. func (m *SopTaskMutation) ClearDeletedAt() {
  23942. m.deleted_at = nil
  23943. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23944. }
  23945. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23946. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23947. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23948. return ok
  23949. }
  23950. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23951. func (m *SopTaskMutation) ResetDeletedAt() {
  23952. m.deleted_at = nil
  23953. delete(m.clearedFields, soptask.FieldDeletedAt)
  23954. }
  23955. // SetName sets the "name" field.
  23956. func (m *SopTaskMutation) SetName(s string) {
  23957. m.name = &s
  23958. }
  23959. // Name returns the value of the "name" field in the mutation.
  23960. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23961. v := m.name
  23962. if v == nil {
  23963. return
  23964. }
  23965. return *v, true
  23966. }
  23967. // OldName returns the old "name" field's value of the SopTask entity.
  23968. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23970. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23971. if !m.op.Is(OpUpdateOne) {
  23972. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23973. }
  23974. if m.id == nil || m.oldValue == nil {
  23975. return v, errors.New("OldName requires an ID field in the mutation")
  23976. }
  23977. oldValue, err := m.oldValue(ctx)
  23978. if err != nil {
  23979. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23980. }
  23981. return oldValue.Name, nil
  23982. }
  23983. // ResetName resets all changes to the "name" field.
  23984. func (m *SopTaskMutation) ResetName() {
  23985. m.name = nil
  23986. }
  23987. // SetBotWxidList sets the "bot_wxid_list" field.
  23988. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23989. m.bot_wxid_list = &s
  23990. m.appendbot_wxid_list = nil
  23991. }
  23992. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23993. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23994. v := m.bot_wxid_list
  23995. if v == nil {
  23996. return
  23997. }
  23998. return *v, true
  23999. }
  24000. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  24001. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24003. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  24004. if !m.op.Is(OpUpdateOne) {
  24005. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  24006. }
  24007. if m.id == nil || m.oldValue == nil {
  24008. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  24009. }
  24010. oldValue, err := m.oldValue(ctx)
  24011. if err != nil {
  24012. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  24013. }
  24014. return oldValue.BotWxidList, nil
  24015. }
  24016. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  24017. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  24018. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  24019. }
  24020. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  24021. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  24022. if len(m.appendbot_wxid_list) == 0 {
  24023. return nil, false
  24024. }
  24025. return m.appendbot_wxid_list, true
  24026. }
  24027. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  24028. func (m *SopTaskMutation) ClearBotWxidList() {
  24029. m.bot_wxid_list = nil
  24030. m.appendbot_wxid_list = nil
  24031. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  24032. }
  24033. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  24034. func (m *SopTaskMutation) BotWxidListCleared() bool {
  24035. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24036. return ok
  24037. }
  24038. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24039. func (m *SopTaskMutation) ResetBotWxidList() {
  24040. m.bot_wxid_list = nil
  24041. m.appendbot_wxid_list = nil
  24042. delete(m.clearedFields, soptask.FieldBotWxidList)
  24043. }
  24044. // SetType sets the "type" field.
  24045. func (m *SopTaskMutation) SetType(i int) {
  24046. m._type = &i
  24047. m.add_type = nil
  24048. }
  24049. // GetType returns the value of the "type" field in the mutation.
  24050. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24051. v := m._type
  24052. if v == nil {
  24053. return
  24054. }
  24055. return *v, true
  24056. }
  24057. // OldType returns the old "type" field's value of the SopTask entity.
  24058. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24060. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24061. if !m.op.Is(OpUpdateOne) {
  24062. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24063. }
  24064. if m.id == nil || m.oldValue == nil {
  24065. return v, errors.New("OldType requires an ID field in the mutation")
  24066. }
  24067. oldValue, err := m.oldValue(ctx)
  24068. if err != nil {
  24069. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24070. }
  24071. return oldValue.Type, nil
  24072. }
  24073. // AddType adds i to the "type" field.
  24074. func (m *SopTaskMutation) AddType(i int) {
  24075. if m.add_type != nil {
  24076. *m.add_type += i
  24077. } else {
  24078. m.add_type = &i
  24079. }
  24080. }
  24081. // AddedType returns the value that was added to the "type" field in this mutation.
  24082. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24083. v := m.add_type
  24084. if v == nil {
  24085. return
  24086. }
  24087. return *v, true
  24088. }
  24089. // ResetType resets all changes to the "type" field.
  24090. func (m *SopTaskMutation) ResetType() {
  24091. m._type = nil
  24092. m.add_type = nil
  24093. }
  24094. // SetPlanStartTime sets the "plan_start_time" field.
  24095. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24096. m.plan_start_time = &t
  24097. }
  24098. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24099. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24100. v := m.plan_start_time
  24101. if v == nil {
  24102. return
  24103. }
  24104. return *v, true
  24105. }
  24106. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24107. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24109. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24110. if !m.op.Is(OpUpdateOne) {
  24111. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24112. }
  24113. if m.id == nil || m.oldValue == nil {
  24114. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24115. }
  24116. oldValue, err := m.oldValue(ctx)
  24117. if err != nil {
  24118. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24119. }
  24120. return oldValue.PlanStartTime, nil
  24121. }
  24122. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24123. func (m *SopTaskMutation) ClearPlanStartTime() {
  24124. m.plan_start_time = nil
  24125. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24126. }
  24127. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24128. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24129. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24130. return ok
  24131. }
  24132. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24133. func (m *SopTaskMutation) ResetPlanStartTime() {
  24134. m.plan_start_time = nil
  24135. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24136. }
  24137. // SetPlanEndTime sets the "plan_end_time" field.
  24138. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24139. m.plan_end_time = &t
  24140. }
  24141. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24142. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24143. v := m.plan_end_time
  24144. if v == nil {
  24145. return
  24146. }
  24147. return *v, true
  24148. }
  24149. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24150. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24152. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24153. if !m.op.Is(OpUpdateOne) {
  24154. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24155. }
  24156. if m.id == nil || m.oldValue == nil {
  24157. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24158. }
  24159. oldValue, err := m.oldValue(ctx)
  24160. if err != nil {
  24161. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24162. }
  24163. return oldValue.PlanEndTime, nil
  24164. }
  24165. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24166. func (m *SopTaskMutation) ClearPlanEndTime() {
  24167. m.plan_end_time = nil
  24168. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24169. }
  24170. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24171. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24172. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24173. return ok
  24174. }
  24175. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24176. func (m *SopTaskMutation) ResetPlanEndTime() {
  24177. m.plan_end_time = nil
  24178. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24179. }
  24180. // SetCreatorID sets the "creator_id" field.
  24181. func (m *SopTaskMutation) SetCreatorID(s string) {
  24182. m.creator_id = &s
  24183. }
  24184. // CreatorID returns the value of the "creator_id" field in the mutation.
  24185. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24186. v := m.creator_id
  24187. if v == nil {
  24188. return
  24189. }
  24190. return *v, true
  24191. }
  24192. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24193. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24195. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24196. if !m.op.Is(OpUpdateOne) {
  24197. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24198. }
  24199. if m.id == nil || m.oldValue == nil {
  24200. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24201. }
  24202. oldValue, err := m.oldValue(ctx)
  24203. if err != nil {
  24204. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24205. }
  24206. return oldValue.CreatorID, nil
  24207. }
  24208. // ClearCreatorID clears the value of the "creator_id" field.
  24209. func (m *SopTaskMutation) ClearCreatorID() {
  24210. m.creator_id = nil
  24211. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24212. }
  24213. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24214. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24215. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24216. return ok
  24217. }
  24218. // ResetCreatorID resets all changes to the "creator_id" field.
  24219. func (m *SopTaskMutation) ResetCreatorID() {
  24220. m.creator_id = nil
  24221. delete(m.clearedFields, soptask.FieldCreatorID)
  24222. }
  24223. // SetOrganizationID sets the "organization_id" field.
  24224. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24225. m.organization_id = &u
  24226. m.addorganization_id = nil
  24227. }
  24228. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24229. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24230. v := m.organization_id
  24231. if v == nil {
  24232. return
  24233. }
  24234. return *v, true
  24235. }
  24236. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24237. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24239. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24240. if !m.op.Is(OpUpdateOne) {
  24241. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24242. }
  24243. if m.id == nil || m.oldValue == nil {
  24244. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24245. }
  24246. oldValue, err := m.oldValue(ctx)
  24247. if err != nil {
  24248. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24249. }
  24250. return oldValue.OrganizationID, nil
  24251. }
  24252. // AddOrganizationID adds u to the "organization_id" field.
  24253. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24254. if m.addorganization_id != nil {
  24255. *m.addorganization_id += u
  24256. } else {
  24257. m.addorganization_id = &u
  24258. }
  24259. }
  24260. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24261. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24262. v := m.addorganization_id
  24263. if v == nil {
  24264. return
  24265. }
  24266. return *v, true
  24267. }
  24268. // ClearOrganizationID clears the value of the "organization_id" field.
  24269. func (m *SopTaskMutation) ClearOrganizationID() {
  24270. m.organization_id = nil
  24271. m.addorganization_id = nil
  24272. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24273. }
  24274. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24275. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24276. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24277. return ok
  24278. }
  24279. // ResetOrganizationID resets all changes to the "organization_id" field.
  24280. func (m *SopTaskMutation) ResetOrganizationID() {
  24281. m.organization_id = nil
  24282. m.addorganization_id = nil
  24283. delete(m.clearedFields, soptask.FieldOrganizationID)
  24284. }
  24285. // SetToken sets the "token" field.
  24286. func (m *SopTaskMutation) SetToken(s []string) {
  24287. m.token = &s
  24288. m.appendtoken = nil
  24289. }
  24290. // Token returns the value of the "token" field in the mutation.
  24291. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24292. v := m.token
  24293. if v == nil {
  24294. return
  24295. }
  24296. return *v, true
  24297. }
  24298. // OldToken returns the old "token" field's value of the SopTask entity.
  24299. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24301. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24302. if !m.op.Is(OpUpdateOne) {
  24303. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24304. }
  24305. if m.id == nil || m.oldValue == nil {
  24306. return v, errors.New("OldToken requires an ID field in the mutation")
  24307. }
  24308. oldValue, err := m.oldValue(ctx)
  24309. if err != nil {
  24310. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24311. }
  24312. return oldValue.Token, nil
  24313. }
  24314. // AppendToken adds s to the "token" field.
  24315. func (m *SopTaskMutation) AppendToken(s []string) {
  24316. m.appendtoken = append(m.appendtoken, s...)
  24317. }
  24318. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24319. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24320. if len(m.appendtoken) == 0 {
  24321. return nil, false
  24322. }
  24323. return m.appendtoken, true
  24324. }
  24325. // ClearToken clears the value of the "token" field.
  24326. func (m *SopTaskMutation) ClearToken() {
  24327. m.token = nil
  24328. m.appendtoken = nil
  24329. m.clearedFields[soptask.FieldToken] = struct{}{}
  24330. }
  24331. // TokenCleared returns if the "token" field was cleared in this mutation.
  24332. func (m *SopTaskMutation) TokenCleared() bool {
  24333. _, ok := m.clearedFields[soptask.FieldToken]
  24334. return ok
  24335. }
  24336. // ResetToken resets all changes to the "token" field.
  24337. func (m *SopTaskMutation) ResetToken() {
  24338. m.token = nil
  24339. m.appendtoken = nil
  24340. delete(m.clearedFields, soptask.FieldToken)
  24341. }
  24342. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24343. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24344. if m.task_stages == nil {
  24345. m.task_stages = make(map[uint64]struct{})
  24346. }
  24347. for i := range ids {
  24348. m.task_stages[ids[i]] = struct{}{}
  24349. }
  24350. }
  24351. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24352. func (m *SopTaskMutation) ClearTaskStages() {
  24353. m.clearedtask_stages = true
  24354. }
  24355. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24356. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24357. return m.clearedtask_stages
  24358. }
  24359. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24360. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24361. if m.removedtask_stages == nil {
  24362. m.removedtask_stages = make(map[uint64]struct{})
  24363. }
  24364. for i := range ids {
  24365. delete(m.task_stages, ids[i])
  24366. m.removedtask_stages[ids[i]] = struct{}{}
  24367. }
  24368. }
  24369. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24370. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24371. for id := range m.removedtask_stages {
  24372. ids = append(ids, id)
  24373. }
  24374. return
  24375. }
  24376. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24377. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24378. for id := range m.task_stages {
  24379. ids = append(ids, id)
  24380. }
  24381. return
  24382. }
  24383. // ResetTaskStages resets all changes to the "task_stages" edge.
  24384. func (m *SopTaskMutation) ResetTaskStages() {
  24385. m.task_stages = nil
  24386. m.clearedtask_stages = false
  24387. m.removedtask_stages = nil
  24388. }
  24389. // Where appends a list predicates to the SopTaskMutation builder.
  24390. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24391. m.predicates = append(m.predicates, ps...)
  24392. }
  24393. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24394. // users can use type-assertion to append predicates that do not depend on any generated package.
  24395. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24396. p := make([]predicate.SopTask, len(ps))
  24397. for i := range ps {
  24398. p[i] = ps[i]
  24399. }
  24400. m.Where(p...)
  24401. }
  24402. // Op returns the operation name.
  24403. func (m *SopTaskMutation) Op() Op {
  24404. return m.op
  24405. }
  24406. // SetOp allows setting the mutation operation.
  24407. func (m *SopTaskMutation) SetOp(op Op) {
  24408. m.op = op
  24409. }
  24410. // Type returns the node type of this mutation (SopTask).
  24411. func (m *SopTaskMutation) Type() string {
  24412. return m.typ
  24413. }
  24414. // Fields returns all fields that were changed during this mutation. Note that in
  24415. // order to get all numeric fields that were incremented/decremented, call
  24416. // AddedFields().
  24417. func (m *SopTaskMutation) Fields() []string {
  24418. fields := make([]string, 0, 12)
  24419. if m.created_at != nil {
  24420. fields = append(fields, soptask.FieldCreatedAt)
  24421. }
  24422. if m.updated_at != nil {
  24423. fields = append(fields, soptask.FieldUpdatedAt)
  24424. }
  24425. if m.status != nil {
  24426. fields = append(fields, soptask.FieldStatus)
  24427. }
  24428. if m.deleted_at != nil {
  24429. fields = append(fields, soptask.FieldDeletedAt)
  24430. }
  24431. if m.name != nil {
  24432. fields = append(fields, soptask.FieldName)
  24433. }
  24434. if m.bot_wxid_list != nil {
  24435. fields = append(fields, soptask.FieldBotWxidList)
  24436. }
  24437. if m._type != nil {
  24438. fields = append(fields, soptask.FieldType)
  24439. }
  24440. if m.plan_start_time != nil {
  24441. fields = append(fields, soptask.FieldPlanStartTime)
  24442. }
  24443. if m.plan_end_time != nil {
  24444. fields = append(fields, soptask.FieldPlanEndTime)
  24445. }
  24446. if m.creator_id != nil {
  24447. fields = append(fields, soptask.FieldCreatorID)
  24448. }
  24449. if m.organization_id != nil {
  24450. fields = append(fields, soptask.FieldOrganizationID)
  24451. }
  24452. if m.token != nil {
  24453. fields = append(fields, soptask.FieldToken)
  24454. }
  24455. return fields
  24456. }
  24457. // Field returns the value of a field with the given name. The second boolean
  24458. // return value indicates that this field was not set, or was not defined in the
  24459. // schema.
  24460. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24461. switch name {
  24462. case soptask.FieldCreatedAt:
  24463. return m.CreatedAt()
  24464. case soptask.FieldUpdatedAt:
  24465. return m.UpdatedAt()
  24466. case soptask.FieldStatus:
  24467. return m.Status()
  24468. case soptask.FieldDeletedAt:
  24469. return m.DeletedAt()
  24470. case soptask.FieldName:
  24471. return m.Name()
  24472. case soptask.FieldBotWxidList:
  24473. return m.BotWxidList()
  24474. case soptask.FieldType:
  24475. return m.GetType()
  24476. case soptask.FieldPlanStartTime:
  24477. return m.PlanStartTime()
  24478. case soptask.FieldPlanEndTime:
  24479. return m.PlanEndTime()
  24480. case soptask.FieldCreatorID:
  24481. return m.CreatorID()
  24482. case soptask.FieldOrganizationID:
  24483. return m.OrganizationID()
  24484. case soptask.FieldToken:
  24485. return m.Token()
  24486. }
  24487. return nil, false
  24488. }
  24489. // OldField returns the old value of the field from the database. An error is
  24490. // returned if the mutation operation is not UpdateOne, or the query to the
  24491. // database failed.
  24492. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24493. switch name {
  24494. case soptask.FieldCreatedAt:
  24495. return m.OldCreatedAt(ctx)
  24496. case soptask.FieldUpdatedAt:
  24497. return m.OldUpdatedAt(ctx)
  24498. case soptask.FieldStatus:
  24499. return m.OldStatus(ctx)
  24500. case soptask.FieldDeletedAt:
  24501. return m.OldDeletedAt(ctx)
  24502. case soptask.FieldName:
  24503. return m.OldName(ctx)
  24504. case soptask.FieldBotWxidList:
  24505. return m.OldBotWxidList(ctx)
  24506. case soptask.FieldType:
  24507. return m.OldType(ctx)
  24508. case soptask.FieldPlanStartTime:
  24509. return m.OldPlanStartTime(ctx)
  24510. case soptask.FieldPlanEndTime:
  24511. return m.OldPlanEndTime(ctx)
  24512. case soptask.FieldCreatorID:
  24513. return m.OldCreatorID(ctx)
  24514. case soptask.FieldOrganizationID:
  24515. return m.OldOrganizationID(ctx)
  24516. case soptask.FieldToken:
  24517. return m.OldToken(ctx)
  24518. }
  24519. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24520. }
  24521. // SetField sets the value of a field with the given name. It returns an error if
  24522. // the field is not defined in the schema, or if the type mismatched the field
  24523. // type.
  24524. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24525. switch name {
  24526. case soptask.FieldCreatedAt:
  24527. v, ok := value.(time.Time)
  24528. if !ok {
  24529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24530. }
  24531. m.SetCreatedAt(v)
  24532. return nil
  24533. case soptask.FieldUpdatedAt:
  24534. v, ok := value.(time.Time)
  24535. if !ok {
  24536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24537. }
  24538. m.SetUpdatedAt(v)
  24539. return nil
  24540. case soptask.FieldStatus:
  24541. v, ok := value.(uint8)
  24542. if !ok {
  24543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24544. }
  24545. m.SetStatus(v)
  24546. return nil
  24547. case soptask.FieldDeletedAt:
  24548. v, ok := value.(time.Time)
  24549. if !ok {
  24550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24551. }
  24552. m.SetDeletedAt(v)
  24553. return nil
  24554. case soptask.FieldName:
  24555. v, ok := value.(string)
  24556. if !ok {
  24557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24558. }
  24559. m.SetName(v)
  24560. return nil
  24561. case soptask.FieldBotWxidList:
  24562. v, ok := value.([]string)
  24563. if !ok {
  24564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24565. }
  24566. m.SetBotWxidList(v)
  24567. return nil
  24568. case soptask.FieldType:
  24569. v, ok := value.(int)
  24570. if !ok {
  24571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24572. }
  24573. m.SetType(v)
  24574. return nil
  24575. case soptask.FieldPlanStartTime:
  24576. v, ok := value.(time.Time)
  24577. if !ok {
  24578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24579. }
  24580. m.SetPlanStartTime(v)
  24581. return nil
  24582. case soptask.FieldPlanEndTime:
  24583. v, ok := value.(time.Time)
  24584. if !ok {
  24585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24586. }
  24587. m.SetPlanEndTime(v)
  24588. return nil
  24589. case soptask.FieldCreatorID:
  24590. v, ok := value.(string)
  24591. if !ok {
  24592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24593. }
  24594. m.SetCreatorID(v)
  24595. return nil
  24596. case soptask.FieldOrganizationID:
  24597. v, ok := value.(uint64)
  24598. if !ok {
  24599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24600. }
  24601. m.SetOrganizationID(v)
  24602. return nil
  24603. case soptask.FieldToken:
  24604. v, ok := value.([]string)
  24605. if !ok {
  24606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24607. }
  24608. m.SetToken(v)
  24609. return nil
  24610. }
  24611. return fmt.Errorf("unknown SopTask field %s", name)
  24612. }
  24613. // AddedFields returns all numeric fields that were incremented/decremented during
  24614. // this mutation.
  24615. func (m *SopTaskMutation) AddedFields() []string {
  24616. var fields []string
  24617. if m.addstatus != nil {
  24618. fields = append(fields, soptask.FieldStatus)
  24619. }
  24620. if m.add_type != nil {
  24621. fields = append(fields, soptask.FieldType)
  24622. }
  24623. if m.addorganization_id != nil {
  24624. fields = append(fields, soptask.FieldOrganizationID)
  24625. }
  24626. return fields
  24627. }
  24628. // AddedField returns the numeric value that was incremented/decremented on a field
  24629. // with the given name. The second boolean return value indicates that this field
  24630. // was not set, or was not defined in the schema.
  24631. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24632. switch name {
  24633. case soptask.FieldStatus:
  24634. return m.AddedStatus()
  24635. case soptask.FieldType:
  24636. return m.AddedType()
  24637. case soptask.FieldOrganizationID:
  24638. return m.AddedOrganizationID()
  24639. }
  24640. return nil, false
  24641. }
  24642. // AddField adds the value to the field with the given name. It returns an error if
  24643. // the field is not defined in the schema, or if the type mismatched the field
  24644. // type.
  24645. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24646. switch name {
  24647. case soptask.FieldStatus:
  24648. v, ok := value.(int8)
  24649. if !ok {
  24650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24651. }
  24652. m.AddStatus(v)
  24653. return nil
  24654. case soptask.FieldType:
  24655. v, ok := value.(int)
  24656. if !ok {
  24657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24658. }
  24659. m.AddType(v)
  24660. return nil
  24661. case soptask.FieldOrganizationID:
  24662. v, ok := value.(int64)
  24663. if !ok {
  24664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24665. }
  24666. m.AddOrganizationID(v)
  24667. return nil
  24668. }
  24669. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24670. }
  24671. // ClearedFields returns all nullable fields that were cleared during this
  24672. // mutation.
  24673. func (m *SopTaskMutation) ClearedFields() []string {
  24674. var fields []string
  24675. if m.FieldCleared(soptask.FieldStatus) {
  24676. fields = append(fields, soptask.FieldStatus)
  24677. }
  24678. if m.FieldCleared(soptask.FieldDeletedAt) {
  24679. fields = append(fields, soptask.FieldDeletedAt)
  24680. }
  24681. if m.FieldCleared(soptask.FieldBotWxidList) {
  24682. fields = append(fields, soptask.FieldBotWxidList)
  24683. }
  24684. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24685. fields = append(fields, soptask.FieldPlanStartTime)
  24686. }
  24687. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24688. fields = append(fields, soptask.FieldPlanEndTime)
  24689. }
  24690. if m.FieldCleared(soptask.FieldCreatorID) {
  24691. fields = append(fields, soptask.FieldCreatorID)
  24692. }
  24693. if m.FieldCleared(soptask.FieldOrganizationID) {
  24694. fields = append(fields, soptask.FieldOrganizationID)
  24695. }
  24696. if m.FieldCleared(soptask.FieldToken) {
  24697. fields = append(fields, soptask.FieldToken)
  24698. }
  24699. return fields
  24700. }
  24701. // FieldCleared returns a boolean indicating if a field with the given name was
  24702. // cleared in this mutation.
  24703. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24704. _, ok := m.clearedFields[name]
  24705. return ok
  24706. }
  24707. // ClearField clears the value of the field with the given name. It returns an
  24708. // error if the field is not defined in the schema.
  24709. func (m *SopTaskMutation) ClearField(name string) error {
  24710. switch name {
  24711. case soptask.FieldStatus:
  24712. m.ClearStatus()
  24713. return nil
  24714. case soptask.FieldDeletedAt:
  24715. m.ClearDeletedAt()
  24716. return nil
  24717. case soptask.FieldBotWxidList:
  24718. m.ClearBotWxidList()
  24719. return nil
  24720. case soptask.FieldPlanStartTime:
  24721. m.ClearPlanStartTime()
  24722. return nil
  24723. case soptask.FieldPlanEndTime:
  24724. m.ClearPlanEndTime()
  24725. return nil
  24726. case soptask.FieldCreatorID:
  24727. m.ClearCreatorID()
  24728. return nil
  24729. case soptask.FieldOrganizationID:
  24730. m.ClearOrganizationID()
  24731. return nil
  24732. case soptask.FieldToken:
  24733. m.ClearToken()
  24734. return nil
  24735. }
  24736. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24737. }
  24738. // ResetField resets all changes in the mutation for the field with the given name.
  24739. // It returns an error if the field is not defined in the schema.
  24740. func (m *SopTaskMutation) ResetField(name string) error {
  24741. switch name {
  24742. case soptask.FieldCreatedAt:
  24743. m.ResetCreatedAt()
  24744. return nil
  24745. case soptask.FieldUpdatedAt:
  24746. m.ResetUpdatedAt()
  24747. return nil
  24748. case soptask.FieldStatus:
  24749. m.ResetStatus()
  24750. return nil
  24751. case soptask.FieldDeletedAt:
  24752. m.ResetDeletedAt()
  24753. return nil
  24754. case soptask.FieldName:
  24755. m.ResetName()
  24756. return nil
  24757. case soptask.FieldBotWxidList:
  24758. m.ResetBotWxidList()
  24759. return nil
  24760. case soptask.FieldType:
  24761. m.ResetType()
  24762. return nil
  24763. case soptask.FieldPlanStartTime:
  24764. m.ResetPlanStartTime()
  24765. return nil
  24766. case soptask.FieldPlanEndTime:
  24767. m.ResetPlanEndTime()
  24768. return nil
  24769. case soptask.FieldCreatorID:
  24770. m.ResetCreatorID()
  24771. return nil
  24772. case soptask.FieldOrganizationID:
  24773. m.ResetOrganizationID()
  24774. return nil
  24775. case soptask.FieldToken:
  24776. m.ResetToken()
  24777. return nil
  24778. }
  24779. return fmt.Errorf("unknown SopTask field %s", name)
  24780. }
  24781. // AddedEdges returns all edge names that were set/added in this mutation.
  24782. func (m *SopTaskMutation) AddedEdges() []string {
  24783. edges := make([]string, 0, 1)
  24784. if m.task_stages != nil {
  24785. edges = append(edges, soptask.EdgeTaskStages)
  24786. }
  24787. return edges
  24788. }
  24789. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24790. // name in this mutation.
  24791. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24792. switch name {
  24793. case soptask.EdgeTaskStages:
  24794. ids := make([]ent.Value, 0, len(m.task_stages))
  24795. for id := range m.task_stages {
  24796. ids = append(ids, id)
  24797. }
  24798. return ids
  24799. }
  24800. return nil
  24801. }
  24802. // RemovedEdges returns all edge names that were removed in this mutation.
  24803. func (m *SopTaskMutation) RemovedEdges() []string {
  24804. edges := make([]string, 0, 1)
  24805. if m.removedtask_stages != nil {
  24806. edges = append(edges, soptask.EdgeTaskStages)
  24807. }
  24808. return edges
  24809. }
  24810. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24811. // the given name in this mutation.
  24812. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24813. switch name {
  24814. case soptask.EdgeTaskStages:
  24815. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24816. for id := range m.removedtask_stages {
  24817. ids = append(ids, id)
  24818. }
  24819. return ids
  24820. }
  24821. return nil
  24822. }
  24823. // ClearedEdges returns all edge names that were cleared in this mutation.
  24824. func (m *SopTaskMutation) ClearedEdges() []string {
  24825. edges := make([]string, 0, 1)
  24826. if m.clearedtask_stages {
  24827. edges = append(edges, soptask.EdgeTaskStages)
  24828. }
  24829. return edges
  24830. }
  24831. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24832. // was cleared in this mutation.
  24833. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24834. switch name {
  24835. case soptask.EdgeTaskStages:
  24836. return m.clearedtask_stages
  24837. }
  24838. return false
  24839. }
  24840. // ClearEdge clears the value of the edge with the given name. It returns an error
  24841. // if that edge is not defined in the schema.
  24842. func (m *SopTaskMutation) ClearEdge(name string) error {
  24843. switch name {
  24844. }
  24845. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24846. }
  24847. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24848. // It returns an error if the edge is not defined in the schema.
  24849. func (m *SopTaskMutation) ResetEdge(name string) error {
  24850. switch name {
  24851. case soptask.EdgeTaskStages:
  24852. m.ResetTaskStages()
  24853. return nil
  24854. }
  24855. return fmt.Errorf("unknown SopTask edge %s", name)
  24856. }
  24857. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24858. type TokenMutation struct {
  24859. config
  24860. op Op
  24861. typ string
  24862. id *uint64
  24863. created_at *time.Time
  24864. updated_at *time.Time
  24865. deleted_at *time.Time
  24866. expire_at *time.Time
  24867. token *string
  24868. mac *string
  24869. organization_id *uint64
  24870. addorganization_id *int64
  24871. custom_agent_base *string
  24872. custom_agent_key *string
  24873. openai_base *string
  24874. openai_key *string
  24875. clearedFields map[string]struct{}
  24876. agent *uint64
  24877. clearedagent bool
  24878. done bool
  24879. oldValue func(context.Context) (*Token, error)
  24880. predicates []predicate.Token
  24881. }
  24882. var _ ent.Mutation = (*TokenMutation)(nil)
  24883. // tokenOption allows management of the mutation configuration using functional options.
  24884. type tokenOption func(*TokenMutation)
  24885. // newTokenMutation creates new mutation for the Token entity.
  24886. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24887. m := &TokenMutation{
  24888. config: c,
  24889. op: op,
  24890. typ: TypeToken,
  24891. clearedFields: make(map[string]struct{}),
  24892. }
  24893. for _, opt := range opts {
  24894. opt(m)
  24895. }
  24896. return m
  24897. }
  24898. // withTokenID sets the ID field of the mutation.
  24899. func withTokenID(id uint64) tokenOption {
  24900. return func(m *TokenMutation) {
  24901. var (
  24902. err error
  24903. once sync.Once
  24904. value *Token
  24905. )
  24906. m.oldValue = func(ctx context.Context) (*Token, error) {
  24907. once.Do(func() {
  24908. if m.done {
  24909. err = errors.New("querying old values post mutation is not allowed")
  24910. } else {
  24911. value, err = m.Client().Token.Get(ctx, id)
  24912. }
  24913. })
  24914. return value, err
  24915. }
  24916. m.id = &id
  24917. }
  24918. }
  24919. // withToken sets the old Token of the mutation.
  24920. func withToken(node *Token) tokenOption {
  24921. return func(m *TokenMutation) {
  24922. m.oldValue = func(context.Context) (*Token, error) {
  24923. return node, nil
  24924. }
  24925. m.id = &node.ID
  24926. }
  24927. }
  24928. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24929. // executed in a transaction (ent.Tx), a transactional client is returned.
  24930. func (m TokenMutation) Client() *Client {
  24931. client := &Client{config: m.config}
  24932. client.init()
  24933. return client
  24934. }
  24935. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24936. // it returns an error otherwise.
  24937. func (m TokenMutation) Tx() (*Tx, error) {
  24938. if _, ok := m.driver.(*txDriver); !ok {
  24939. return nil, errors.New("ent: mutation is not running in a transaction")
  24940. }
  24941. tx := &Tx{config: m.config}
  24942. tx.init()
  24943. return tx, nil
  24944. }
  24945. // SetID sets the value of the id field. Note that this
  24946. // operation is only accepted on creation of Token entities.
  24947. func (m *TokenMutation) SetID(id uint64) {
  24948. m.id = &id
  24949. }
  24950. // ID returns the ID value in the mutation. Note that the ID is only available
  24951. // if it was provided to the builder or after it was returned from the database.
  24952. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24953. if m.id == nil {
  24954. return
  24955. }
  24956. return *m.id, true
  24957. }
  24958. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24959. // That means, if the mutation is applied within a transaction with an isolation level such
  24960. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24961. // or updated by the mutation.
  24962. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24963. switch {
  24964. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24965. id, exists := m.ID()
  24966. if exists {
  24967. return []uint64{id}, nil
  24968. }
  24969. fallthrough
  24970. case m.op.Is(OpUpdate | OpDelete):
  24971. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24972. default:
  24973. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24974. }
  24975. }
  24976. // SetCreatedAt sets the "created_at" field.
  24977. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24978. m.created_at = &t
  24979. }
  24980. // CreatedAt returns the value of the "created_at" field in the mutation.
  24981. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24982. v := m.created_at
  24983. if v == nil {
  24984. return
  24985. }
  24986. return *v, true
  24987. }
  24988. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24989. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24991. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24992. if !m.op.Is(OpUpdateOne) {
  24993. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24994. }
  24995. if m.id == nil || m.oldValue == nil {
  24996. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24997. }
  24998. oldValue, err := m.oldValue(ctx)
  24999. if err != nil {
  25000. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25001. }
  25002. return oldValue.CreatedAt, nil
  25003. }
  25004. // ResetCreatedAt resets all changes to the "created_at" field.
  25005. func (m *TokenMutation) ResetCreatedAt() {
  25006. m.created_at = nil
  25007. }
  25008. // SetUpdatedAt sets the "updated_at" field.
  25009. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  25010. m.updated_at = &t
  25011. }
  25012. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25013. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  25014. v := m.updated_at
  25015. if v == nil {
  25016. return
  25017. }
  25018. return *v, true
  25019. }
  25020. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  25021. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25023. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25024. if !m.op.Is(OpUpdateOne) {
  25025. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25026. }
  25027. if m.id == nil || m.oldValue == nil {
  25028. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25029. }
  25030. oldValue, err := m.oldValue(ctx)
  25031. if err != nil {
  25032. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25033. }
  25034. return oldValue.UpdatedAt, nil
  25035. }
  25036. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25037. func (m *TokenMutation) ResetUpdatedAt() {
  25038. m.updated_at = nil
  25039. }
  25040. // SetDeletedAt sets the "deleted_at" field.
  25041. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25042. m.deleted_at = &t
  25043. }
  25044. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25045. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25046. v := m.deleted_at
  25047. if v == nil {
  25048. return
  25049. }
  25050. return *v, true
  25051. }
  25052. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25053. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25055. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25056. if !m.op.Is(OpUpdateOne) {
  25057. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25058. }
  25059. if m.id == nil || m.oldValue == nil {
  25060. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25061. }
  25062. oldValue, err := m.oldValue(ctx)
  25063. if err != nil {
  25064. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25065. }
  25066. return oldValue.DeletedAt, nil
  25067. }
  25068. // ClearDeletedAt clears the value of the "deleted_at" field.
  25069. func (m *TokenMutation) ClearDeletedAt() {
  25070. m.deleted_at = nil
  25071. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25072. }
  25073. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25074. func (m *TokenMutation) DeletedAtCleared() bool {
  25075. _, ok := m.clearedFields[token.FieldDeletedAt]
  25076. return ok
  25077. }
  25078. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25079. func (m *TokenMutation) ResetDeletedAt() {
  25080. m.deleted_at = nil
  25081. delete(m.clearedFields, token.FieldDeletedAt)
  25082. }
  25083. // SetExpireAt sets the "expire_at" field.
  25084. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25085. m.expire_at = &t
  25086. }
  25087. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25088. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25089. v := m.expire_at
  25090. if v == nil {
  25091. return
  25092. }
  25093. return *v, true
  25094. }
  25095. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25096. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25098. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25099. if !m.op.Is(OpUpdateOne) {
  25100. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25101. }
  25102. if m.id == nil || m.oldValue == nil {
  25103. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25104. }
  25105. oldValue, err := m.oldValue(ctx)
  25106. if err != nil {
  25107. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25108. }
  25109. return oldValue.ExpireAt, nil
  25110. }
  25111. // ClearExpireAt clears the value of the "expire_at" field.
  25112. func (m *TokenMutation) ClearExpireAt() {
  25113. m.expire_at = nil
  25114. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25115. }
  25116. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25117. func (m *TokenMutation) ExpireAtCleared() bool {
  25118. _, ok := m.clearedFields[token.FieldExpireAt]
  25119. return ok
  25120. }
  25121. // ResetExpireAt resets all changes to the "expire_at" field.
  25122. func (m *TokenMutation) ResetExpireAt() {
  25123. m.expire_at = nil
  25124. delete(m.clearedFields, token.FieldExpireAt)
  25125. }
  25126. // SetToken sets the "token" field.
  25127. func (m *TokenMutation) SetToken(s string) {
  25128. m.token = &s
  25129. }
  25130. // Token returns the value of the "token" field in the mutation.
  25131. func (m *TokenMutation) Token() (r string, exists bool) {
  25132. v := m.token
  25133. if v == nil {
  25134. return
  25135. }
  25136. return *v, true
  25137. }
  25138. // OldToken returns the old "token" field's value of the Token entity.
  25139. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25141. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25142. if !m.op.Is(OpUpdateOne) {
  25143. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25144. }
  25145. if m.id == nil || m.oldValue == nil {
  25146. return v, errors.New("OldToken requires an ID field in the mutation")
  25147. }
  25148. oldValue, err := m.oldValue(ctx)
  25149. if err != nil {
  25150. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25151. }
  25152. return oldValue.Token, nil
  25153. }
  25154. // ClearToken clears the value of the "token" field.
  25155. func (m *TokenMutation) ClearToken() {
  25156. m.token = nil
  25157. m.clearedFields[token.FieldToken] = struct{}{}
  25158. }
  25159. // TokenCleared returns if the "token" field was cleared in this mutation.
  25160. func (m *TokenMutation) TokenCleared() bool {
  25161. _, ok := m.clearedFields[token.FieldToken]
  25162. return ok
  25163. }
  25164. // ResetToken resets all changes to the "token" field.
  25165. func (m *TokenMutation) ResetToken() {
  25166. m.token = nil
  25167. delete(m.clearedFields, token.FieldToken)
  25168. }
  25169. // SetMAC sets the "mac" field.
  25170. func (m *TokenMutation) SetMAC(s string) {
  25171. m.mac = &s
  25172. }
  25173. // MAC returns the value of the "mac" field in the mutation.
  25174. func (m *TokenMutation) MAC() (r string, exists bool) {
  25175. v := m.mac
  25176. if v == nil {
  25177. return
  25178. }
  25179. return *v, true
  25180. }
  25181. // OldMAC returns the old "mac" field's value of the Token entity.
  25182. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25184. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25185. if !m.op.Is(OpUpdateOne) {
  25186. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25187. }
  25188. if m.id == nil || m.oldValue == nil {
  25189. return v, errors.New("OldMAC requires an ID field in the mutation")
  25190. }
  25191. oldValue, err := m.oldValue(ctx)
  25192. if err != nil {
  25193. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25194. }
  25195. return oldValue.MAC, nil
  25196. }
  25197. // ClearMAC clears the value of the "mac" field.
  25198. func (m *TokenMutation) ClearMAC() {
  25199. m.mac = nil
  25200. m.clearedFields[token.FieldMAC] = struct{}{}
  25201. }
  25202. // MACCleared returns if the "mac" field was cleared in this mutation.
  25203. func (m *TokenMutation) MACCleared() bool {
  25204. _, ok := m.clearedFields[token.FieldMAC]
  25205. return ok
  25206. }
  25207. // ResetMAC resets all changes to the "mac" field.
  25208. func (m *TokenMutation) ResetMAC() {
  25209. m.mac = nil
  25210. delete(m.clearedFields, token.FieldMAC)
  25211. }
  25212. // SetOrganizationID sets the "organization_id" field.
  25213. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25214. m.organization_id = &u
  25215. m.addorganization_id = nil
  25216. }
  25217. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25218. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25219. v := m.organization_id
  25220. if v == nil {
  25221. return
  25222. }
  25223. return *v, true
  25224. }
  25225. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25226. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25228. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25229. if !m.op.Is(OpUpdateOne) {
  25230. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25231. }
  25232. if m.id == nil || m.oldValue == nil {
  25233. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25234. }
  25235. oldValue, err := m.oldValue(ctx)
  25236. if err != nil {
  25237. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25238. }
  25239. return oldValue.OrganizationID, nil
  25240. }
  25241. // AddOrganizationID adds u to the "organization_id" field.
  25242. func (m *TokenMutation) AddOrganizationID(u int64) {
  25243. if m.addorganization_id != nil {
  25244. *m.addorganization_id += u
  25245. } else {
  25246. m.addorganization_id = &u
  25247. }
  25248. }
  25249. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25250. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25251. v := m.addorganization_id
  25252. if v == nil {
  25253. return
  25254. }
  25255. return *v, true
  25256. }
  25257. // ResetOrganizationID resets all changes to the "organization_id" field.
  25258. func (m *TokenMutation) ResetOrganizationID() {
  25259. m.organization_id = nil
  25260. m.addorganization_id = nil
  25261. }
  25262. // SetAgentID sets the "agent_id" field.
  25263. func (m *TokenMutation) SetAgentID(u uint64) {
  25264. m.agent = &u
  25265. }
  25266. // AgentID returns the value of the "agent_id" field in the mutation.
  25267. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25268. v := m.agent
  25269. if v == nil {
  25270. return
  25271. }
  25272. return *v, true
  25273. }
  25274. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25275. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25277. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25278. if !m.op.Is(OpUpdateOne) {
  25279. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25280. }
  25281. if m.id == nil || m.oldValue == nil {
  25282. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25283. }
  25284. oldValue, err := m.oldValue(ctx)
  25285. if err != nil {
  25286. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25287. }
  25288. return oldValue.AgentID, nil
  25289. }
  25290. // ResetAgentID resets all changes to the "agent_id" field.
  25291. func (m *TokenMutation) ResetAgentID() {
  25292. m.agent = nil
  25293. }
  25294. // SetCustomAgentBase sets the "custom_agent_base" field.
  25295. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25296. m.custom_agent_base = &s
  25297. }
  25298. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25299. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25300. v := m.custom_agent_base
  25301. if v == nil {
  25302. return
  25303. }
  25304. return *v, true
  25305. }
  25306. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25307. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25309. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25310. if !m.op.Is(OpUpdateOne) {
  25311. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25312. }
  25313. if m.id == nil || m.oldValue == nil {
  25314. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25315. }
  25316. oldValue, err := m.oldValue(ctx)
  25317. if err != nil {
  25318. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25319. }
  25320. return oldValue.CustomAgentBase, nil
  25321. }
  25322. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25323. func (m *TokenMutation) ClearCustomAgentBase() {
  25324. m.custom_agent_base = nil
  25325. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25326. }
  25327. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25328. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25329. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25330. return ok
  25331. }
  25332. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25333. func (m *TokenMutation) ResetCustomAgentBase() {
  25334. m.custom_agent_base = nil
  25335. delete(m.clearedFields, token.FieldCustomAgentBase)
  25336. }
  25337. // SetCustomAgentKey sets the "custom_agent_key" field.
  25338. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25339. m.custom_agent_key = &s
  25340. }
  25341. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25342. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25343. v := m.custom_agent_key
  25344. if v == nil {
  25345. return
  25346. }
  25347. return *v, true
  25348. }
  25349. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25350. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25352. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25353. if !m.op.Is(OpUpdateOne) {
  25354. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25355. }
  25356. if m.id == nil || m.oldValue == nil {
  25357. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25358. }
  25359. oldValue, err := m.oldValue(ctx)
  25360. if err != nil {
  25361. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25362. }
  25363. return oldValue.CustomAgentKey, nil
  25364. }
  25365. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25366. func (m *TokenMutation) ClearCustomAgentKey() {
  25367. m.custom_agent_key = nil
  25368. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25369. }
  25370. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25371. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25372. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25373. return ok
  25374. }
  25375. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25376. func (m *TokenMutation) ResetCustomAgentKey() {
  25377. m.custom_agent_key = nil
  25378. delete(m.clearedFields, token.FieldCustomAgentKey)
  25379. }
  25380. // SetOpenaiBase sets the "openai_base" field.
  25381. func (m *TokenMutation) SetOpenaiBase(s string) {
  25382. m.openai_base = &s
  25383. }
  25384. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25385. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25386. v := m.openai_base
  25387. if v == nil {
  25388. return
  25389. }
  25390. return *v, true
  25391. }
  25392. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25393. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25395. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25396. if !m.op.Is(OpUpdateOne) {
  25397. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25398. }
  25399. if m.id == nil || m.oldValue == nil {
  25400. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25401. }
  25402. oldValue, err := m.oldValue(ctx)
  25403. if err != nil {
  25404. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25405. }
  25406. return oldValue.OpenaiBase, nil
  25407. }
  25408. // ClearOpenaiBase clears the value of the "openai_base" field.
  25409. func (m *TokenMutation) ClearOpenaiBase() {
  25410. m.openai_base = nil
  25411. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25412. }
  25413. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25414. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25415. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25416. return ok
  25417. }
  25418. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25419. func (m *TokenMutation) ResetOpenaiBase() {
  25420. m.openai_base = nil
  25421. delete(m.clearedFields, token.FieldOpenaiBase)
  25422. }
  25423. // SetOpenaiKey sets the "openai_key" field.
  25424. func (m *TokenMutation) SetOpenaiKey(s string) {
  25425. m.openai_key = &s
  25426. }
  25427. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25428. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25429. v := m.openai_key
  25430. if v == nil {
  25431. return
  25432. }
  25433. return *v, true
  25434. }
  25435. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25436. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25438. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25439. if !m.op.Is(OpUpdateOne) {
  25440. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25441. }
  25442. if m.id == nil || m.oldValue == nil {
  25443. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25444. }
  25445. oldValue, err := m.oldValue(ctx)
  25446. if err != nil {
  25447. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25448. }
  25449. return oldValue.OpenaiKey, nil
  25450. }
  25451. // ClearOpenaiKey clears the value of the "openai_key" field.
  25452. func (m *TokenMutation) ClearOpenaiKey() {
  25453. m.openai_key = nil
  25454. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25455. }
  25456. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25457. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25458. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25459. return ok
  25460. }
  25461. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25462. func (m *TokenMutation) ResetOpenaiKey() {
  25463. m.openai_key = nil
  25464. delete(m.clearedFields, token.FieldOpenaiKey)
  25465. }
  25466. // ClearAgent clears the "agent" edge to the Agent entity.
  25467. func (m *TokenMutation) ClearAgent() {
  25468. m.clearedagent = true
  25469. m.clearedFields[token.FieldAgentID] = struct{}{}
  25470. }
  25471. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25472. func (m *TokenMutation) AgentCleared() bool {
  25473. return m.clearedagent
  25474. }
  25475. // AgentIDs returns the "agent" edge IDs in the mutation.
  25476. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25477. // AgentID instead. It exists only for internal usage by the builders.
  25478. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25479. if id := m.agent; id != nil {
  25480. ids = append(ids, *id)
  25481. }
  25482. return
  25483. }
  25484. // ResetAgent resets all changes to the "agent" edge.
  25485. func (m *TokenMutation) ResetAgent() {
  25486. m.agent = nil
  25487. m.clearedagent = false
  25488. }
  25489. // Where appends a list predicates to the TokenMutation builder.
  25490. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25491. m.predicates = append(m.predicates, ps...)
  25492. }
  25493. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25494. // users can use type-assertion to append predicates that do not depend on any generated package.
  25495. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25496. p := make([]predicate.Token, len(ps))
  25497. for i := range ps {
  25498. p[i] = ps[i]
  25499. }
  25500. m.Where(p...)
  25501. }
  25502. // Op returns the operation name.
  25503. func (m *TokenMutation) Op() Op {
  25504. return m.op
  25505. }
  25506. // SetOp allows setting the mutation operation.
  25507. func (m *TokenMutation) SetOp(op Op) {
  25508. m.op = op
  25509. }
  25510. // Type returns the node type of this mutation (Token).
  25511. func (m *TokenMutation) Type() string {
  25512. return m.typ
  25513. }
  25514. // Fields returns all fields that were changed during this mutation. Note that in
  25515. // order to get all numeric fields that were incremented/decremented, call
  25516. // AddedFields().
  25517. func (m *TokenMutation) Fields() []string {
  25518. fields := make([]string, 0, 12)
  25519. if m.created_at != nil {
  25520. fields = append(fields, token.FieldCreatedAt)
  25521. }
  25522. if m.updated_at != nil {
  25523. fields = append(fields, token.FieldUpdatedAt)
  25524. }
  25525. if m.deleted_at != nil {
  25526. fields = append(fields, token.FieldDeletedAt)
  25527. }
  25528. if m.expire_at != nil {
  25529. fields = append(fields, token.FieldExpireAt)
  25530. }
  25531. if m.token != nil {
  25532. fields = append(fields, token.FieldToken)
  25533. }
  25534. if m.mac != nil {
  25535. fields = append(fields, token.FieldMAC)
  25536. }
  25537. if m.organization_id != nil {
  25538. fields = append(fields, token.FieldOrganizationID)
  25539. }
  25540. if m.agent != nil {
  25541. fields = append(fields, token.FieldAgentID)
  25542. }
  25543. if m.custom_agent_base != nil {
  25544. fields = append(fields, token.FieldCustomAgentBase)
  25545. }
  25546. if m.custom_agent_key != nil {
  25547. fields = append(fields, token.FieldCustomAgentKey)
  25548. }
  25549. if m.openai_base != nil {
  25550. fields = append(fields, token.FieldOpenaiBase)
  25551. }
  25552. if m.openai_key != nil {
  25553. fields = append(fields, token.FieldOpenaiKey)
  25554. }
  25555. return fields
  25556. }
  25557. // Field returns the value of a field with the given name. The second boolean
  25558. // return value indicates that this field was not set, or was not defined in the
  25559. // schema.
  25560. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25561. switch name {
  25562. case token.FieldCreatedAt:
  25563. return m.CreatedAt()
  25564. case token.FieldUpdatedAt:
  25565. return m.UpdatedAt()
  25566. case token.FieldDeletedAt:
  25567. return m.DeletedAt()
  25568. case token.FieldExpireAt:
  25569. return m.ExpireAt()
  25570. case token.FieldToken:
  25571. return m.Token()
  25572. case token.FieldMAC:
  25573. return m.MAC()
  25574. case token.FieldOrganizationID:
  25575. return m.OrganizationID()
  25576. case token.FieldAgentID:
  25577. return m.AgentID()
  25578. case token.FieldCustomAgentBase:
  25579. return m.CustomAgentBase()
  25580. case token.FieldCustomAgentKey:
  25581. return m.CustomAgentKey()
  25582. case token.FieldOpenaiBase:
  25583. return m.OpenaiBase()
  25584. case token.FieldOpenaiKey:
  25585. return m.OpenaiKey()
  25586. }
  25587. return nil, false
  25588. }
  25589. // OldField returns the old value of the field from the database. An error is
  25590. // returned if the mutation operation is not UpdateOne, or the query to the
  25591. // database failed.
  25592. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25593. switch name {
  25594. case token.FieldCreatedAt:
  25595. return m.OldCreatedAt(ctx)
  25596. case token.FieldUpdatedAt:
  25597. return m.OldUpdatedAt(ctx)
  25598. case token.FieldDeletedAt:
  25599. return m.OldDeletedAt(ctx)
  25600. case token.FieldExpireAt:
  25601. return m.OldExpireAt(ctx)
  25602. case token.FieldToken:
  25603. return m.OldToken(ctx)
  25604. case token.FieldMAC:
  25605. return m.OldMAC(ctx)
  25606. case token.FieldOrganizationID:
  25607. return m.OldOrganizationID(ctx)
  25608. case token.FieldAgentID:
  25609. return m.OldAgentID(ctx)
  25610. case token.FieldCustomAgentBase:
  25611. return m.OldCustomAgentBase(ctx)
  25612. case token.FieldCustomAgentKey:
  25613. return m.OldCustomAgentKey(ctx)
  25614. case token.FieldOpenaiBase:
  25615. return m.OldOpenaiBase(ctx)
  25616. case token.FieldOpenaiKey:
  25617. return m.OldOpenaiKey(ctx)
  25618. }
  25619. return nil, fmt.Errorf("unknown Token field %s", name)
  25620. }
  25621. // SetField sets the value of a field with the given name. It returns an error if
  25622. // the field is not defined in the schema, or if the type mismatched the field
  25623. // type.
  25624. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25625. switch name {
  25626. case token.FieldCreatedAt:
  25627. v, ok := value.(time.Time)
  25628. if !ok {
  25629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25630. }
  25631. m.SetCreatedAt(v)
  25632. return nil
  25633. case token.FieldUpdatedAt:
  25634. v, ok := value.(time.Time)
  25635. if !ok {
  25636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25637. }
  25638. m.SetUpdatedAt(v)
  25639. return nil
  25640. case token.FieldDeletedAt:
  25641. v, ok := value.(time.Time)
  25642. if !ok {
  25643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25644. }
  25645. m.SetDeletedAt(v)
  25646. return nil
  25647. case token.FieldExpireAt:
  25648. v, ok := value.(time.Time)
  25649. if !ok {
  25650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25651. }
  25652. m.SetExpireAt(v)
  25653. return nil
  25654. case token.FieldToken:
  25655. v, ok := value.(string)
  25656. if !ok {
  25657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25658. }
  25659. m.SetToken(v)
  25660. return nil
  25661. case token.FieldMAC:
  25662. v, ok := value.(string)
  25663. if !ok {
  25664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25665. }
  25666. m.SetMAC(v)
  25667. return nil
  25668. case token.FieldOrganizationID:
  25669. v, ok := value.(uint64)
  25670. if !ok {
  25671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25672. }
  25673. m.SetOrganizationID(v)
  25674. return nil
  25675. case token.FieldAgentID:
  25676. v, ok := value.(uint64)
  25677. if !ok {
  25678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25679. }
  25680. m.SetAgentID(v)
  25681. return nil
  25682. case token.FieldCustomAgentBase:
  25683. v, ok := value.(string)
  25684. if !ok {
  25685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25686. }
  25687. m.SetCustomAgentBase(v)
  25688. return nil
  25689. case token.FieldCustomAgentKey:
  25690. v, ok := value.(string)
  25691. if !ok {
  25692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25693. }
  25694. m.SetCustomAgentKey(v)
  25695. return nil
  25696. case token.FieldOpenaiBase:
  25697. v, ok := value.(string)
  25698. if !ok {
  25699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25700. }
  25701. m.SetOpenaiBase(v)
  25702. return nil
  25703. case token.FieldOpenaiKey:
  25704. v, ok := value.(string)
  25705. if !ok {
  25706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25707. }
  25708. m.SetOpenaiKey(v)
  25709. return nil
  25710. }
  25711. return fmt.Errorf("unknown Token field %s", name)
  25712. }
  25713. // AddedFields returns all numeric fields that were incremented/decremented during
  25714. // this mutation.
  25715. func (m *TokenMutation) AddedFields() []string {
  25716. var fields []string
  25717. if m.addorganization_id != nil {
  25718. fields = append(fields, token.FieldOrganizationID)
  25719. }
  25720. return fields
  25721. }
  25722. // AddedField returns the numeric value that was incremented/decremented on a field
  25723. // with the given name. The second boolean return value indicates that this field
  25724. // was not set, or was not defined in the schema.
  25725. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25726. switch name {
  25727. case token.FieldOrganizationID:
  25728. return m.AddedOrganizationID()
  25729. }
  25730. return nil, false
  25731. }
  25732. // AddField adds the value to the field with the given name. It returns an error if
  25733. // the field is not defined in the schema, or if the type mismatched the field
  25734. // type.
  25735. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25736. switch name {
  25737. case token.FieldOrganizationID:
  25738. v, ok := value.(int64)
  25739. if !ok {
  25740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25741. }
  25742. m.AddOrganizationID(v)
  25743. return nil
  25744. }
  25745. return fmt.Errorf("unknown Token numeric field %s", name)
  25746. }
  25747. // ClearedFields returns all nullable fields that were cleared during this
  25748. // mutation.
  25749. func (m *TokenMutation) ClearedFields() []string {
  25750. var fields []string
  25751. if m.FieldCleared(token.FieldDeletedAt) {
  25752. fields = append(fields, token.FieldDeletedAt)
  25753. }
  25754. if m.FieldCleared(token.FieldExpireAt) {
  25755. fields = append(fields, token.FieldExpireAt)
  25756. }
  25757. if m.FieldCleared(token.FieldToken) {
  25758. fields = append(fields, token.FieldToken)
  25759. }
  25760. if m.FieldCleared(token.FieldMAC) {
  25761. fields = append(fields, token.FieldMAC)
  25762. }
  25763. if m.FieldCleared(token.FieldCustomAgentBase) {
  25764. fields = append(fields, token.FieldCustomAgentBase)
  25765. }
  25766. if m.FieldCleared(token.FieldCustomAgentKey) {
  25767. fields = append(fields, token.FieldCustomAgentKey)
  25768. }
  25769. if m.FieldCleared(token.FieldOpenaiBase) {
  25770. fields = append(fields, token.FieldOpenaiBase)
  25771. }
  25772. if m.FieldCleared(token.FieldOpenaiKey) {
  25773. fields = append(fields, token.FieldOpenaiKey)
  25774. }
  25775. return fields
  25776. }
  25777. // FieldCleared returns a boolean indicating if a field with the given name was
  25778. // cleared in this mutation.
  25779. func (m *TokenMutation) FieldCleared(name string) bool {
  25780. _, ok := m.clearedFields[name]
  25781. return ok
  25782. }
  25783. // ClearField clears the value of the field with the given name. It returns an
  25784. // error if the field is not defined in the schema.
  25785. func (m *TokenMutation) ClearField(name string) error {
  25786. switch name {
  25787. case token.FieldDeletedAt:
  25788. m.ClearDeletedAt()
  25789. return nil
  25790. case token.FieldExpireAt:
  25791. m.ClearExpireAt()
  25792. return nil
  25793. case token.FieldToken:
  25794. m.ClearToken()
  25795. return nil
  25796. case token.FieldMAC:
  25797. m.ClearMAC()
  25798. return nil
  25799. case token.FieldCustomAgentBase:
  25800. m.ClearCustomAgentBase()
  25801. return nil
  25802. case token.FieldCustomAgentKey:
  25803. m.ClearCustomAgentKey()
  25804. return nil
  25805. case token.FieldOpenaiBase:
  25806. m.ClearOpenaiBase()
  25807. return nil
  25808. case token.FieldOpenaiKey:
  25809. m.ClearOpenaiKey()
  25810. return nil
  25811. }
  25812. return fmt.Errorf("unknown Token nullable field %s", name)
  25813. }
  25814. // ResetField resets all changes in the mutation for the field with the given name.
  25815. // It returns an error if the field is not defined in the schema.
  25816. func (m *TokenMutation) ResetField(name string) error {
  25817. switch name {
  25818. case token.FieldCreatedAt:
  25819. m.ResetCreatedAt()
  25820. return nil
  25821. case token.FieldUpdatedAt:
  25822. m.ResetUpdatedAt()
  25823. return nil
  25824. case token.FieldDeletedAt:
  25825. m.ResetDeletedAt()
  25826. return nil
  25827. case token.FieldExpireAt:
  25828. m.ResetExpireAt()
  25829. return nil
  25830. case token.FieldToken:
  25831. m.ResetToken()
  25832. return nil
  25833. case token.FieldMAC:
  25834. m.ResetMAC()
  25835. return nil
  25836. case token.FieldOrganizationID:
  25837. m.ResetOrganizationID()
  25838. return nil
  25839. case token.FieldAgentID:
  25840. m.ResetAgentID()
  25841. return nil
  25842. case token.FieldCustomAgentBase:
  25843. m.ResetCustomAgentBase()
  25844. return nil
  25845. case token.FieldCustomAgentKey:
  25846. m.ResetCustomAgentKey()
  25847. return nil
  25848. case token.FieldOpenaiBase:
  25849. m.ResetOpenaiBase()
  25850. return nil
  25851. case token.FieldOpenaiKey:
  25852. m.ResetOpenaiKey()
  25853. return nil
  25854. }
  25855. return fmt.Errorf("unknown Token field %s", name)
  25856. }
  25857. // AddedEdges returns all edge names that were set/added in this mutation.
  25858. func (m *TokenMutation) AddedEdges() []string {
  25859. edges := make([]string, 0, 1)
  25860. if m.agent != nil {
  25861. edges = append(edges, token.EdgeAgent)
  25862. }
  25863. return edges
  25864. }
  25865. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25866. // name in this mutation.
  25867. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25868. switch name {
  25869. case token.EdgeAgent:
  25870. if id := m.agent; id != nil {
  25871. return []ent.Value{*id}
  25872. }
  25873. }
  25874. return nil
  25875. }
  25876. // RemovedEdges returns all edge names that were removed in this mutation.
  25877. func (m *TokenMutation) RemovedEdges() []string {
  25878. edges := make([]string, 0, 1)
  25879. return edges
  25880. }
  25881. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25882. // the given name in this mutation.
  25883. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25884. return nil
  25885. }
  25886. // ClearedEdges returns all edge names that were cleared in this mutation.
  25887. func (m *TokenMutation) ClearedEdges() []string {
  25888. edges := make([]string, 0, 1)
  25889. if m.clearedagent {
  25890. edges = append(edges, token.EdgeAgent)
  25891. }
  25892. return edges
  25893. }
  25894. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25895. // was cleared in this mutation.
  25896. func (m *TokenMutation) EdgeCleared(name string) bool {
  25897. switch name {
  25898. case token.EdgeAgent:
  25899. return m.clearedagent
  25900. }
  25901. return false
  25902. }
  25903. // ClearEdge clears the value of the edge with the given name. It returns an error
  25904. // if that edge is not defined in the schema.
  25905. func (m *TokenMutation) ClearEdge(name string) error {
  25906. switch name {
  25907. case token.EdgeAgent:
  25908. m.ClearAgent()
  25909. return nil
  25910. }
  25911. return fmt.Errorf("unknown Token unique edge %s", name)
  25912. }
  25913. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25914. // It returns an error if the edge is not defined in the schema.
  25915. func (m *TokenMutation) ResetEdge(name string) error {
  25916. switch name {
  25917. case token.EdgeAgent:
  25918. m.ResetAgent()
  25919. return nil
  25920. }
  25921. return fmt.Errorf("unknown Token edge %s", name)
  25922. }
  25923. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25924. type TutorialMutation struct {
  25925. config
  25926. op Op
  25927. typ string
  25928. id *uint64
  25929. created_at *time.Time
  25930. updated_at *time.Time
  25931. deleted_at *time.Time
  25932. index *int
  25933. addindex *int
  25934. title *string
  25935. content *string
  25936. organization_id *uint64
  25937. addorganization_id *int64
  25938. clearedFields map[string]struct{}
  25939. employee *uint64
  25940. clearedemployee bool
  25941. done bool
  25942. oldValue func(context.Context) (*Tutorial, error)
  25943. predicates []predicate.Tutorial
  25944. }
  25945. var _ ent.Mutation = (*TutorialMutation)(nil)
  25946. // tutorialOption allows management of the mutation configuration using functional options.
  25947. type tutorialOption func(*TutorialMutation)
  25948. // newTutorialMutation creates new mutation for the Tutorial entity.
  25949. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25950. m := &TutorialMutation{
  25951. config: c,
  25952. op: op,
  25953. typ: TypeTutorial,
  25954. clearedFields: make(map[string]struct{}),
  25955. }
  25956. for _, opt := range opts {
  25957. opt(m)
  25958. }
  25959. return m
  25960. }
  25961. // withTutorialID sets the ID field of the mutation.
  25962. func withTutorialID(id uint64) tutorialOption {
  25963. return func(m *TutorialMutation) {
  25964. var (
  25965. err error
  25966. once sync.Once
  25967. value *Tutorial
  25968. )
  25969. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25970. once.Do(func() {
  25971. if m.done {
  25972. err = errors.New("querying old values post mutation is not allowed")
  25973. } else {
  25974. value, err = m.Client().Tutorial.Get(ctx, id)
  25975. }
  25976. })
  25977. return value, err
  25978. }
  25979. m.id = &id
  25980. }
  25981. }
  25982. // withTutorial sets the old Tutorial of the mutation.
  25983. func withTutorial(node *Tutorial) tutorialOption {
  25984. return func(m *TutorialMutation) {
  25985. m.oldValue = func(context.Context) (*Tutorial, error) {
  25986. return node, nil
  25987. }
  25988. m.id = &node.ID
  25989. }
  25990. }
  25991. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25992. // executed in a transaction (ent.Tx), a transactional client is returned.
  25993. func (m TutorialMutation) Client() *Client {
  25994. client := &Client{config: m.config}
  25995. client.init()
  25996. return client
  25997. }
  25998. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25999. // it returns an error otherwise.
  26000. func (m TutorialMutation) Tx() (*Tx, error) {
  26001. if _, ok := m.driver.(*txDriver); !ok {
  26002. return nil, errors.New("ent: mutation is not running in a transaction")
  26003. }
  26004. tx := &Tx{config: m.config}
  26005. tx.init()
  26006. return tx, nil
  26007. }
  26008. // SetID sets the value of the id field. Note that this
  26009. // operation is only accepted on creation of Tutorial entities.
  26010. func (m *TutorialMutation) SetID(id uint64) {
  26011. m.id = &id
  26012. }
  26013. // ID returns the ID value in the mutation. Note that the ID is only available
  26014. // if it was provided to the builder or after it was returned from the database.
  26015. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  26016. if m.id == nil {
  26017. return
  26018. }
  26019. return *m.id, true
  26020. }
  26021. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26022. // That means, if the mutation is applied within a transaction with an isolation level such
  26023. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26024. // or updated by the mutation.
  26025. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  26026. switch {
  26027. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26028. id, exists := m.ID()
  26029. if exists {
  26030. return []uint64{id}, nil
  26031. }
  26032. fallthrough
  26033. case m.op.Is(OpUpdate | OpDelete):
  26034. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  26035. default:
  26036. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26037. }
  26038. }
  26039. // SetCreatedAt sets the "created_at" field.
  26040. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26041. m.created_at = &t
  26042. }
  26043. // CreatedAt returns the value of the "created_at" field in the mutation.
  26044. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26045. v := m.created_at
  26046. if v == nil {
  26047. return
  26048. }
  26049. return *v, true
  26050. }
  26051. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26052. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26054. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26055. if !m.op.Is(OpUpdateOne) {
  26056. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26057. }
  26058. if m.id == nil || m.oldValue == nil {
  26059. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26060. }
  26061. oldValue, err := m.oldValue(ctx)
  26062. if err != nil {
  26063. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26064. }
  26065. return oldValue.CreatedAt, nil
  26066. }
  26067. // ResetCreatedAt resets all changes to the "created_at" field.
  26068. func (m *TutorialMutation) ResetCreatedAt() {
  26069. m.created_at = nil
  26070. }
  26071. // SetUpdatedAt sets the "updated_at" field.
  26072. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26073. m.updated_at = &t
  26074. }
  26075. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26076. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26077. v := m.updated_at
  26078. if v == nil {
  26079. return
  26080. }
  26081. return *v, true
  26082. }
  26083. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26084. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26086. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26087. if !m.op.Is(OpUpdateOne) {
  26088. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26089. }
  26090. if m.id == nil || m.oldValue == nil {
  26091. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26092. }
  26093. oldValue, err := m.oldValue(ctx)
  26094. if err != nil {
  26095. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26096. }
  26097. return oldValue.UpdatedAt, nil
  26098. }
  26099. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26100. func (m *TutorialMutation) ResetUpdatedAt() {
  26101. m.updated_at = nil
  26102. }
  26103. // SetDeletedAt sets the "deleted_at" field.
  26104. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26105. m.deleted_at = &t
  26106. }
  26107. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26108. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26109. v := m.deleted_at
  26110. if v == nil {
  26111. return
  26112. }
  26113. return *v, true
  26114. }
  26115. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26116. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26118. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26119. if !m.op.Is(OpUpdateOne) {
  26120. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26121. }
  26122. if m.id == nil || m.oldValue == nil {
  26123. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26124. }
  26125. oldValue, err := m.oldValue(ctx)
  26126. if err != nil {
  26127. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26128. }
  26129. return oldValue.DeletedAt, nil
  26130. }
  26131. // ClearDeletedAt clears the value of the "deleted_at" field.
  26132. func (m *TutorialMutation) ClearDeletedAt() {
  26133. m.deleted_at = nil
  26134. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26135. }
  26136. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26137. func (m *TutorialMutation) DeletedAtCleared() bool {
  26138. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26139. return ok
  26140. }
  26141. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26142. func (m *TutorialMutation) ResetDeletedAt() {
  26143. m.deleted_at = nil
  26144. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26145. }
  26146. // SetEmployeeID sets the "employee_id" field.
  26147. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26148. m.employee = &u
  26149. }
  26150. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26151. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26152. v := m.employee
  26153. if v == nil {
  26154. return
  26155. }
  26156. return *v, true
  26157. }
  26158. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26159. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26161. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26162. if !m.op.Is(OpUpdateOne) {
  26163. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26164. }
  26165. if m.id == nil || m.oldValue == nil {
  26166. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26167. }
  26168. oldValue, err := m.oldValue(ctx)
  26169. if err != nil {
  26170. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26171. }
  26172. return oldValue.EmployeeID, nil
  26173. }
  26174. // ResetEmployeeID resets all changes to the "employee_id" field.
  26175. func (m *TutorialMutation) ResetEmployeeID() {
  26176. m.employee = nil
  26177. }
  26178. // SetIndex sets the "index" field.
  26179. func (m *TutorialMutation) SetIndex(i int) {
  26180. m.index = &i
  26181. m.addindex = nil
  26182. }
  26183. // Index returns the value of the "index" field in the mutation.
  26184. func (m *TutorialMutation) Index() (r int, exists bool) {
  26185. v := m.index
  26186. if v == nil {
  26187. return
  26188. }
  26189. return *v, true
  26190. }
  26191. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26192. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26194. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26195. if !m.op.Is(OpUpdateOne) {
  26196. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26197. }
  26198. if m.id == nil || m.oldValue == nil {
  26199. return v, errors.New("OldIndex requires an ID field in the mutation")
  26200. }
  26201. oldValue, err := m.oldValue(ctx)
  26202. if err != nil {
  26203. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26204. }
  26205. return oldValue.Index, nil
  26206. }
  26207. // AddIndex adds i to the "index" field.
  26208. func (m *TutorialMutation) AddIndex(i int) {
  26209. if m.addindex != nil {
  26210. *m.addindex += i
  26211. } else {
  26212. m.addindex = &i
  26213. }
  26214. }
  26215. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26216. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26217. v := m.addindex
  26218. if v == nil {
  26219. return
  26220. }
  26221. return *v, true
  26222. }
  26223. // ResetIndex resets all changes to the "index" field.
  26224. func (m *TutorialMutation) ResetIndex() {
  26225. m.index = nil
  26226. m.addindex = nil
  26227. }
  26228. // SetTitle sets the "title" field.
  26229. func (m *TutorialMutation) SetTitle(s string) {
  26230. m.title = &s
  26231. }
  26232. // Title returns the value of the "title" field in the mutation.
  26233. func (m *TutorialMutation) Title() (r string, exists bool) {
  26234. v := m.title
  26235. if v == nil {
  26236. return
  26237. }
  26238. return *v, true
  26239. }
  26240. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26241. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26243. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26244. if !m.op.Is(OpUpdateOne) {
  26245. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26246. }
  26247. if m.id == nil || m.oldValue == nil {
  26248. return v, errors.New("OldTitle requires an ID field in the mutation")
  26249. }
  26250. oldValue, err := m.oldValue(ctx)
  26251. if err != nil {
  26252. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26253. }
  26254. return oldValue.Title, nil
  26255. }
  26256. // ResetTitle resets all changes to the "title" field.
  26257. func (m *TutorialMutation) ResetTitle() {
  26258. m.title = nil
  26259. }
  26260. // SetContent sets the "content" field.
  26261. func (m *TutorialMutation) SetContent(s string) {
  26262. m.content = &s
  26263. }
  26264. // Content returns the value of the "content" field in the mutation.
  26265. func (m *TutorialMutation) Content() (r string, exists bool) {
  26266. v := m.content
  26267. if v == nil {
  26268. return
  26269. }
  26270. return *v, true
  26271. }
  26272. // OldContent returns the old "content" field's value of the Tutorial entity.
  26273. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26275. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26276. if !m.op.Is(OpUpdateOne) {
  26277. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26278. }
  26279. if m.id == nil || m.oldValue == nil {
  26280. return v, errors.New("OldContent requires an ID field in the mutation")
  26281. }
  26282. oldValue, err := m.oldValue(ctx)
  26283. if err != nil {
  26284. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26285. }
  26286. return oldValue.Content, nil
  26287. }
  26288. // ResetContent resets all changes to the "content" field.
  26289. func (m *TutorialMutation) ResetContent() {
  26290. m.content = nil
  26291. }
  26292. // SetOrganizationID sets the "organization_id" field.
  26293. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26294. m.organization_id = &u
  26295. m.addorganization_id = nil
  26296. }
  26297. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26298. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26299. v := m.organization_id
  26300. if v == nil {
  26301. return
  26302. }
  26303. return *v, true
  26304. }
  26305. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26306. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26308. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26309. if !m.op.Is(OpUpdateOne) {
  26310. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26311. }
  26312. if m.id == nil || m.oldValue == nil {
  26313. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26314. }
  26315. oldValue, err := m.oldValue(ctx)
  26316. if err != nil {
  26317. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26318. }
  26319. return oldValue.OrganizationID, nil
  26320. }
  26321. // AddOrganizationID adds u to the "organization_id" field.
  26322. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26323. if m.addorganization_id != nil {
  26324. *m.addorganization_id += u
  26325. } else {
  26326. m.addorganization_id = &u
  26327. }
  26328. }
  26329. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26330. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26331. v := m.addorganization_id
  26332. if v == nil {
  26333. return
  26334. }
  26335. return *v, true
  26336. }
  26337. // ResetOrganizationID resets all changes to the "organization_id" field.
  26338. func (m *TutorialMutation) ResetOrganizationID() {
  26339. m.organization_id = nil
  26340. m.addorganization_id = nil
  26341. }
  26342. // ClearEmployee clears the "employee" edge to the Employee entity.
  26343. func (m *TutorialMutation) ClearEmployee() {
  26344. m.clearedemployee = true
  26345. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26346. }
  26347. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26348. func (m *TutorialMutation) EmployeeCleared() bool {
  26349. return m.clearedemployee
  26350. }
  26351. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26352. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26353. // EmployeeID instead. It exists only for internal usage by the builders.
  26354. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26355. if id := m.employee; id != nil {
  26356. ids = append(ids, *id)
  26357. }
  26358. return
  26359. }
  26360. // ResetEmployee resets all changes to the "employee" edge.
  26361. func (m *TutorialMutation) ResetEmployee() {
  26362. m.employee = nil
  26363. m.clearedemployee = false
  26364. }
  26365. // Where appends a list predicates to the TutorialMutation builder.
  26366. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26367. m.predicates = append(m.predicates, ps...)
  26368. }
  26369. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26370. // users can use type-assertion to append predicates that do not depend on any generated package.
  26371. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26372. p := make([]predicate.Tutorial, len(ps))
  26373. for i := range ps {
  26374. p[i] = ps[i]
  26375. }
  26376. m.Where(p...)
  26377. }
  26378. // Op returns the operation name.
  26379. func (m *TutorialMutation) Op() Op {
  26380. return m.op
  26381. }
  26382. // SetOp allows setting the mutation operation.
  26383. func (m *TutorialMutation) SetOp(op Op) {
  26384. m.op = op
  26385. }
  26386. // Type returns the node type of this mutation (Tutorial).
  26387. func (m *TutorialMutation) Type() string {
  26388. return m.typ
  26389. }
  26390. // Fields returns all fields that were changed during this mutation. Note that in
  26391. // order to get all numeric fields that were incremented/decremented, call
  26392. // AddedFields().
  26393. func (m *TutorialMutation) Fields() []string {
  26394. fields := make([]string, 0, 8)
  26395. if m.created_at != nil {
  26396. fields = append(fields, tutorial.FieldCreatedAt)
  26397. }
  26398. if m.updated_at != nil {
  26399. fields = append(fields, tutorial.FieldUpdatedAt)
  26400. }
  26401. if m.deleted_at != nil {
  26402. fields = append(fields, tutorial.FieldDeletedAt)
  26403. }
  26404. if m.employee != nil {
  26405. fields = append(fields, tutorial.FieldEmployeeID)
  26406. }
  26407. if m.index != nil {
  26408. fields = append(fields, tutorial.FieldIndex)
  26409. }
  26410. if m.title != nil {
  26411. fields = append(fields, tutorial.FieldTitle)
  26412. }
  26413. if m.content != nil {
  26414. fields = append(fields, tutorial.FieldContent)
  26415. }
  26416. if m.organization_id != nil {
  26417. fields = append(fields, tutorial.FieldOrganizationID)
  26418. }
  26419. return fields
  26420. }
  26421. // Field returns the value of a field with the given name. The second boolean
  26422. // return value indicates that this field was not set, or was not defined in the
  26423. // schema.
  26424. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26425. switch name {
  26426. case tutorial.FieldCreatedAt:
  26427. return m.CreatedAt()
  26428. case tutorial.FieldUpdatedAt:
  26429. return m.UpdatedAt()
  26430. case tutorial.FieldDeletedAt:
  26431. return m.DeletedAt()
  26432. case tutorial.FieldEmployeeID:
  26433. return m.EmployeeID()
  26434. case tutorial.FieldIndex:
  26435. return m.Index()
  26436. case tutorial.FieldTitle:
  26437. return m.Title()
  26438. case tutorial.FieldContent:
  26439. return m.Content()
  26440. case tutorial.FieldOrganizationID:
  26441. return m.OrganizationID()
  26442. }
  26443. return nil, false
  26444. }
  26445. // OldField returns the old value of the field from the database. An error is
  26446. // returned if the mutation operation is not UpdateOne, or the query to the
  26447. // database failed.
  26448. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26449. switch name {
  26450. case tutorial.FieldCreatedAt:
  26451. return m.OldCreatedAt(ctx)
  26452. case tutorial.FieldUpdatedAt:
  26453. return m.OldUpdatedAt(ctx)
  26454. case tutorial.FieldDeletedAt:
  26455. return m.OldDeletedAt(ctx)
  26456. case tutorial.FieldEmployeeID:
  26457. return m.OldEmployeeID(ctx)
  26458. case tutorial.FieldIndex:
  26459. return m.OldIndex(ctx)
  26460. case tutorial.FieldTitle:
  26461. return m.OldTitle(ctx)
  26462. case tutorial.FieldContent:
  26463. return m.OldContent(ctx)
  26464. case tutorial.FieldOrganizationID:
  26465. return m.OldOrganizationID(ctx)
  26466. }
  26467. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26468. }
  26469. // SetField sets the value of a field with the given name. It returns an error if
  26470. // the field is not defined in the schema, or if the type mismatched the field
  26471. // type.
  26472. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26473. switch name {
  26474. case tutorial.FieldCreatedAt:
  26475. v, ok := value.(time.Time)
  26476. if !ok {
  26477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26478. }
  26479. m.SetCreatedAt(v)
  26480. return nil
  26481. case tutorial.FieldUpdatedAt:
  26482. v, ok := value.(time.Time)
  26483. if !ok {
  26484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26485. }
  26486. m.SetUpdatedAt(v)
  26487. return nil
  26488. case tutorial.FieldDeletedAt:
  26489. v, ok := value.(time.Time)
  26490. if !ok {
  26491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26492. }
  26493. m.SetDeletedAt(v)
  26494. return nil
  26495. case tutorial.FieldEmployeeID:
  26496. v, ok := value.(uint64)
  26497. if !ok {
  26498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26499. }
  26500. m.SetEmployeeID(v)
  26501. return nil
  26502. case tutorial.FieldIndex:
  26503. v, ok := value.(int)
  26504. if !ok {
  26505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26506. }
  26507. m.SetIndex(v)
  26508. return nil
  26509. case tutorial.FieldTitle:
  26510. v, ok := value.(string)
  26511. if !ok {
  26512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26513. }
  26514. m.SetTitle(v)
  26515. return nil
  26516. case tutorial.FieldContent:
  26517. v, ok := value.(string)
  26518. if !ok {
  26519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26520. }
  26521. m.SetContent(v)
  26522. return nil
  26523. case tutorial.FieldOrganizationID:
  26524. v, ok := value.(uint64)
  26525. if !ok {
  26526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26527. }
  26528. m.SetOrganizationID(v)
  26529. return nil
  26530. }
  26531. return fmt.Errorf("unknown Tutorial field %s", name)
  26532. }
  26533. // AddedFields returns all numeric fields that were incremented/decremented during
  26534. // this mutation.
  26535. func (m *TutorialMutation) AddedFields() []string {
  26536. var fields []string
  26537. if m.addindex != nil {
  26538. fields = append(fields, tutorial.FieldIndex)
  26539. }
  26540. if m.addorganization_id != nil {
  26541. fields = append(fields, tutorial.FieldOrganizationID)
  26542. }
  26543. return fields
  26544. }
  26545. // AddedField returns the numeric value that was incremented/decremented on a field
  26546. // with the given name. The second boolean return value indicates that this field
  26547. // was not set, or was not defined in the schema.
  26548. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26549. switch name {
  26550. case tutorial.FieldIndex:
  26551. return m.AddedIndex()
  26552. case tutorial.FieldOrganizationID:
  26553. return m.AddedOrganizationID()
  26554. }
  26555. return nil, false
  26556. }
  26557. // AddField adds the value to the field with the given name. It returns an error if
  26558. // the field is not defined in the schema, or if the type mismatched the field
  26559. // type.
  26560. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26561. switch name {
  26562. case tutorial.FieldIndex:
  26563. v, ok := value.(int)
  26564. if !ok {
  26565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26566. }
  26567. m.AddIndex(v)
  26568. return nil
  26569. case tutorial.FieldOrganizationID:
  26570. v, ok := value.(int64)
  26571. if !ok {
  26572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26573. }
  26574. m.AddOrganizationID(v)
  26575. return nil
  26576. }
  26577. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26578. }
  26579. // ClearedFields returns all nullable fields that were cleared during this
  26580. // mutation.
  26581. func (m *TutorialMutation) ClearedFields() []string {
  26582. var fields []string
  26583. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26584. fields = append(fields, tutorial.FieldDeletedAt)
  26585. }
  26586. return fields
  26587. }
  26588. // FieldCleared returns a boolean indicating if a field with the given name was
  26589. // cleared in this mutation.
  26590. func (m *TutorialMutation) FieldCleared(name string) bool {
  26591. _, ok := m.clearedFields[name]
  26592. return ok
  26593. }
  26594. // ClearField clears the value of the field with the given name. It returns an
  26595. // error if the field is not defined in the schema.
  26596. func (m *TutorialMutation) ClearField(name string) error {
  26597. switch name {
  26598. case tutorial.FieldDeletedAt:
  26599. m.ClearDeletedAt()
  26600. return nil
  26601. }
  26602. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26603. }
  26604. // ResetField resets all changes in the mutation for the field with the given name.
  26605. // It returns an error if the field is not defined in the schema.
  26606. func (m *TutorialMutation) ResetField(name string) error {
  26607. switch name {
  26608. case tutorial.FieldCreatedAt:
  26609. m.ResetCreatedAt()
  26610. return nil
  26611. case tutorial.FieldUpdatedAt:
  26612. m.ResetUpdatedAt()
  26613. return nil
  26614. case tutorial.FieldDeletedAt:
  26615. m.ResetDeletedAt()
  26616. return nil
  26617. case tutorial.FieldEmployeeID:
  26618. m.ResetEmployeeID()
  26619. return nil
  26620. case tutorial.FieldIndex:
  26621. m.ResetIndex()
  26622. return nil
  26623. case tutorial.FieldTitle:
  26624. m.ResetTitle()
  26625. return nil
  26626. case tutorial.FieldContent:
  26627. m.ResetContent()
  26628. return nil
  26629. case tutorial.FieldOrganizationID:
  26630. m.ResetOrganizationID()
  26631. return nil
  26632. }
  26633. return fmt.Errorf("unknown Tutorial field %s", name)
  26634. }
  26635. // AddedEdges returns all edge names that were set/added in this mutation.
  26636. func (m *TutorialMutation) AddedEdges() []string {
  26637. edges := make([]string, 0, 1)
  26638. if m.employee != nil {
  26639. edges = append(edges, tutorial.EdgeEmployee)
  26640. }
  26641. return edges
  26642. }
  26643. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26644. // name in this mutation.
  26645. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26646. switch name {
  26647. case tutorial.EdgeEmployee:
  26648. if id := m.employee; id != nil {
  26649. return []ent.Value{*id}
  26650. }
  26651. }
  26652. return nil
  26653. }
  26654. // RemovedEdges returns all edge names that were removed in this mutation.
  26655. func (m *TutorialMutation) RemovedEdges() []string {
  26656. edges := make([]string, 0, 1)
  26657. return edges
  26658. }
  26659. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26660. // the given name in this mutation.
  26661. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26662. return nil
  26663. }
  26664. // ClearedEdges returns all edge names that were cleared in this mutation.
  26665. func (m *TutorialMutation) ClearedEdges() []string {
  26666. edges := make([]string, 0, 1)
  26667. if m.clearedemployee {
  26668. edges = append(edges, tutorial.EdgeEmployee)
  26669. }
  26670. return edges
  26671. }
  26672. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26673. // was cleared in this mutation.
  26674. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26675. switch name {
  26676. case tutorial.EdgeEmployee:
  26677. return m.clearedemployee
  26678. }
  26679. return false
  26680. }
  26681. // ClearEdge clears the value of the edge with the given name. It returns an error
  26682. // if that edge is not defined in the schema.
  26683. func (m *TutorialMutation) ClearEdge(name string) error {
  26684. switch name {
  26685. case tutorial.EdgeEmployee:
  26686. m.ClearEmployee()
  26687. return nil
  26688. }
  26689. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26690. }
  26691. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26692. // It returns an error if the edge is not defined in the schema.
  26693. func (m *TutorialMutation) ResetEdge(name string) error {
  26694. switch name {
  26695. case tutorial.EdgeEmployee:
  26696. m.ResetEmployee()
  26697. return nil
  26698. }
  26699. return fmt.Errorf("unknown Tutorial edge %s", name)
  26700. }
  26701. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26702. type UsageDetailMutation struct {
  26703. config
  26704. op Op
  26705. typ string
  26706. id *uint64
  26707. created_at *time.Time
  26708. updated_at *time.Time
  26709. status *uint8
  26710. addstatus *int8
  26711. _type *int
  26712. add_type *int
  26713. bot_id *string
  26714. receiver_id *string
  26715. app *int
  26716. addapp *int
  26717. session_id *uint64
  26718. addsession_id *int64
  26719. request *string
  26720. response *string
  26721. original_data *custom_types.OriginalData
  26722. total_tokens *uint64
  26723. addtotal_tokens *int64
  26724. prompt_tokens *uint64
  26725. addprompt_tokens *int64
  26726. completion_tokens *uint64
  26727. addcompletion_tokens *int64
  26728. organization_id *uint64
  26729. addorganization_id *int64
  26730. clearedFields map[string]struct{}
  26731. done bool
  26732. oldValue func(context.Context) (*UsageDetail, error)
  26733. predicates []predicate.UsageDetail
  26734. }
  26735. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26736. // usagedetailOption allows management of the mutation configuration using functional options.
  26737. type usagedetailOption func(*UsageDetailMutation)
  26738. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26739. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26740. m := &UsageDetailMutation{
  26741. config: c,
  26742. op: op,
  26743. typ: TypeUsageDetail,
  26744. clearedFields: make(map[string]struct{}),
  26745. }
  26746. for _, opt := range opts {
  26747. opt(m)
  26748. }
  26749. return m
  26750. }
  26751. // withUsageDetailID sets the ID field of the mutation.
  26752. func withUsageDetailID(id uint64) usagedetailOption {
  26753. return func(m *UsageDetailMutation) {
  26754. var (
  26755. err error
  26756. once sync.Once
  26757. value *UsageDetail
  26758. )
  26759. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26760. once.Do(func() {
  26761. if m.done {
  26762. err = errors.New("querying old values post mutation is not allowed")
  26763. } else {
  26764. value, err = m.Client().UsageDetail.Get(ctx, id)
  26765. }
  26766. })
  26767. return value, err
  26768. }
  26769. m.id = &id
  26770. }
  26771. }
  26772. // withUsageDetail sets the old UsageDetail of the mutation.
  26773. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26774. return func(m *UsageDetailMutation) {
  26775. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26776. return node, nil
  26777. }
  26778. m.id = &node.ID
  26779. }
  26780. }
  26781. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26782. // executed in a transaction (ent.Tx), a transactional client is returned.
  26783. func (m UsageDetailMutation) Client() *Client {
  26784. client := &Client{config: m.config}
  26785. client.init()
  26786. return client
  26787. }
  26788. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26789. // it returns an error otherwise.
  26790. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26791. if _, ok := m.driver.(*txDriver); !ok {
  26792. return nil, errors.New("ent: mutation is not running in a transaction")
  26793. }
  26794. tx := &Tx{config: m.config}
  26795. tx.init()
  26796. return tx, nil
  26797. }
  26798. // SetID sets the value of the id field. Note that this
  26799. // operation is only accepted on creation of UsageDetail entities.
  26800. func (m *UsageDetailMutation) SetID(id uint64) {
  26801. m.id = &id
  26802. }
  26803. // ID returns the ID value in the mutation. Note that the ID is only available
  26804. // if it was provided to the builder or after it was returned from the database.
  26805. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26806. if m.id == nil {
  26807. return
  26808. }
  26809. return *m.id, true
  26810. }
  26811. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26812. // That means, if the mutation is applied within a transaction with an isolation level such
  26813. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26814. // or updated by the mutation.
  26815. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26816. switch {
  26817. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26818. id, exists := m.ID()
  26819. if exists {
  26820. return []uint64{id}, nil
  26821. }
  26822. fallthrough
  26823. case m.op.Is(OpUpdate | OpDelete):
  26824. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26825. default:
  26826. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26827. }
  26828. }
  26829. // SetCreatedAt sets the "created_at" field.
  26830. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26831. m.created_at = &t
  26832. }
  26833. // CreatedAt returns the value of the "created_at" field in the mutation.
  26834. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26835. v := m.created_at
  26836. if v == nil {
  26837. return
  26838. }
  26839. return *v, true
  26840. }
  26841. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26842. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26844. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26845. if !m.op.Is(OpUpdateOne) {
  26846. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26847. }
  26848. if m.id == nil || m.oldValue == nil {
  26849. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26850. }
  26851. oldValue, err := m.oldValue(ctx)
  26852. if err != nil {
  26853. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26854. }
  26855. return oldValue.CreatedAt, nil
  26856. }
  26857. // ResetCreatedAt resets all changes to the "created_at" field.
  26858. func (m *UsageDetailMutation) ResetCreatedAt() {
  26859. m.created_at = nil
  26860. }
  26861. // SetUpdatedAt sets the "updated_at" field.
  26862. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26863. m.updated_at = &t
  26864. }
  26865. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26866. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26867. v := m.updated_at
  26868. if v == nil {
  26869. return
  26870. }
  26871. return *v, true
  26872. }
  26873. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26874. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26876. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26877. if !m.op.Is(OpUpdateOne) {
  26878. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26879. }
  26880. if m.id == nil || m.oldValue == nil {
  26881. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26882. }
  26883. oldValue, err := m.oldValue(ctx)
  26884. if err != nil {
  26885. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26886. }
  26887. return oldValue.UpdatedAt, nil
  26888. }
  26889. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26890. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26891. m.updated_at = nil
  26892. }
  26893. // SetStatus sets the "status" field.
  26894. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26895. m.status = &u
  26896. m.addstatus = nil
  26897. }
  26898. // Status returns the value of the "status" field in the mutation.
  26899. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26900. v := m.status
  26901. if v == nil {
  26902. return
  26903. }
  26904. return *v, true
  26905. }
  26906. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26907. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26909. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26910. if !m.op.Is(OpUpdateOne) {
  26911. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26912. }
  26913. if m.id == nil || m.oldValue == nil {
  26914. return v, errors.New("OldStatus requires an ID field in the mutation")
  26915. }
  26916. oldValue, err := m.oldValue(ctx)
  26917. if err != nil {
  26918. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26919. }
  26920. return oldValue.Status, nil
  26921. }
  26922. // AddStatus adds u to the "status" field.
  26923. func (m *UsageDetailMutation) AddStatus(u int8) {
  26924. if m.addstatus != nil {
  26925. *m.addstatus += u
  26926. } else {
  26927. m.addstatus = &u
  26928. }
  26929. }
  26930. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26931. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26932. v := m.addstatus
  26933. if v == nil {
  26934. return
  26935. }
  26936. return *v, true
  26937. }
  26938. // ClearStatus clears the value of the "status" field.
  26939. func (m *UsageDetailMutation) ClearStatus() {
  26940. m.status = nil
  26941. m.addstatus = nil
  26942. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26943. }
  26944. // StatusCleared returns if the "status" field was cleared in this mutation.
  26945. func (m *UsageDetailMutation) StatusCleared() bool {
  26946. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26947. return ok
  26948. }
  26949. // ResetStatus resets all changes to the "status" field.
  26950. func (m *UsageDetailMutation) ResetStatus() {
  26951. m.status = nil
  26952. m.addstatus = nil
  26953. delete(m.clearedFields, usagedetail.FieldStatus)
  26954. }
  26955. // SetType sets the "type" field.
  26956. func (m *UsageDetailMutation) SetType(i int) {
  26957. m._type = &i
  26958. m.add_type = nil
  26959. }
  26960. // GetType returns the value of the "type" field in the mutation.
  26961. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26962. v := m._type
  26963. if v == nil {
  26964. return
  26965. }
  26966. return *v, true
  26967. }
  26968. // OldType returns the old "type" field's value of the UsageDetail entity.
  26969. // If the UsageDetail 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 *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26972. if !m.op.Is(OpUpdateOne) {
  26973. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26974. }
  26975. if m.id == nil || m.oldValue == nil {
  26976. return v, errors.New("OldType 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 OldType: %w", err)
  26981. }
  26982. return oldValue.Type, nil
  26983. }
  26984. // AddType adds i to the "type" field.
  26985. func (m *UsageDetailMutation) AddType(i int) {
  26986. if m.add_type != nil {
  26987. *m.add_type += i
  26988. } else {
  26989. m.add_type = &i
  26990. }
  26991. }
  26992. // AddedType returns the value that was added to the "type" field in this mutation.
  26993. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26994. v := m.add_type
  26995. if v == nil {
  26996. return
  26997. }
  26998. return *v, true
  26999. }
  27000. // ClearType clears the value of the "type" field.
  27001. func (m *UsageDetailMutation) ClearType() {
  27002. m._type = nil
  27003. m.add_type = nil
  27004. m.clearedFields[usagedetail.FieldType] = struct{}{}
  27005. }
  27006. // TypeCleared returns if the "type" field was cleared in this mutation.
  27007. func (m *UsageDetailMutation) TypeCleared() bool {
  27008. _, ok := m.clearedFields[usagedetail.FieldType]
  27009. return ok
  27010. }
  27011. // ResetType resets all changes to the "type" field.
  27012. func (m *UsageDetailMutation) ResetType() {
  27013. m._type = nil
  27014. m.add_type = nil
  27015. delete(m.clearedFields, usagedetail.FieldType)
  27016. }
  27017. // SetBotID sets the "bot_id" field.
  27018. func (m *UsageDetailMutation) SetBotID(s string) {
  27019. m.bot_id = &s
  27020. }
  27021. // BotID returns the value of the "bot_id" field in the mutation.
  27022. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  27023. v := m.bot_id
  27024. if v == nil {
  27025. return
  27026. }
  27027. return *v, true
  27028. }
  27029. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  27030. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27032. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  27033. if !m.op.Is(OpUpdateOne) {
  27034. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27035. }
  27036. if m.id == nil || m.oldValue == nil {
  27037. return v, errors.New("OldBotID requires an ID field in the mutation")
  27038. }
  27039. oldValue, err := m.oldValue(ctx)
  27040. if err != nil {
  27041. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27042. }
  27043. return oldValue.BotID, nil
  27044. }
  27045. // ResetBotID resets all changes to the "bot_id" field.
  27046. func (m *UsageDetailMutation) ResetBotID() {
  27047. m.bot_id = nil
  27048. }
  27049. // SetReceiverID sets the "receiver_id" field.
  27050. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27051. m.receiver_id = &s
  27052. }
  27053. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27054. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27055. v := m.receiver_id
  27056. if v == nil {
  27057. return
  27058. }
  27059. return *v, true
  27060. }
  27061. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27062. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27064. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27065. if !m.op.Is(OpUpdateOne) {
  27066. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27067. }
  27068. if m.id == nil || m.oldValue == nil {
  27069. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27070. }
  27071. oldValue, err := m.oldValue(ctx)
  27072. if err != nil {
  27073. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27074. }
  27075. return oldValue.ReceiverID, nil
  27076. }
  27077. // ResetReceiverID resets all changes to the "receiver_id" field.
  27078. func (m *UsageDetailMutation) ResetReceiverID() {
  27079. m.receiver_id = nil
  27080. }
  27081. // SetApp sets the "app" field.
  27082. func (m *UsageDetailMutation) SetApp(i int) {
  27083. m.app = &i
  27084. m.addapp = nil
  27085. }
  27086. // App returns the value of the "app" field in the mutation.
  27087. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27088. v := m.app
  27089. if v == nil {
  27090. return
  27091. }
  27092. return *v, true
  27093. }
  27094. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27095. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27097. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27098. if !m.op.Is(OpUpdateOne) {
  27099. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27100. }
  27101. if m.id == nil || m.oldValue == nil {
  27102. return v, errors.New("OldApp requires an ID field in the mutation")
  27103. }
  27104. oldValue, err := m.oldValue(ctx)
  27105. if err != nil {
  27106. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27107. }
  27108. return oldValue.App, nil
  27109. }
  27110. // AddApp adds i to the "app" field.
  27111. func (m *UsageDetailMutation) AddApp(i int) {
  27112. if m.addapp != nil {
  27113. *m.addapp += i
  27114. } else {
  27115. m.addapp = &i
  27116. }
  27117. }
  27118. // AddedApp returns the value that was added to the "app" field in this mutation.
  27119. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27120. v := m.addapp
  27121. if v == nil {
  27122. return
  27123. }
  27124. return *v, true
  27125. }
  27126. // ClearApp clears the value of the "app" field.
  27127. func (m *UsageDetailMutation) ClearApp() {
  27128. m.app = nil
  27129. m.addapp = nil
  27130. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27131. }
  27132. // AppCleared returns if the "app" field was cleared in this mutation.
  27133. func (m *UsageDetailMutation) AppCleared() bool {
  27134. _, ok := m.clearedFields[usagedetail.FieldApp]
  27135. return ok
  27136. }
  27137. // ResetApp resets all changes to the "app" field.
  27138. func (m *UsageDetailMutation) ResetApp() {
  27139. m.app = nil
  27140. m.addapp = nil
  27141. delete(m.clearedFields, usagedetail.FieldApp)
  27142. }
  27143. // SetSessionID sets the "session_id" field.
  27144. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27145. m.session_id = &u
  27146. m.addsession_id = nil
  27147. }
  27148. // SessionID returns the value of the "session_id" field in the mutation.
  27149. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27150. v := m.session_id
  27151. if v == nil {
  27152. return
  27153. }
  27154. return *v, true
  27155. }
  27156. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27157. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27159. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27160. if !m.op.Is(OpUpdateOne) {
  27161. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27162. }
  27163. if m.id == nil || m.oldValue == nil {
  27164. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27165. }
  27166. oldValue, err := m.oldValue(ctx)
  27167. if err != nil {
  27168. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27169. }
  27170. return oldValue.SessionID, nil
  27171. }
  27172. // AddSessionID adds u to the "session_id" field.
  27173. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27174. if m.addsession_id != nil {
  27175. *m.addsession_id += u
  27176. } else {
  27177. m.addsession_id = &u
  27178. }
  27179. }
  27180. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27181. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27182. v := m.addsession_id
  27183. if v == nil {
  27184. return
  27185. }
  27186. return *v, true
  27187. }
  27188. // ClearSessionID clears the value of the "session_id" field.
  27189. func (m *UsageDetailMutation) ClearSessionID() {
  27190. m.session_id = nil
  27191. m.addsession_id = nil
  27192. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27193. }
  27194. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27195. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27196. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27197. return ok
  27198. }
  27199. // ResetSessionID resets all changes to the "session_id" field.
  27200. func (m *UsageDetailMutation) ResetSessionID() {
  27201. m.session_id = nil
  27202. m.addsession_id = nil
  27203. delete(m.clearedFields, usagedetail.FieldSessionID)
  27204. }
  27205. // SetRequest sets the "request" field.
  27206. func (m *UsageDetailMutation) SetRequest(s string) {
  27207. m.request = &s
  27208. }
  27209. // Request returns the value of the "request" field in the mutation.
  27210. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27211. v := m.request
  27212. if v == nil {
  27213. return
  27214. }
  27215. return *v, true
  27216. }
  27217. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27218. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27220. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27221. if !m.op.Is(OpUpdateOne) {
  27222. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27223. }
  27224. if m.id == nil || m.oldValue == nil {
  27225. return v, errors.New("OldRequest requires an ID field in the mutation")
  27226. }
  27227. oldValue, err := m.oldValue(ctx)
  27228. if err != nil {
  27229. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27230. }
  27231. return oldValue.Request, nil
  27232. }
  27233. // ResetRequest resets all changes to the "request" field.
  27234. func (m *UsageDetailMutation) ResetRequest() {
  27235. m.request = nil
  27236. }
  27237. // SetResponse sets the "response" field.
  27238. func (m *UsageDetailMutation) SetResponse(s string) {
  27239. m.response = &s
  27240. }
  27241. // Response returns the value of the "response" field in the mutation.
  27242. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27243. v := m.response
  27244. if v == nil {
  27245. return
  27246. }
  27247. return *v, true
  27248. }
  27249. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27250. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27252. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27253. if !m.op.Is(OpUpdateOne) {
  27254. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27255. }
  27256. if m.id == nil || m.oldValue == nil {
  27257. return v, errors.New("OldResponse requires an ID field in the mutation")
  27258. }
  27259. oldValue, err := m.oldValue(ctx)
  27260. if err != nil {
  27261. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27262. }
  27263. return oldValue.Response, nil
  27264. }
  27265. // ResetResponse resets all changes to the "response" field.
  27266. func (m *UsageDetailMutation) ResetResponse() {
  27267. m.response = nil
  27268. }
  27269. // SetOriginalData sets the "original_data" field.
  27270. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27271. m.original_data = &ctd
  27272. }
  27273. // OriginalData returns the value of the "original_data" field in the mutation.
  27274. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27275. v := m.original_data
  27276. if v == nil {
  27277. return
  27278. }
  27279. return *v, true
  27280. }
  27281. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27282. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27284. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27285. if !m.op.Is(OpUpdateOne) {
  27286. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27287. }
  27288. if m.id == nil || m.oldValue == nil {
  27289. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27290. }
  27291. oldValue, err := m.oldValue(ctx)
  27292. if err != nil {
  27293. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27294. }
  27295. return oldValue.OriginalData, nil
  27296. }
  27297. // ResetOriginalData resets all changes to the "original_data" field.
  27298. func (m *UsageDetailMutation) ResetOriginalData() {
  27299. m.original_data = nil
  27300. }
  27301. // SetTotalTokens sets the "total_tokens" field.
  27302. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27303. m.total_tokens = &u
  27304. m.addtotal_tokens = nil
  27305. }
  27306. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27307. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27308. v := m.total_tokens
  27309. if v == nil {
  27310. return
  27311. }
  27312. return *v, true
  27313. }
  27314. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27315. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27317. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27318. if !m.op.Is(OpUpdateOne) {
  27319. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27320. }
  27321. if m.id == nil || m.oldValue == nil {
  27322. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27323. }
  27324. oldValue, err := m.oldValue(ctx)
  27325. if err != nil {
  27326. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27327. }
  27328. return oldValue.TotalTokens, nil
  27329. }
  27330. // AddTotalTokens adds u to the "total_tokens" field.
  27331. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27332. if m.addtotal_tokens != nil {
  27333. *m.addtotal_tokens += u
  27334. } else {
  27335. m.addtotal_tokens = &u
  27336. }
  27337. }
  27338. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27339. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27340. v := m.addtotal_tokens
  27341. if v == nil {
  27342. return
  27343. }
  27344. return *v, true
  27345. }
  27346. // ClearTotalTokens clears the value of the "total_tokens" field.
  27347. func (m *UsageDetailMutation) ClearTotalTokens() {
  27348. m.total_tokens = nil
  27349. m.addtotal_tokens = nil
  27350. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27351. }
  27352. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27353. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27354. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27355. return ok
  27356. }
  27357. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27358. func (m *UsageDetailMutation) ResetTotalTokens() {
  27359. m.total_tokens = nil
  27360. m.addtotal_tokens = nil
  27361. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27362. }
  27363. // SetPromptTokens sets the "prompt_tokens" field.
  27364. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27365. m.prompt_tokens = &u
  27366. m.addprompt_tokens = nil
  27367. }
  27368. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27369. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27370. v := m.prompt_tokens
  27371. if v == nil {
  27372. return
  27373. }
  27374. return *v, true
  27375. }
  27376. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27377. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27379. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27380. if !m.op.Is(OpUpdateOne) {
  27381. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27382. }
  27383. if m.id == nil || m.oldValue == nil {
  27384. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27385. }
  27386. oldValue, err := m.oldValue(ctx)
  27387. if err != nil {
  27388. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27389. }
  27390. return oldValue.PromptTokens, nil
  27391. }
  27392. // AddPromptTokens adds u to the "prompt_tokens" field.
  27393. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27394. if m.addprompt_tokens != nil {
  27395. *m.addprompt_tokens += u
  27396. } else {
  27397. m.addprompt_tokens = &u
  27398. }
  27399. }
  27400. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27401. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27402. v := m.addprompt_tokens
  27403. if v == nil {
  27404. return
  27405. }
  27406. return *v, true
  27407. }
  27408. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27409. func (m *UsageDetailMutation) ClearPromptTokens() {
  27410. m.prompt_tokens = nil
  27411. m.addprompt_tokens = nil
  27412. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27413. }
  27414. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27415. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27416. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27417. return ok
  27418. }
  27419. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27420. func (m *UsageDetailMutation) ResetPromptTokens() {
  27421. m.prompt_tokens = nil
  27422. m.addprompt_tokens = nil
  27423. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27424. }
  27425. // SetCompletionTokens sets the "completion_tokens" field.
  27426. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27427. m.completion_tokens = &u
  27428. m.addcompletion_tokens = nil
  27429. }
  27430. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27431. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27432. v := m.completion_tokens
  27433. if v == nil {
  27434. return
  27435. }
  27436. return *v, true
  27437. }
  27438. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27439. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27441. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27442. if !m.op.Is(OpUpdateOne) {
  27443. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27444. }
  27445. if m.id == nil || m.oldValue == nil {
  27446. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27447. }
  27448. oldValue, err := m.oldValue(ctx)
  27449. if err != nil {
  27450. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27451. }
  27452. return oldValue.CompletionTokens, nil
  27453. }
  27454. // AddCompletionTokens adds u to the "completion_tokens" field.
  27455. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27456. if m.addcompletion_tokens != nil {
  27457. *m.addcompletion_tokens += u
  27458. } else {
  27459. m.addcompletion_tokens = &u
  27460. }
  27461. }
  27462. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27463. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27464. v := m.addcompletion_tokens
  27465. if v == nil {
  27466. return
  27467. }
  27468. return *v, true
  27469. }
  27470. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27471. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27472. m.completion_tokens = nil
  27473. m.addcompletion_tokens = nil
  27474. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27475. }
  27476. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27477. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27478. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27479. return ok
  27480. }
  27481. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27482. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27483. m.completion_tokens = nil
  27484. m.addcompletion_tokens = nil
  27485. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27486. }
  27487. // SetOrganizationID sets the "organization_id" field.
  27488. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27489. m.organization_id = &u
  27490. m.addorganization_id = nil
  27491. }
  27492. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27493. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27494. v := m.organization_id
  27495. if v == nil {
  27496. return
  27497. }
  27498. return *v, true
  27499. }
  27500. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27501. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27503. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27504. if !m.op.Is(OpUpdateOne) {
  27505. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27506. }
  27507. if m.id == nil || m.oldValue == nil {
  27508. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27509. }
  27510. oldValue, err := m.oldValue(ctx)
  27511. if err != nil {
  27512. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27513. }
  27514. return oldValue.OrganizationID, nil
  27515. }
  27516. // AddOrganizationID adds u to the "organization_id" field.
  27517. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27518. if m.addorganization_id != nil {
  27519. *m.addorganization_id += u
  27520. } else {
  27521. m.addorganization_id = &u
  27522. }
  27523. }
  27524. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27525. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27526. v := m.addorganization_id
  27527. if v == nil {
  27528. return
  27529. }
  27530. return *v, true
  27531. }
  27532. // ClearOrganizationID clears the value of the "organization_id" field.
  27533. func (m *UsageDetailMutation) ClearOrganizationID() {
  27534. m.organization_id = nil
  27535. m.addorganization_id = nil
  27536. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27537. }
  27538. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27539. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27540. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27541. return ok
  27542. }
  27543. // ResetOrganizationID resets all changes to the "organization_id" field.
  27544. func (m *UsageDetailMutation) ResetOrganizationID() {
  27545. m.organization_id = nil
  27546. m.addorganization_id = nil
  27547. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27548. }
  27549. // Where appends a list predicates to the UsageDetailMutation builder.
  27550. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27551. m.predicates = append(m.predicates, ps...)
  27552. }
  27553. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27554. // users can use type-assertion to append predicates that do not depend on any generated package.
  27555. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27556. p := make([]predicate.UsageDetail, len(ps))
  27557. for i := range ps {
  27558. p[i] = ps[i]
  27559. }
  27560. m.Where(p...)
  27561. }
  27562. // Op returns the operation name.
  27563. func (m *UsageDetailMutation) Op() Op {
  27564. return m.op
  27565. }
  27566. // SetOp allows setting the mutation operation.
  27567. func (m *UsageDetailMutation) SetOp(op Op) {
  27568. m.op = op
  27569. }
  27570. // Type returns the node type of this mutation (UsageDetail).
  27571. func (m *UsageDetailMutation) Type() string {
  27572. return m.typ
  27573. }
  27574. // Fields returns all fields that were changed during this mutation. Note that in
  27575. // order to get all numeric fields that were incremented/decremented, call
  27576. // AddedFields().
  27577. func (m *UsageDetailMutation) Fields() []string {
  27578. fields := make([]string, 0, 15)
  27579. if m.created_at != nil {
  27580. fields = append(fields, usagedetail.FieldCreatedAt)
  27581. }
  27582. if m.updated_at != nil {
  27583. fields = append(fields, usagedetail.FieldUpdatedAt)
  27584. }
  27585. if m.status != nil {
  27586. fields = append(fields, usagedetail.FieldStatus)
  27587. }
  27588. if m._type != nil {
  27589. fields = append(fields, usagedetail.FieldType)
  27590. }
  27591. if m.bot_id != nil {
  27592. fields = append(fields, usagedetail.FieldBotID)
  27593. }
  27594. if m.receiver_id != nil {
  27595. fields = append(fields, usagedetail.FieldReceiverID)
  27596. }
  27597. if m.app != nil {
  27598. fields = append(fields, usagedetail.FieldApp)
  27599. }
  27600. if m.session_id != nil {
  27601. fields = append(fields, usagedetail.FieldSessionID)
  27602. }
  27603. if m.request != nil {
  27604. fields = append(fields, usagedetail.FieldRequest)
  27605. }
  27606. if m.response != nil {
  27607. fields = append(fields, usagedetail.FieldResponse)
  27608. }
  27609. if m.original_data != nil {
  27610. fields = append(fields, usagedetail.FieldOriginalData)
  27611. }
  27612. if m.total_tokens != nil {
  27613. fields = append(fields, usagedetail.FieldTotalTokens)
  27614. }
  27615. if m.prompt_tokens != nil {
  27616. fields = append(fields, usagedetail.FieldPromptTokens)
  27617. }
  27618. if m.completion_tokens != nil {
  27619. fields = append(fields, usagedetail.FieldCompletionTokens)
  27620. }
  27621. if m.organization_id != nil {
  27622. fields = append(fields, usagedetail.FieldOrganizationID)
  27623. }
  27624. return fields
  27625. }
  27626. // Field returns the value of a field with the given name. The second boolean
  27627. // return value indicates that this field was not set, or was not defined in the
  27628. // schema.
  27629. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27630. switch name {
  27631. case usagedetail.FieldCreatedAt:
  27632. return m.CreatedAt()
  27633. case usagedetail.FieldUpdatedAt:
  27634. return m.UpdatedAt()
  27635. case usagedetail.FieldStatus:
  27636. return m.Status()
  27637. case usagedetail.FieldType:
  27638. return m.GetType()
  27639. case usagedetail.FieldBotID:
  27640. return m.BotID()
  27641. case usagedetail.FieldReceiverID:
  27642. return m.ReceiverID()
  27643. case usagedetail.FieldApp:
  27644. return m.App()
  27645. case usagedetail.FieldSessionID:
  27646. return m.SessionID()
  27647. case usagedetail.FieldRequest:
  27648. return m.Request()
  27649. case usagedetail.FieldResponse:
  27650. return m.Response()
  27651. case usagedetail.FieldOriginalData:
  27652. return m.OriginalData()
  27653. case usagedetail.FieldTotalTokens:
  27654. return m.TotalTokens()
  27655. case usagedetail.FieldPromptTokens:
  27656. return m.PromptTokens()
  27657. case usagedetail.FieldCompletionTokens:
  27658. return m.CompletionTokens()
  27659. case usagedetail.FieldOrganizationID:
  27660. return m.OrganizationID()
  27661. }
  27662. return nil, false
  27663. }
  27664. // OldField returns the old value of the field from the database. An error is
  27665. // returned if the mutation operation is not UpdateOne, or the query to the
  27666. // database failed.
  27667. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27668. switch name {
  27669. case usagedetail.FieldCreatedAt:
  27670. return m.OldCreatedAt(ctx)
  27671. case usagedetail.FieldUpdatedAt:
  27672. return m.OldUpdatedAt(ctx)
  27673. case usagedetail.FieldStatus:
  27674. return m.OldStatus(ctx)
  27675. case usagedetail.FieldType:
  27676. return m.OldType(ctx)
  27677. case usagedetail.FieldBotID:
  27678. return m.OldBotID(ctx)
  27679. case usagedetail.FieldReceiverID:
  27680. return m.OldReceiverID(ctx)
  27681. case usagedetail.FieldApp:
  27682. return m.OldApp(ctx)
  27683. case usagedetail.FieldSessionID:
  27684. return m.OldSessionID(ctx)
  27685. case usagedetail.FieldRequest:
  27686. return m.OldRequest(ctx)
  27687. case usagedetail.FieldResponse:
  27688. return m.OldResponse(ctx)
  27689. case usagedetail.FieldOriginalData:
  27690. return m.OldOriginalData(ctx)
  27691. case usagedetail.FieldTotalTokens:
  27692. return m.OldTotalTokens(ctx)
  27693. case usagedetail.FieldPromptTokens:
  27694. return m.OldPromptTokens(ctx)
  27695. case usagedetail.FieldCompletionTokens:
  27696. return m.OldCompletionTokens(ctx)
  27697. case usagedetail.FieldOrganizationID:
  27698. return m.OldOrganizationID(ctx)
  27699. }
  27700. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27701. }
  27702. // SetField sets the value of a field with the given name. It returns an error if
  27703. // the field is not defined in the schema, or if the type mismatched the field
  27704. // type.
  27705. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27706. switch name {
  27707. case usagedetail.FieldCreatedAt:
  27708. v, ok := value.(time.Time)
  27709. if !ok {
  27710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27711. }
  27712. m.SetCreatedAt(v)
  27713. return nil
  27714. case usagedetail.FieldUpdatedAt:
  27715. v, ok := value.(time.Time)
  27716. if !ok {
  27717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27718. }
  27719. m.SetUpdatedAt(v)
  27720. return nil
  27721. case usagedetail.FieldStatus:
  27722. v, ok := value.(uint8)
  27723. if !ok {
  27724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27725. }
  27726. m.SetStatus(v)
  27727. return nil
  27728. case usagedetail.FieldType:
  27729. v, ok := value.(int)
  27730. if !ok {
  27731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27732. }
  27733. m.SetType(v)
  27734. return nil
  27735. case usagedetail.FieldBotID:
  27736. v, ok := value.(string)
  27737. if !ok {
  27738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27739. }
  27740. m.SetBotID(v)
  27741. return nil
  27742. case usagedetail.FieldReceiverID:
  27743. v, ok := value.(string)
  27744. if !ok {
  27745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27746. }
  27747. m.SetReceiverID(v)
  27748. return nil
  27749. case usagedetail.FieldApp:
  27750. v, ok := value.(int)
  27751. if !ok {
  27752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27753. }
  27754. m.SetApp(v)
  27755. return nil
  27756. case usagedetail.FieldSessionID:
  27757. v, ok := value.(uint64)
  27758. if !ok {
  27759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27760. }
  27761. m.SetSessionID(v)
  27762. return nil
  27763. case usagedetail.FieldRequest:
  27764. v, ok := value.(string)
  27765. if !ok {
  27766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27767. }
  27768. m.SetRequest(v)
  27769. return nil
  27770. case usagedetail.FieldResponse:
  27771. v, ok := value.(string)
  27772. if !ok {
  27773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27774. }
  27775. m.SetResponse(v)
  27776. return nil
  27777. case usagedetail.FieldOriginalData:
  27778. v, ok := value.(custom_types.OriginalData)
  27779. if !ok {
  27780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27781. }
  27782. m.SetOriginalData(v)
  27783. return nil
  27784. case usagedetail.FieldTotalTokens:
  27785. v, ok := value.(uint64)
  27786. if !ok {
  27787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27788. }
  27789. m.SetTotalTokens(v)
  27790. return nil
  27791. case usagedetail.FieldPromptTokens:
  27792. v, ok := value.(uint64)
  27793. if !ok {
  27794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27795. }
  27796. m.SetPromptTokens(v)
  27797. return nil
  27798. case usagedetail.FieldCompletionTokens:
  27799. v, ok := value.(uint64)
  27800. if !ok {
  27801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27802. }
  27803. m.SetCompletionTokens(v)
  27804. return nil
  27805. case usagedetail.FieldOrganizationID:
  27806. v, ok := value.(uint64)
  27807. if !ok {
  27808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27809. }
  27810. m.SetOrganizationID(v)
  27811. return nil
  27812. }
  27813. return fmt.Errorf("unknown UsageDetail field %s", name)
  27814. }
  27815. // AddedFields returns all numeric fields that were incremented/decremented during
  27816. // this mutation.
  27817. func (m *UsageDetailMutation) AddedFields() []string {
  27818. var fields []string
  27819. if m.addstatus != nil {
  27820. fields = append(fields, usagedetail.FieldStatus)
  27821. }
  27822. if m.add_type != nil {
  27823. fields = append(fields, usagedetail.FieldType)
  27824. }
  27825. if m.addapp != nil {
  27826. fields = append(fields, usagedetail.FieldApp)
  27827. }
  27828. if m.addsession_id != nil {
  27829. fields = append(fields, usagedetail.FieldSessionID)
  27830. }
  27831. if m.addtotal_tokens != nil {
  27832. fields = append(fields, usagedetail.FieldTotalTokens)
  27833. }
  27834. if m.addprompt_tokens != nil {
  27835. fields = append(fields, usagedetail.FieldPromptTokens)
  27836. }
  27837. if m.addcompletion_tokens != nil {
  27838. fields = append(fields, usagedetail.FieldCompletionTokens)
  27839. }
  27840. if m.addorganization_id != nil {
  27841. fields = append(fields, usagedetail.FieldOrganizationID)
  27842. }
  27843. return fields
  27844. }
  27845. // AddedField returns the numeric value that was incremented/decremented on a field
  27846. // with the given name. The second boolean return value indicates that this field
  27847. // was not set, or was not defined in the schema.
  27848. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27849. switch name {
  27850. case usagedetail.FieldStatus:
  27851. return m.AddedStatus()
  27852. case usagedetail.FieldType:
  27853. return m.AddedType()
  27854. case usagedetail.FieldApp:
  27855. return m.AddedApp()
  27856. case usagedetail.FieldSessionID:
  27857. return m.AddedSessionID()
  27858. case usagedetail.FieldTotalTokens:
  27859. return m.AddedTotalTokens()
  27860. case usagedetail.FieldPromptTokens:
  27861. return m.AddedPromptTokens()
  27862. case usagedetail.FieldCompletionTokens:
  27863. return m.AddedCompletionTokens()
  27864. case usagedetail.FieldOrganizationID:
  27865. return m.AddedOrganizationID()
  27866. }
  27867. return nil, false
  27868. }
  27869. // AddField adds the value to the field with the given name. It returns an error if
  27870. // the field is not defined in the schema, or if the type mismatched the field
  27871. // type.
  27872. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27873. switch name {
  27874. case usagedetail.FieldStatus:
  27875. v, ok := value.(int8)
  27876. if !ok {
  27877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27878. }
  27879. m.AddStatus(v)
  27880. return nil
  27881. case usagedetail.FieldType:
  27882. v, ok := value.(int)
  27883. if !ok {
  27884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27885. }
  27886. m.AddType(v)
  27887. return nil
  27888. case usagedetail.FieldApp:
  27889. v, ok := value.(int)
  27890. if !ok {
  27891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27892. }
  27893. m.AddApp(v)
  27894. return nil
  27895. case usagedetail.FieldSessionID:
  27896. v, ok := value.(int64)
  27897. if !ok {
  27898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27899. }
  27900. m.AddSessionID(v)
  27901. return nil
  27902. case usagedetail.FieldTotalTokens:
  27903. v, ok := value.(int64)
  27904. if !ok {
  27905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27906. }
  27907. m.AddTotalTokens(v)
  27908. return nil
  27909. case usagedetail.FieldPromptTokens:
  27910. v, ok := value.(int64)
  27911. if !ok {
  27912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27913. }
  27914. m.AddPromptTokens(v)
  27915. return nil
  27916. case usagedetail.FieldCompletionTokens:
  27917. v, ok := value.(int64)
  27918. if !ok {
  27919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27920. }
  27921. m.AddCompletionTokens(v)
  27922. return nil
  27923. case usagedetail.FieldOrganizationID:
  27924. v, ok := value.(int64)
  27925. if !ok {
  27926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27927. }
  27928. m.AddOrganizationID(v)
  27929. return nil
  27930. }
  27931. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27932. }
  27933. // ClearedFields returns all nullable fields that were cleared during this
  27934. // mutation.
  27935. func (m *UsageDetailMutation) ClearedFields() []string {
  27936. var fields []string
  27937. if m.FieldCleared(usagedetail.FieldStatus) {
  27938. fields = append(fields, usagedetail.FieldStatus)
  27939. }
  27940. if m.FieldCleared(usagedetail.FieldType) {
  27941. fields = append(fields, usagedetail.FieldType)
  27942. }
  27943. if m.FieldCleared(usagedetail.FieldApp) {
  27944. fields = append(fields, usagedetail.FieldApp)
  27945. }
  27946. if m.FieldCleared(usagedetail.FieldSessionID) {
  27947. fields = append(fields, usagedetail.FieldSessionID)
  27948. }
  27949. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27950. fields = append(fields, usagedetail.FieldTotalTokens)
  27951. }
  27952. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27953. fields = append(fields, usagedetail.FieldPromptTokens)
  27954. }
  27955. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27956. fields = append(fields, usagedetail.FieldCompletionTokens)
  27957. }
  27958. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27959. fields = append(fields, usagedetail.FieldOrganizationID)
  27960. }
  27961. return fields
  27962. }
  27963. // FieldCleared returns a boolean indicating if a field with the given name was
  27964. // cleared in this mutation.
  27965. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27966. _, ok := m.clearedFields[name]
  27967. return ok
  27968. }
  27969. // ClearField clears the value of the field with the given name. It returns an
  27970. // error if the field is not defined in the schema.
  27971. func (m *UsageDetailMutation) ClearField(name string) error {
  27972. switch name {
  27973. case usagedetail.FieldStatus:
  27974. m.ClearStatus()
  27975. return nil
  27976. case usagedetail.FieldType:
  27977. m.ClearType()
  27978. return nil
  27979. case usagedetail.FieldApp:
  27980. m.ClearApp()
  27981. return nil
  27982. case usagedetail.FieldSessionID:
  27983. m.ClearSessionID()
  27984. return nil
  27985. case usagedetail.FieldTotalTokens:
  27986. m.ClearTotalTokens()
  27987. return nil
  27988. case usagedetail.FieldPromptTokens:
  27989. m.ClearPromptTokens()
  27990. return nil
  27991. case usagedetail.FieldCompletionTokens:
  27992. m.ClearCompletionTokens()
  27993. return nil
  27994. case usagedetail.FieldOrganizationID:
  27995. m.ClearOrganizationID()
  27996. return nil
  27997. }
  27998. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27999. }
  28000. // ResetField resets all changes in the mutation for the field with the given name.
  28001. // It returns an error if the field is not defined in the schema.
  28002. func (m *UsageDetailMutation) ResetField(name string) error {
  28003. switch name {
  28004. case usagedetail.FieldCreatedAt:
  28005. m.ResetCreatedAt()
  28006. return nil
  28007. case usagedetail.FieldUpdatedAt:
  28008. m.ResetUpdatedAt()
  28009. return nil
  28010. case usagedetail.FieldStatus:
  28011. m.ResetStatus()
  28012. return nil
  28013. case usagedetail.FieldType:
  28014. m.ResetType()
  28015. return nil
  28016. case usagedetail.FieldBotID:
  28017. m.ResetBotID()
  28018. return nil
  28019. case usagedetail.FieldReceiverID:
  28020. m.ResetReceiverID()
  28021. return nil
  28022. case usagedetail.FieldApp:
  28023. m.ResetApp()
  28024. return nil
  28025. case usagedetail.FieldSessionID:
  28026. m.ResetSessionID()
  28027. return nil
  28028. case usagedetail.FieldRequest:
  28029. m.ResetRequest()
  28030. return nil
  28031. case usagedetail.FieldResponse:
  28032. m.ResetResponse()
  28033. return nil
  28034. case usagedetail.FieldOriginalData:
  28035. m.ResetOriginalData()
  28036. return nil
  28037. case usagedetail.FieldTotalTokens:
  28038. m.ResetTotalTokens()
  28039. return nil
  28040. case usagedetail.FieldPromptTokens:
  28041. m.ResetPromptTokens()
  28042. return nil
  28043. case usagedetail.FieldCompletionTokens:
  28044. m.ResetCompletionTokens()
  28045. return nil
  28046. case usagedetail.FieldOrganizationID:
  28047. m.ResetOrganizationID()
  28048. return nil
  28049. }
  28050. return fmt.Errorf("unknown UsageDetail field %s", name)
  28051. }
  28052. // AddedEdges returns all edge names that were set/added in this mutation.
  28053. func (m *UsageDetailMutation) AddedEdges() []string {
  28054. edges := make([]string, 0, 0)
  28055. return edges
  28056. }
  28057. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28058. // name in this mutation.
  28059. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28060. return nil
  28061. }
  28062. // RemovedEdges returns all edge names that were removed in this mutation.
  28063. func (m *UsageDetailMutation) RemovedEdges() []string {
  28064. edges := make([]string, 0, 0)
  28065. return edges
  28066. }
  28067. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28068. // the given name in this mutation.
  28069. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28070. return nil
  28071. }
  28072. // ClearedEdges returns all edge names that were cleared in this mutation.
  28073. func (m *UsageDetailMutation) ClearedEdges() []string {
  28074. edges := make([]string, 0, 0)
  28075. return edges
  28076. }
  28077. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28078. // was cleared in this mutation.
  28079. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28080. return false
  28081. }
  28082. // ClearEdge clears the value of the edge with the given name. It returns an error
  28083. // if that edge is not defined in the schema.
  28084. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28085. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28086. }
  28087. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28088. // It returns an error if the edge is not defined in the schema.
  28089. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28090. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28091. }
  28092. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28093. type UsageStatisticDayMutation struct {
  28094. config
  28095. op Op
  28096. typ string
  28097. id *uint64
  28098. created_at *time.Time
  28099. updated_at *time.Time
  28100. status *uint8
  28101. addstatus *int8
  28102. deleted_at *time.Time
  28103. addtime *uint64
  28104. addaddtime *int64
  28105. _type *int
  28106. add_type *int
  28107. bot_id *string
  28108. organization_id *uint64
  28109. addorganization_id *int64
  28110. ai_response *uint64
  28111. addai_response *int64
  28112. sop_run *uint64
  28113. addsop_run *int64
  28114. total_friend *uint64
  28115. addtotal_friend *int64
  28116. total_group *uint64
  28117. addtotal_group *int64
  28118. account_balance *uint64
  28119. addaccount_balance *int64
  28120. consume_token *uint64
  28121. addconsume_token *int64
  28122. active_user *uint64
  28123. addactive_user *int64
  28124. new_user *int64
  28125. addnew_user *int64
  28126. label_dist *[]custom_types.LabelDist
  28127. appendlabel_dist []custom_types.LabelDist
  28128. clearedFields map[string]struct{}
  28129. done bool
  28130. oldValue func(context.Context) (*UsageStatisticDay, error)
  28131. predicates []predicate.UsageStatisticDay
  28132. }
  28133. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28134. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28135. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28136. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28137. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28138. m := &UsageStatisticDayMutation{
  28139. config: c,
  28140. op: op,
  28141. typ: TypeUsageStatisticDay,
  28142. clearedFields: make(map[string]struct{}),
  28143. }
  28144. for _, opt := range opts {
  28145. opt(m)
  28146. }
  28147. return m
  28148. }
  28149. // withUsageStatisticDayID sets the ID field of the mutation.
  28150. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28151. return func(m *UsageStatisticDayMutation) {
  28152. var (
  28153. err error
  28154. once sync.Once
  28155. value *UsageStatisticDay
  28156. )
  28157. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28158. once.Do(func() {
  28159. if m.done {
  28160. err = errors.New("querying old values post mutation is not allowed")
  28161. } else {
  28162. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28163. }
  28164. })
  28165. return value, err
  28166. }
  28167. m.id = &id
  28168. }
  28169. }
  28170. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28171. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28172. return func(m *UsageStatisticDayMutation) {
  28173. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28174. return node, nil
  28175. }
  28176. m.id = &node.ID
  28177. }
  28178. }
  28179. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28180. // executed in a transaction (ent.Tx), a transactional client is returned.
  28181. func (m UsageStatisticDayMutation) Client() *Client {
  28182. client := &Client{config: m.config}
  28183. client.init()
  28184. return client
  28185. }
  28186. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28187. // it returns an error otherwise.
  28188. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28189. if _, ok := m.driver.(*txDriver); !ok {
  28190. return nil, errors.New("ent: mutation is not running in a transaction")
  28191. }
  28192. tx := &Tx{config: m.config}
  28193. tx.init()
  28194. return tx, nil
  28195. }
  28196. // SetID sets the value of the id field. Note that this
  28197. // operation is only accepted on creation of UsageStatisticDay entities.
  28198. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28199. m.id = &id
  28200. }
  28201. // ID returns the ID value in the mutation. Note that the ID is only available
  28202. // if it was provided to the builder or after it was returned from the database.
  28203. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28204. if m.id == nil {
  28205. return
  28206. }
  28207. return *m.id, true
  28208. }
  28209. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28210. // That means, if the mutation is applied within a transaction with an isolation level such
  28211. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28212. // or updated by the mutation.
  28213. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28214. switch {
  28215. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28216. id, exists := m.ID()
  28217. if exists {
  28218. return []uint64{id}, nil
  28219. }
  28220. fallthrough
  28221. case m.op.Is(OpUpdate | OpDelete):
  28222. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28223. default:
  28224. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28225. }
  28226. }
  28227. // SetCreatedAt sets the "created_at" field.
  28228. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28229. m.created_at = &t
  28230. }
  28231. // CreatedAt returns the value of the "created_at" field in the mutation.
  28232. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28233. v := m.created_at
  28234. if v == nil {
  28235. return
  28236. }
  28237. return *v, true
  28238. }
  28239. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28240. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28242. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28243. if !m.op.Is(OpUpdateOne) {
  28244. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28245. }
  28246. if m.id == nil || m.oldValue == nil {
  28247. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28248. }
  28249. oldValue, err := m.oldValue(ctx)
  28250. if err != nil {
  28251. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28252. }
  28253. return oldValue.CreatedAt, nil
  28254. }
  28255. // ResetCreatedAt resets all changes to the "created_at" field.
  28256. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28257. m.created_at = nil
  28258. }
  28259. // SetUpdatedAt sets the "updated_at" field.
  28260. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28261. m.updated_at = &t
  28262. }
  28263. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28264. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28265. v := m.updated_at
  28266. if v == nil {
  28267. return
  28268. }
  28269. return *v, true
  28270. }
  28271. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28272. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28274. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28275. if !m.op.Is(OpUpdateOne) {
  28276. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28277. }
  28278. if m.id == nil || m.oldValue == nil {
  28279. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28280. }
  28281. oldValue, err := m.oldValue(ctx)
  28282. if err != nil {
  28283. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28284. }
  28285. return oldValue.UpdatedAt, nil
  28286. }
  28287. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28288. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28289. m.updated_at = nil
  28290. }
  28291. // SetStatus sets the "status" field.
  28292. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28293. m.status = &u
  28294. m.addstatus = nil
  28295. }
  28296. // Status returns the value of the "status" field in the mutation.
  28297. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28298. v := m.status
  28299. if v == nil {
  28300. return
  28301. }
  28302. return *v, true
  28303. }
  28304. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28305. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28307. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28308. if !m.op.Is(OpUpdateOne) {
  28309. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28310. }
  28311. if m.id == nil || m.oldValue == nil {
  28312. return v, errors.New("OldStatus requires an ID field in the mutation")
  28313. }
  28314. oldValue, err := m.oldValue(ctx)
  28315. if err != nil {
  28316. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28317. }
  28318. return oldValue.Status, nil
  28319. }
  28320. // AddStatus adds u to the "status" field.
  28321. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28322. if m.addstatus != nil {
  28323. *m.addstatus += u
  28324. } else {
  28325. m.addstatus = &u
  28326. }
  28327. }
  28328. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28329. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28330. v := m.addstatus
  28331. if v == nil {
  28332. return
  28333. }
  28334. return *v, true
  28335. }
  28336. // ClearStatus clears the value of the "status" field.
  28337. func (m *UsageStatisticDayMutation) ClearStatus() {
  28338. m.status = nil
  28339. m.addstatus = nil
  28340. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28341. }
  28342. // StatusCleared returns if the "status" field was cleared in this mutation.
  28343. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28344. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28345. return ok
  28346. }
  28347. // ResetStatus resets all changes to the "status" field.
  28348. func (m *UsageStatisticDayMutation) ResetStatus() {
  28349. m.status = nil
  28350. m.addstatus = nil
  28351. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28352. }
  28353. // SetDeletedAt sets the "deleted_at" field.
  28354. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28355. m.deleted_at = &t
  28356. }
  28357. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28358. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28359. v := m.deleted_at
  28360. if v == nil {
  28361. return
  28362. }
  28363. return *v, true
  28364. }
  28365. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28366. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28368. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28369. if !m.op.Is(OpUpdateOne) {
  28370. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28371. }
  28372. if m.id == nil || m.oldValue == nil {
  28373. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28374. }
  28375. oldValue, err := m.oldValue(ctx)
  28376. if err != nil {
  28377. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28378. }
  28379. return oldValue.DeletedAt, nil
  28380. }
  28381. // ClearDeletedAt clears the value of the "deleted_at" field.
  28382. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28383. m.deleted_at = nil
  28384. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28385. }
  28386. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28387. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28388. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28389. return ok
  28390. }
  28391. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28392. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28393. m.deleted_at = nil
  28394. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28395. }
  28396. // SetAddtime sets the "addtime" field.
  28397. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28398. m.addtime = &u
  28399. m.addaddtime = nil
  28400. }
  28401. // Addtime returns the value of the "addtime" field in the mutation.
  28402. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28403. v := m.addtime
  28404. if v == nil {
  28405. return
  28406. }
  28407. return *v, true
  28408. }
  28409. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28410. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28412. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28413. if !m.op.Is(OpUpdateOne) {
  28414. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28415. }
  28416. if m.id == nil || m.oldValue == nil {
  28417. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28418. }
  28419. oldValue, err := m.oldValue(ctx)
  28420. if err != nil {
  28421. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28422. }
  28423. return oldValue.Addtime, nil
  28424. }
  28425. // AddAddtime adds u to the "addtime" field.
  28426. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28427. if m.addaddtime != nil {
  28428. *m.addaddtime += u
  28429. } else {
  28430. m.addaddtime = &u
  28431. }
  28432. }
  28433. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28434. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28435. v := m.addaddtime
  28436. if v == nil {
  28437. return
  28438. }
  28439. return *v, true
  28440. }
  28441. // ResetAddtime resets all changes to the "addtime" field.
  28442. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28443. m.addtime = nil
  28444. m.addaddtime = nil
  28445. }
  28446. // SetType sets the "type" field.
  28447. func (m *UsageStatisticDayMutation) SetType(i int) {
  28448. m._type = &i
  28449. m.add_type = nil
  28450. }
  28451. // GetType returns the value of the "type" field in the mutation.
  28452. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28453. v := m._type
  28454. if v == nil {
  28455. return
  28456. }
  28457. return *v, true
  28458. }
  28459. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28460. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28462. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28463. if !m.op.Is(OpUpdateOne) {
  28464. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28465. }
  28466. if m.id == nil || m.oldValue == nil {
  28467. return v, errors.New("OldType requires an ID field in the mutation")
  28468. }
  28469. oldValue, err := m.oldValue(ctx)
  28470. if err != nil {
  28471. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28472. }
  28473. return oldValue.Type, nil
  28474. }
  28475. // AddType adds i to the "type" field.
  28476. func (m *UsageStatisticDayMutation) AddType(i int) {
  28477. if m.add_type != nil {
  28478. *m.add_type += i
  28479. } else {
  28480. m.add_type = &i
  28481. }
  28482. }
  28483. // AddedType returns the value that was added to the "type" field in this mutation.
  28484. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28485. v := m.add_type
  28486. if v == nil {
  28487. return
  28488. }
  28489. return *v, true
  28490. }
  28491. // ResetType resets all changes to the "type" field.
  28492. func (m *UsageStatisticDayMutation) ResetType() {
  28493. m._type = nil
  28494. m.add_type = nil
  28495. }
  28496. // SetBotID sets the "bot_id" field.
  28497. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28498. m.bot_id = &s
  28499. }
  28500. // BotID returns the value of the "bot_id" field in the mutation.
  28501. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28502. v := m.bot_id
  28503. if v == nil {
  28504. return
  28505. }
  28506. return *v, true
  28507. }
  28508. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28509. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28511. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28512. if !m.op.Is(OpUpdateOne) {
  28513. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28514. }
  28515. if m.id == nil || m.oldValue == nil {
  28516. return v, errors.New("OldBotID requires an ID field in the mutation")
  28517. }
  28518. oldValue, err := m.oldValue(ctx)
  28519. if err != nil {
  28520. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28521. }
  28522. return oldValue.BotID, nil
  28523. }
  28524. // ClearBotID clears the value of the "bot_id" field.
  28525. func (m *UsageStatisticDayMutation) ClearBotID() {
  28526. m.bot_id = nil
  28527. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28528. }
  28529. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28530. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28531. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28532. return ok
  28533. }
  28534. // ResetBotID resets all changes to the "bot_id" field.
  28535. func (m *UsageStatisticDayMutation) ResetBotID() {
  28536. m.bot_id = nil
  28537. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28538. }
  28539. // SetOrganizationID sets the "organization_id" field.
  28540. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28541. m.organization_id = &u
  28542. m.addorganization_id = nil
  28543. }
  28544. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28545. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28546. v := m.organization_id
  28547. if v == nil {
  28548. return
  28549. }
  28550. return *v, true
  28551. }
  28552. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28553. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28555. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28556. if !m.op.Is(OpUpdateOne) {
  28557. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28558. }
  28559. if m.id == nil || m.oldValue == nil {
  28560. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28561. }
  28562. oldValue, err := m.oldValue(ctx)
  28563. if err != nil {
  28564. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28565. }
  28566. return oldValue.OrganizationID, nil
  28567. }
  28568. // AddOrganizationID adds u to the "organization_id" field.
  28569. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28570. if m.addorganization_id != nil {
  28571. *m.addorganization_id += u
  28572. } else {
  28573. m.addorganization_id = &u
  28574. }
  28575. }
  28576. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28577. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28578. v := m.addorganization_id
  28579. if v == nil {
  28580. return
  28581. }
  28582. return *v, true
  28583. }
  28584. // ClearOrganizationID clears the value of the "organization_id" field.
  28585. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28586. m.organization_id = nil
  28587. m.addorganization_id = nil
  28588. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28589. }
  28590. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28591. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28592. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28593. return ok
  28594. }
  28595. // ResetOrganizationID resets all changes to the "organization_id" field.
  28596. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28597. m.organization_id = nil
  28598. m.addorganization_id = nil
  28599. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28600. }
  28601. // SetAiResponse sets the "ai_response" field.
  28602. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28603. m.ai_response = &u
  28604. m.addai_response = nil
  28605. }
  28606. // AiResponse returns the value of the "ai_response" field in the mutation.
  28607. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28608. v := m.ai_response
  28609. if v == nil {
  28610. return
  28611. }
  28612. return *v, true
  28613. }
  28614. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28615. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28617. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28618. if !m.op.Is(OpUpdateOne) {
  28619. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28620. }
  28621. if m.id == nil || m.oldValue == nil {
  28622. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28623. }
  28624. oldValue, err := m.oldValue(ctx)
  28625. if err != nil {
  28626. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28627. }
  28628. return oldValue.AiResponse, nil
  28629. }
  28630. // AddAiResponse adds u to the "ai_response" field.
  28631. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28632. if m.addai_response != nil {
  28633. *m.addai_response += u
  28634. } else {
  28635. m.addai_response = &u
  28636. }
  28637. }
  28638. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28639. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28640. v := m.addai_response
  28641. if v == nil {
  28642. return
  28643. }
  28644. return *v, true
  28645. }
  28646. // ResetAiResponse resets all changes to the "ai_response" field.
  28647. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28648. m.ai_response = nil
  28649. m.addai_response = nil
  28650. }
  28651. // SetSopRun sets the "sop_run" field.
  28652. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28653. m.sop_run = &u
  28654. m.addsop_run = nil
  28655. }
  28656. // SopRun returns the value of the "sop_run" field in the mutation.
  28657. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28658. v := m.sop_run
  28659. if v == nil {
  28660. return
  28661. }
  28662. return *v, true
  28663. }
  28664. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28665. // If the UsageStatisticDay 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 *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28668. if !m.op.Is(OpUpdateOne) {
  28669. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28670. }
  28671. if m.id == nil || m.oldValue == nil {
  28672. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  28677. }
  28678. return oldValue.SopRun, nil
  28679. }
  28680. // AddSopRun adds u to the "sop_run" field.
  28681. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28682. if m.addsop_run != nil {
  28683. *m.addsop_run += u
  28684. } else {
  28685. m.addsop_run = &u
  28686. }
  28687. }
  28688. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28689. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28690. v := m.addsop_run
  28691. if v == nil {
  28692. return
  28693. }
  28694. return *v, true
  28695. }
  28696. // ResetSopRun resets all changes to the "sop_run" field.
  28697. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28698. m.sop_run = nil
  28699. m.addsop_run = nil
  28700. }
  28701. // SetTotalFriend sets the "total_friend" field.
  28702. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28703. m.total_friend = &u
  28704. m.addtotal_friend = nil
  28705. }
  28706. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28707. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28708. v := m.total_friend
  28709. if v == nil {
  28710. return
  28711. }
  28712. return *v, true
  28713. }
  28714. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28715. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28717. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28718. if !m.op.Is(OpUpdateOne) {
  28719. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28720. }
  28721. if m.id == nil || m.oldValue == nil {
  28722. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28723. }
  28724. oldValue, err := m.oldValue(ctx)
  28725. if err != nil {
  28726. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28727. }
  28728. return oldValue.TotalFriend, nil
  28729. }
  28730. // AddTotalFriend adds u to the "total_friend" field.
  28731. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28732. if m.addtotal_friend != nil {
  28733. *m.addtotal_friend += u
  28734. } else {
  28735. m.addtotal_friend = &u
  28736. }
  28737. }
  28738. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28739. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28740. v := m.addtotal_friend
  28741. if v == nil {
  28742. return
  28743. }
  28744. return *v, true
  28745. }
  28746. // ResetTotalFriend resets all changes to the "total_friend" field.
  28747. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28748. m.total_friend = nil
  28749. m.addtotal_friend = nil
  28750. }
  28751. // SetTotalGroup sets the "total_group" field.
  28752. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28753. m.total_group = &u
  28754. m.addtotal_group = nil
  28755. }
  28756. // TotalGroup returns the value of the "total_group" field in the mutation.
  28757. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28758. v := m.total_group
  28759. if v == nil {
  28760. return
  28761. }
  28762. return *v, true
  28763. }
  28764. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28765. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28767. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28768. if !m.op.Is(OpUpdateOne) {
  28769. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28770. }
  28771. if m.id == nil || m.oldValue == nil {
  28772. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28773. }
  28774. oldValue, err := m.oldValue(ctx)
  28775. if err != nil {
  28776. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28777. }
  28778. return oldValue.TotalGroup, nil
  28779. }
  28780. // AddTotalGroup adds u to the "total_group" field.
  28781. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28782. if m.addtotal_group != nil {
  28783. *m.addtotal_group += u
  28784. } else {
  28785. m.addtotal_group = &u
  28786. }
  28787. }
  28788. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28789. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28790. v := m.addtotal_group
  28791. if v == nil {
  28792. return
  28793. }
  28794. return *v, true
  28795. }
  28796. // ResetTotalGroup resets all changes to the "total_group" field.
  28797. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28798. m.total_group = nil
  28799. m.addtotal_group = nil
  28800. }
  28801. // SetAccountBalance sets the "account_balance" field.
  28802. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28803. m.account_balance = &u
  28804. m.addaccount_balance = nil
  28805. }
  28806. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28807. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28808. v := m.account_balance
  28809. if v == nil {
  28810. return
  28811. }
  28812. return *v, true
  28813. }
  28814. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28815. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28817. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28818. if !m.op.Is(OpUpdateOne) {
  28819. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28820. }
  28821. if m.id == nil || m.oldValue == nil {
  28822. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28823. }
  28824. oldValue, err := m.oldValue(ctx)
  28825. if err != nil {
  28826. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28827. }
  28828. return oldValue.AccountBalance, nil
  28829. }
  28830. // AddAccountBalance adds u to the "account_balance" field.
  28831. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28832. if m.addaccount_balance != nil {
  28833. *m.addaccount_balance += u
  28834. } else {
  28835. m.addaccount_balance = &u
  28836. }
  28837. }
  28838. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28839. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28840. v := m.addaccount_balance
  28841. if v == nil {
  28842. return
  28843. }
  28844. return *v, true
  28845. }
  28846. // ResetAccountBalance resets all changes to the "account_balance" field.
  28847. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28848. m.account_balance = nil
  28849. m.addaccount_balance = nil
  28850. }
  28851. // SetConsumeToken sets the "consume_token" field.
  28852. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28853. m.consume_token = &u
  28854. m.addconsume_token = nil
  28855. }
  28856. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28857. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28858. v := m.consume_token
  28859. if v == nil {
  28860. return
  28861. }
  28862. return *v, true
  28863. }
  28864. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28865. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28867. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28868. if !m.op.Is(OpUpdateOne) {
  28869. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28870. }
  28871. if m.id == nil || m.oldValue == nil {
  28872. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28873. }
  28874. oldValue, err := m.oldValue(ctx)
  28875. if err != nil {
  28876. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28877. }
  28878. return oldValue.ConsumeToken, nil
  28879. }
  28880. // AddConsumeToken adds u to the "consume_token" field.
  28881. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28882. if m.addconsume_token != nil {
  28883. *m.addconsume_token += u
  28884. } else {
  28885. m.addconsume_token = &u
  28886. }
  28887. }
  28888. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28889. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28890. v := m.addconsume_token
  28891. if v == nil {
  28892. return
  28893. }
  28894. return *v, true
  28895. }
  28896. // ResetConsumeToken resets all changes to the "consume_token" field.
  28897. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28898. m.consume_token = nil
  28899. m.addconsume_token = nil
  28900. }
  28901. // SetActiveUser sets the "active_user" field.
  28902. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28903. m.active_user = &u
  28904. m.addactive_user = nil
  28905. }
  28906. // ActiveUser returns the value of the "active_user" field in the mutation.
  28907. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28908. v := m.active_user
  28909. if v == nil {
  28910. return
  28911. }
  28912. return *v, true
  28913. }
  28914. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28915. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28917. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28918. if !m.op.Is(OpUpdateOne) {
  28919. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28920. }
  28921. if m.id == nil || m.oldValue == nil {
  28922. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28923. }
  28924. oldValue, err := m.oldValue(ctx)
  28925. if err != nil {
  28926. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28927. }
  28928. return oldValue.ActiveUser, nil
  28929. }
  28930. // AddActiveUser adds u to the "active_user" field.
  28931. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28932. if m.addactive_user != nil {
  28933. *m.addactive_user += u
  28934. } else {
  28935. m.addactive_user = &u
  28936. }
  28937. }
  28938. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28939. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28940. v := m.addactive_user
  28941. if v == nil {
  28942. return
  28943. }
  28944. return *v, true
  28945. }
  28946. // ResetActiveUser resets all changes to the "active_user" field.
  28947. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28948. m.active_user = nil
  28949. m.addactive_user = nil
  28950. }
  28951. // SetNewUser sets the "new_user" field.
  28952. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28953. m.new_user = &i
  28954. m.addnew_user = nil
  28955. }
  28956. // NewUser returns the value of the "new_user" field in the mutation.
  28957. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28958. v := m.new_user
  28959. if v == nil {
  28960. return
  28961. }
  28962. return *v, true
  28963. }
  28964. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28965. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28967. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28968. if !m.op.Is(OpUpdateOne) {
  28969. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28970. }
  28971. if m.id == nil || m.oldValue == nil {
  28972. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28973. }
  28974. oldValue, err := m.oldValue(ctx)
  28975. if err != nil {
  28976. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28977. }
  28978. return oldValue.NewUser, nil
  28979. }
  28980. // AddNewUser adds i to the "new_user" field.
  28981. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28982. if m.addnew_user != nil {
  28983. *m.addnew_user += i
  28984. } else {
  28985. m.addnew_user = &i
  28986. }
  28987. }
  28988. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28989. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28990. v := m.addnew_user
  28991. if v == nil {
  28992. return
  28993. }
  28994. return *v, true
  28995. }
  28996. // ResetNewUser resets all changes to the "new_user" field.
  28997. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28998. m.new_user = nil
  28999. m.addnew_user = nil
  29000. }
  29001. // SetLabelDist sets the "label_dist" field.
  29002. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  29003. m.label_dist = &ctd
  29004. m.appendlabel_dist = nil
  29005. }
  29006. // LabelDist returns the value of the "label_dist" field in the mutation.
  29007. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  29008. v := m.label_dist
  29009. if v == nil {
  29010. return
  29011. }
  29012. return *v, true
  29013. }
  29014. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  29015. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29017. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29018. if !m.op.Is(OpUpdateOne) {
  29019. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29020. }
  29021. if m.id == nil || m.oldValue == nil {
  29022. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29023. }
  29024. oldValue, err := m.oldValue(ctx)
  29025. if err != nil {
  29026. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29027. }
  29028. return oldValue.LabelDist, nil
  29029. }
  29030. // AppendLabelDist adds ctd to the "label_dist" field.
  29031. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29032. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29033. }
  29034. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29035. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29036. if len(m.appendlabel_dist) == 0 {
  29037. return nil, false
  29038. }
  29039. return m.appendlabel_dist, true
  29040. }
  29041. // ResetLabelDist resets all changes to the "label_dist" field.
  29042. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29043. m.label_dist = nil
  29044. m.appendlabel_dist = nil
  29045. }
  29046. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29047. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29048. m.predicates = append(m.predicates, ps...)
  29049. }
  29050. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29051. // users can use type-assertion to append predicates that do not depend on any generated package.
  29052. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29053. p := make([]predicate.UsageStatisticDay, len(ps))
  29054. for i := range ps {
  29055. p[i] = ps[i]
  29056. }
  29057. m.Where(p...)
  29058. }
  29059. // Op returns the operation name.
  29060. func (m *UsageStatisticDayMutation) Op() Op {
  29061. return m.op
  29062. }
  29063. // SetOp allows setting the mutation operation.
  29064. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29065. m.op = op
  29066. }
  29067. // Type returns the node type of this mutation (UsageStatisticDay).
  29068. func (m *UsageStatisticDayMutation) Type() string {
  29069. return m.typ
  29070. }
  29071. // Fields returns all fields that were changed during this mutation. Note that in
  29072. // order to get all numeric fields that were incremented/decremented, call
  29073. // AddedFields().
  29074. func (m *UsageStatisticDayMutation) Fields() []string {
  29075. fields := make([]string, 0, 17)
  29076. if m.created_at != nil {
  29077. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29078. }
  29079. if m.updated_at != nil {
  29080. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29081. }
  29082. if m.status != nil {
  29083. fields = append(fields, usagestatisticday.FieldStatus)
  29084. }
  29085. if m.deleted_at != nil {
  29086. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29087. }
  29088. if m.addtime != nil {
  29089. fields = append(fields, usagestatisticday.FieldAddtime)
  29090. }
  29091. if m._type != nil {
  29092. fields = append(fields, usagestatisticday.FieldType)
  29093. }
  29094. if m.bot_id != nil {
  29095. fields = append(fields, usagestatisticday.FieldBotID)
  29096. }
  29097. if m.organization_id != nil {
  29098. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29099. }
  29100. if m.ai_response != nil {
  29101. fields = append(fields, usagestatisticday.FieldAiResponse)
  29102. }
  29103. if m.sop_run != nil {
  29104. fields = append(fields, usagestatisticday.FieldSopRun)
  29105. }
  29106. if m.total_friend != nil {
  29107. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29108. }
  29109. if m.total_group != nil {
  29110. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29111. }
  29112. if m.account_balance != nil {
  29113. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29114. }
  29115. if m.consume_token != nil {
  29116. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29117. }
  29118. if m.active_user != nil {
  29119. fields = append(fields, usagestatisticday.FieldActiveUser)
  29120. }
  29121. if m.new_user != nil {
  29122. fields = append(fields, usagestatisticday.FieldNewUser)
  29123. }
  29124. if m.label_dist != nil {
  29125. fields = append(fields, usagestatisticday.FieldLabelDist)
  29126. }
  29127. return fields
  29128. }
  29129. // Field returns the value of a field with the given name. The second boolean
  29130. // return value indicates that this field was not set, or was not defined in the
  29131. // schema.
  29132. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29133. switch name {
  29134. case usagestatisticday.FieldCreatedAt:
  29135. return m.CreatedAt()
  29136. case usagestatisticday.FieldUpdatedAt:
  29137. return m.UpdatedAt()
  29138. case usagestatisticday.FieldStatus:
  29139. return m.Status()
  29140. case usagestatisticday.FieldDeletedAt:
  29141. return m.DeletedAt()
  29142. case usagestatisticday.FieldAddtime:
  29143. return m.Addtime()
  29144. case usagestatisticday.FieldType:
  29145. return m.GetType()
  29146. case usagestatisticday.FieldBotID:
  29147. return m.BotID()
  29148. case usagestatisticday.FieldOrganizationID:
  29149. return m.OrganizationID()
  29150. case usagestatisticday.FieldAiResponse:
  29151. return m.AiResponse()
  29152. case usagestatisticday.FieldSopRun:
  29153. return m.SopRun()
  29154. case usagestatisticday.FieldTotalFriend:
  29155. return m.TotalFriend()
  29156. case usagestatisticday.FieldTotalGroup:
  29157. return m.TotalGroup()
  29158. case usagestatisticday.FieldAccountBalance:
  29159. return m.AccountBalance()
  29160. case usagestatisticday.FieldConsumeToken:
  29161. return m.ConsumeToken()
  29162. case usagestatisticday.FieldActiveUser:
  29163. return m.ActiveUser()
  29164. case usagestatisticday.FieldNewUser:
  29165. return m.NewUser()
  29166. case usagestatisticday.FieldLabelDist:
  29167. return m.LabelDist()
  29168. }
  29169. return nil, false
  29170. }
  29171. // OldField returns the old value of the field from the database. An error is
  29172. // returned if the mutation operation is not UpdateOne, or the query to the
  29173. // database failed.
  29174. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29175. switch name {
  29176. case usagestatisticday.FieldCreatedAt:
  29177. return m.OldCreatedAt(ctx)
  29178. case usagestatisticday.FieldUpdatedAt:
  29179. return m.OldUpdatedAt(ctx)
  29180. case usagestatisticday.FieldStatus:
  29181. return m.OldStatus(ctx)
  29182. case usagestatisticday.FieldDeletedAt:
  29183. return m.OldDeletedAt(ctx)
  29184. case usagestatisticday.FieldAddtime:
  29185. return m.OldAddtime(ctx)
  29186. case usagestatisticday.FieldType:
  29187. return m.OldType(ctx)
  29188. case usagestatisticday.FieldBotID:
  29189. return m.OldBotID(ctx)
  29190. case usagestatisticday.FieldOrganizationID:
  29191. return m.OldOrganizationID(ctx)
  29192. case usagestatisticday.FieldAiResponse:
  29193. return m.OldAiResponse(ctx)
  29194. case usagestatisticday.FieldSopRun:
  29195. return m.OldSopRun(ctx)
  29196. case usagestatisticday.FieldTotalFriend:
  29197. return m.OldTotalFriend(ctx)
  29198. case usagestatisticday.FieldTotalGroup:
  29199. return m.OldTotalGroup(ctx)
  29200. case usagestatisticday.FieldAccountBalance:
  29201. return m.OldAccountBalance(ctx)
  29202. case usagestatisticday.FieldConsumeToken:
  29203. return m.OldConsumeToken(ctx)
  29204. case usagestatisticday.FieldActiveUser:
  29205. return m.OldActiveUser(ctx)
  29206. case usagestatisticday.FieldNewUser:
  29207. return m.OldNewUser(ctx)
  29208. case usagestatisticday.FieldLabelDist:
  29209. return m.OldLabelDist(ctx)
  29210. }
  29211. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29212. }
  29213. // SetField sets the value of a field with the given name. It returns an error if
  29214. // the field is not defined in the schema, or if the type mismatched the field
  29215. // type.
  29216. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29217. switch name {
  29218. case usagestatisticday.FieldCreatedAt:
  29219. v, ok := value.(time.Time)
  29220. if !ok {
  29221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29222. }
  29223. m.SetCreatedAt(v)
  29224. return nil
  29225. case usagestatisticday.FieldUpdatedAt:
  29226. v, ok := value.(time.Time)
  29227. if !ok {
  29228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29229. }
  29230. m.SetUpdatedAt(v)
  29231. return nil
  29232. case usagestatisticday.FieldStatus:
  29233. v, ok := value.(uint8)
  29234. if !ok {
  29235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29236. }
  29237. m.SetStatus(v)
  29238. return nil
  29239. case usagestatisticday.FieldDeletedAt:
  29240. v, ok := value.(time.Time)
  29241. if !ok {
  29242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29243. }
  29244. m.SetDeletedAt(v)
  29245. return nil
  29246. case usagestatisticday.FieldAddtime:
  29247. v, ok := value.(uint64)
  29248. if !ok {
  29249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29250. }
  29251. m.SetAddtime(v)
  29252. return nil
  29253. case usagestatisticday.FieldType:
  29254. v, ok := value.(int)
  29255. if !ok {
  29256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29257. }
  29258. m.SetType(v)
  29259. return nil
  29260. case usagestatisticday.FieldBotID:
  29261. v, ok := value.(string)
  29262. if !ok {
  29263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29264. }
  29265. m.SetBotID(v)
  29266. return nil
  29267. case usagestatisticday.FieldOrganizationID:
  29268. v, ok := value.(uint64)
  29269. if !ok {
  29270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29271. }
  29272. m.SetOrganizationID(v)
  29273. return nil
  29274. case usagestatisticday.FieldAiResponse:
  29275. v, ok := value.(uint64)
  29276. if !ok {
  29277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29278. }
  29279. m.SetAiResponse(v)
  29280. return nil
  29281. case usagestatisticday.FieldSopRun:
  29282. v, ok := value.(uint64)
  29283. if !ok {
  29284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29285. }
  29286. m.SetSopRun(v)
  29287. return nil
  29288. case usagestatisticday.FieldTotalFriend:
  29289. v, ok := value.(uint64)
  29290. if !ok {
  29291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29292. }
  29293. m.SetTotalFriend(v)
  29294. return nil
  29295. case usagestatisticday.FieldTotalGroup:
  29296. v, ok := value.(uint64)
  29297. if !ok {
  29298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29299. }
  29300. m.SetTotalGroup(v)
  29301. return nil
  29302. case usagestatisticday.FieldAccountBalance:
  29303. v, ok := value.(uint64)
  29304. if !ok {
  29305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29306. }
  29307. m.SetAccountBalance(v)
  29308. return nil
  29309. case usagestatisticday.FieldConsumeToken:
  29310. v, ok := value.(uint64)
  29311. if !ok {
  29312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29313. }
  29314. m.SetConsumeToken(v)
  29315. return nil
  29316. case usagestatisticday.FieldActiveUser:
  29317. v, ok := value.(uint64)
  29318. if !ok {
  29319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29320. }
  29321. m.SetActiveUser(v)
  29322. return nil
  29323. case usagestatisticday.FieldNewUser:
  29324. v, ok := value.(int64)
  29325. if !ok {
  29326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29327. }
  29328. m.SetNewUser(v)
  29329. return nil
  29330. case usagestatisticday.FieldLabelDist:
  29331. v, ok := value.([]custom_types.LabelDist)
  29332. if !ok {
  29333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29334. }
  29335. m.SetLabelDist(v)
  29336. return nil
  29337. }
  29338. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29339. }
  29340. // AddedFields returns all numeric fields that were incremented/decremented during
  29341. // this mutation.
  29342. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29343. var fields []string
  29344. if m.addstatus != nil {
  29345. fields = append(fields, usagestatisticday.FieldStatus)
  29346. }
  29347. if m.addaddtime != nil {
  29348. fields = append(fields, usagestatisticday.FieldAddtime)
  29349. }
  29350. if m.add_type != nil {
  29351. fields = append(fields, usagestatisticday.FieldType)
  29352. }
  29353. if m.addorganization_id != nil {
  29354. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29355. }
  29356. if m.addai_response != nil {
  29357. fields = append(fields, usagestatisticday.FieldAiResponse)
  29358. }
  29359. if m.addsop_run != nil {
  29360. fields = append(fields, usagestatisticday.FieldSopRun)
  29361. }
  29362. if m.addtotal_friend != nil {
  29363. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29364. }
  29365. if m.addtotal_group != nil {
  29366. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29367. }
  29368. if m.addaccount_balance != nil {
  29369. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29370. }
  29371. if m.addconsume_token != nil {
  29372. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29373. }
  29374. if m.addactive_user != nil {
  29375. fields = append(fields, usagestatisticday.FieldActiveUser)
  29376. }
  29377. if m.addnew_user != nil {
  29378. fields = append(fields, usagestatisticday.FieldNewUser)
  29379. }
  29380. return fields
  29381. }
  29382. // AddedField returns the numeric value that was incremented/decremented on a field
  29383. // with the given name. The second boolean return value indicates that this field
  29384. // was not set, or was not defined in the schema.
  29385. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29386. switch name {
  29387. case usagestatisticday.FieldStatus:
  29388. return m.AddedStatus()
  29389. case usagestatisticday.FieldAddtime:
  29390. return m.AddedAddtime()
  29391. case usagestatisticday.FieldType:
  29392. return m.AddedType()
  29393. case usagestatisticday.FieldOrganizationID:
  29394. return m.AddedOrganizationID()
  29395. case usagestatisticday.FieldAiResponse:
  29396. return m.AddedAiResponse()
  29397. case usagestatisticday.FieldSopRun:
  29398. return m.AddedSopRun()
  29399. case usagestatisticday.FieldTotalFriend:
  29400. return m.AddedTotalFriend()
  29401. case usagestatisticday.FieldTotalGroup:
  29402. return m.AddedTotalGroup()
  29403. case usagestatisticday.FieldAccountBalance:
  29404. return m.AddedAccountBalance()
  29405. case usagestatisticday.FieldConsumeToken:
  29406. return m.AddedConsumeToken()
  29407. case usagestatisticday.FieldActiveUser:
  29408. return m.AddedActiveUser()
  29409. case usagestatisticday.FieldNewUser:
  29410. return m.AddedNewUser()
  29411. }
  29412. return nil, false
  29413. }
  29414. // AddField adds the value to the field with the given name. It returns an error if
  29415. // the field is not defined in the schema, or if the type mismatched the field
  29416. // type.
  29417. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29418. switch name {
  29419. case usagestatisticday.FieldStatus:
  29420. v, ok := value.(int8)
  29421. if !ok {
  29422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29423. }
  29424. m.AddStatus(v)
  29425. return nil
  29426. case usagestatisticday.FieldAddtime:
  29427. v, ok := value.(int64)
  29428. if !ok {
  29429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29430. }
  29431. m.AddAddtime(v)
  29432. return nil
  29433. case usagestatisticday.FieldType:
  29434. v, ok := value.(int)
  29435. if !ok {
  29436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29437. }
  29438. m.AddType(v)
  29439. return nil
  29440. case usagestatisticday.FieldOrganizationID:
  29441. v, ok := value.(int64)
  29442. if !ok {
  29443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29444. }
  29445. m.AddOrganizationID(v)
  29446. return nil
  29447. case usagestatisticday.FieldAiResponse:
  29448. v, ok := value.(int64)
  29449. if !ok {
  29450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29451. }
  29452. m.AddAiResponse(v)
  29453. return nil
  29454. case usagestatisticday.FieldSopRun:
  29455. v, ok := value.(int64)
  29456. if !ok {
  29457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29458. }
  29459. m.AddSopRun(v)
  29460. return nil
  29461. case usagestatisticday.FieldTotalFriend:
  29462. v, ok := value.(int64)
  29463. if !ok {
  29464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29465. }
  29466. m.AddTotalFriend(v)
  29467. return nil
  29468. case usagestatisticday.FieldTotalGroup:
  29469. v, ok := value.(int64)
  29470. if !ok {
  29471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29472. }
  29473. m.AddTotalGroup(v)
  29474. return nil
  29475. case usagestatisticday.FieldAccountBalance:
  29476. v, ok := value.(int64)
  29477. if !ok {
  29478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29479. }
  29480. m.AddAccountBalance(v)
  29481. return nil
  29482. case usagestatisticday.FieldConsumeToken:
  29483. v, ok := value.(int64)
  29484. if !ok {
  29485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29486. }
  29487. m.AddConsumeToken(v)
  29488. return nil
  29489. case usagestatisticday.FieldActiveUser:
  29490. v, ok := value.(int64)
  29491. if !ok {
  29492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29493. }
  29494. m.AddActiveUser(v)
  29495. return nil
  29496. case usagestatisticday.FieldNewUser:
  29497. v, ok := value.(int64)
  29498. if !ok {
  29499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29500. }
  29501. m.AddNewUser(v)
  29502. return nil
  29503. }
  29504. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29505. }
  29506. // ClearedFields returns all nullable fields that were cleared during this
  29507. // mutation.
  29508. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29509. var fields []string
  29510. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29511. fields = append(fields, usagestatisticday.FieldStatus)
  29512. }
  29513. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29514. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29515. }
  29516. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29517. fields = append(fields, usagestatisticday.FieldBotID)
  29518. }
  29519. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29520. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29521. }
  29522. return fields
  29523. }
  29524. // FieldCleared returns a boolean indicating if a field with the given name was
  29525. // cleared in this mutation.
  29526. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29527. _, ok := m.clearedFields[name]
  29528. return ok
  29529. }
  29530. // ClearField clears the value of the field with the given name. It returns an
  29531. // error if the field is not defined in the schema.
  29532. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29533. switch name {
  29534. case usagestatisticday.FieldStatus:
  29535. m.ClearStatus()
  29536. return nil
  29537. case usagestatisticday.FieldDeletedAt:
  29538. m.ClearDeletedAt()
  29539. return nil
  29540. case usagestatisticday.FieldBotID:
  29541. m.ClearBotID()
  29542. return nil
  29543. case usagestatisticday.FieldOrganizationID:
  29544. m.ClearOrganizationID()
  29545. return nil
  29546. }
  29547. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29548. }
  29549. // ResetField resets all changes in the mutation for the field with the given name.
  29550. // It returns an error if the field is not defined in the schema.
  29551. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29552. switch name {
  29553. case usagestatisticday.FieldCreatedAt:
  29554. m.ResetCreatedAt()
  29555. return nil
  29556. case usagestatisticday.FieldUpdatedAt:
  29557. m.ResetUpdatedAt()
  29558. return nil
  29559. case usagestatisticday.FieldStatus:
  29560. m.ResetStatus()
  29561. return nil
  29562. case usagestatisticday.FieldDeletedAt:
  29563. m.ResetDeletedAt()
  29564. return nil
  29565. case usagestatisticday.FieldAddtime:
  29566. m.ResetAddtime()
  29567. return nil
  29568. case usagestatisticday.FieldType:
  29569. m.ResetType()
  29570. return nil
  29571. case usagestatisticday.FieldBotID:
  29572. m.ResetBotID()
  29573. return nil
  29574. case usagestatisticday.FieldOrganizationID:
  29575. m.ResetOrganizationID()
  29576. return nil
  29577. case usagestatisticday.FieldAiResponse:
  29578. m.ResetAiResponse()
  29579. return nil
  29580. case usagestatisticday.FieldSopRun:
  29581. m.ResetSopRun()
  29582. return nil
  29583. case usagestatisticday.FieldTotalFriend:
  29584. m.ResetTotalFriend()
  29585. return nil
  29586. case usagestatisticday.FieldTotalGroup:
  29587. m.ResetTotalGroup()
  29588. return nil
  29589. case usagestatisticday.FieldAccountBalance:
  29590. m.ResetAccountBalance()
  29591. return nil
  29592. case usagestatisticday.FieldConsumeToken:
  29593. m.ResetConsumeToken()
  29594. return nil
  29595. case usagestatisticday.FieldActiveUser:
  29596. m.ResetActiveUser()
  29597. return nil
  29598. case usagestatisticday.FieldNewUser:
  29599. m.ResetNewUser()
  29600. return nil
  29601. case usagestatisticday.FieldLabelDist:
  29602. m.ResetLabelDist()
  29603. return nil
  29604. }
  29605. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29606. }
  29607. // AddedEdges returns all edge names that were set/added in this mutation.
  29608. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29609. edges := make([]string, 0, 0)
  29610. return edges
  29611. }
  29612. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29613. // name in this mutation.
  29614. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29615. return nil
  29616. }
  29617. // RemovedEdges returns all edge names that were removed in this mutation.
  29618. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29619. edges := make([]string, 0, 0)
  29620. return edges
  29621. }
  29622. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29623. // the given name in this mutation.
  29624. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29625. return nil
  29626. }
  29627. // ClearedEdges returns all edge names that were cleared in this mutation.
  29628. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29629. edges := make([]string, 0, 0)
  29630. return edges
  29631. }
  29632. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29633. // was cleared in this mutation.
  29634. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29635. return false
  29636. }
  29637. // ClearEdge clears the value of the edge with the given name. It returns an error
  29638. // if that edge is not defined in the schema.
  29639. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29640. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29641. }
  29642. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29643. // It returns an error if the edge is not defined in the schema.
  29644. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29645. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29646. }
  29647. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29648. type UsageStatisticHourMutation struct {
  29649. config
  29650. op Op
  29651. typ string
  29652. id *uint64
  29653. created_at *time.Time
  29654. updated_at *time.Time
  29655. status *uint8
  29656. addstatus *int8
  29657. deleted_at *time.Time
  29658. addtime *uint64
  29659. addaddtime *int64
  29660. _type *int
  29661. add_type *int
  29662. bot_id *string
  29663. organization_id *uint64
  29664. addorganization_id *int64
  29665. ai_response *uint64
  29666. addai_response *int64
  29667. sop_run *uint64
  29668. addsop_run *int64
  29669. total_friend *uint64
  29670. addtotal_friend *int64
  29671. total_group *uint64
  29672. addtotal_group *int64
  29673. account_balance *uint64
  29674. addaccount_balance *int64
  29675. consume_token *uint64
  29676. addconsume_token *int64
  29677. active_user *uint64
  29678. addactive_user *int64
  29679. new_user *int64
  29680. addnew_user *int64
  29681. label_dist *[]custom_types.LabelDist
  29682. appendlabel_dist []custom_types.LabelDist
  29683. clearedFields map[string]struct{}
  29684. done bool
  29685. oldValue func(context.Context) (*UsageStatisticHour, error)
  29686. predicates []predicate.UsageStatisticHour
  29687. }
  29688. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29689. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29690. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29691. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29692. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29693. m := &UsageStatisticHourMutation{
  29694. config: c,
  29695. op: op,
  29696. typ: TypeUsageStatisticHour,
  29697. clearedFields: make(map[string]struct{}),
  29698. }
  29699. for _, opt := range opts {
  29700. opt(m)
  29701. }
  29702. return m
  29703. }
  29704. // withUsageStatisticHourID sets the ID field of the mutation.
  29705. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29706. return func(m *UsageStatisticHourMutation) {
  29707. var (
  29708. err error
  29709. once sync.Once
  29710. value *UsageStatisticHour
  29711. )
  29712. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29713. once.Do(func() {
  29714. if m.done {
  29715. err = errors.New("querying old values post mutation is not allowed")
  29716. } else {
  29717. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29718. }
  29719. })
  29720. return value, err
  29721. }
  29722. m.id = &id
  29723. }
  29724. }
  29725. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29726. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29727. return func(m *UsageStatisticHourMutation) {
  29728. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29729. return node, nil
  29730. }
  29731. m.id = &node.ID
  29732. }
  29733. }
  29734. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29735. // executed in a transaction (ent.Tx), a transactional client is returned.
  29736. func (m UsageStatisticHourMutation) Client() *Client {
  29737. client := &Client{config: m.config}
  29738. client.init()
  29739. return client
  29740. }
  29741. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29742. // it returns an error otherwise.
  29743. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29744. if _, ok := m.driver.(*txDriver); !ok {
  29745. return nil, errors.New("ent: mutation is not running in a transaction")
  29746. }
  29747. tx := &Tx{config: m.config}
  29748. tx.init()
  29749. return tx, nil
  29750. }
  29751. // SetID sets the value of the id field. Note that this
  29752. // operation is only accepted on creation of UsageStatisticHour entities.
  29753. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29754. m.id = &id
  29755. }
  29756. // ID returns the ID value in the mutation. Note that the ID is only available
  29757. // if it was provided to the builder or after it was returned from the database.
  29758. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29759. if m.id == nil {
  29760. return
  29761. }
  29762. return *m.id, true
  29763. }
  29764. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29765. // That means, if the mutation is applied within a transaction with an isolation level such
  29766. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29767. // or updated by the mutation.
  29768. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29769. switch {
  29770. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29771. id, exists := m.ID()
  29772. if exists {
  29773. return []uint64{id}, nil
  29774. }
  29775. fallthrough
  29776. case m.op.Is(OpUpdate | OpDelete):
  29777. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29778. default:
  29779. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29780. }
  29781. }
  29782. // SetCreatedAt sets the "created_at" field.
  29783. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29784. m.created_at = &t
  29785. }
  29786. // CreatedAt returns the value of the "created_at" field in the mutation.
  29787. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29788. v := m.created_at
  29789. if v == nil {
  29790. return
  29791. }
  29792. return *v, true
  29793. }
  29794. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29795. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29797. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29798. if !m.op.Is(OpUpdateOne) {
  29799. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29800. }
  29801. if m.id == nil || m.oldValue == nil {
  29802. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29803. }
  29804. oldValue, err := m.oldValue(ctx)
  29805. if err != nil {
  29806. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29807. }
  29808. return oldValue.CreatedAt, nil
  29809. }
  29810. // ResetCreatedAt resets all changes to the "created_at" field.
  29811. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29812. m.created_at = nil
  29813. }
  29814. // SetUpdatedAt sets the "updated_at" field.
  29815. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29816. m.updated_at = &t
  29817. }
  29818. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29819. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29820. v := m.updated_at
  29821. if v == nil {
  29822. return
  29823. }
  29824. return *v, true
  29825. }
  29826. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29827. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29829. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29830. if !m.op.Is(OpUpdateOne) {
  29831. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29832. }
  29833. if m.id == nil || m.oldValue == nil {
  29834. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29835. }
  29836. oldValue, err := m.oldValue(ctx)
  29837. if err != nil {
  29838. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29839. }
  29840. return oldValue.UpdatedAt, nil
  29841. }
  29842. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29843. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29844. m.updated_at = nil
  29845. }
  29846. // SetStatus sets the "status" field.
  29847. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29848. m.status = &u
  29849. m.addstatus = nil
  29850. }
  29851. // Status returns the value of the "status" field in the mutation.
  29852. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29853. v := m.status
  29854. if v == nil {
  29855. return
  29856. }
  29857. return *v, true
  29858. }
  29859. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29860. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29862. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29863. if !m.op.Is(OpUpdateOne) {
  29864. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29865. }
  29866. if m.id == nil || m.oldValue == nil {
  29867. return v, errors.New("OldStatus requires an ID field in the mutation")
  29868. }
  29869. oldValue, err := m.oldValue(ctx)
  29870. if err != nil {
  29871. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29872. }
  29873. return oldValue.Status, nil
  29874. }
  29875. // AddStatus adds u to the "status" field.
  29876. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29877. if m.addstatus != nil {
  29878. *m.addstatus += u
  29879. } else {
  29880. m.addstatus = &u
  29881. }
  29882. }
  29883. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29884. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29885. v := m.addstatus
  29886. if v == nil {
  29887. return
  29888. }
  29889. return *v, true
  29890. }
  29891. // ClearStatus clears the value of the "status" field.
  29892. func (m *UsageStatisticHourMutation) ClearStatus() {
  29893. m.status = nil
  29894. m.addstatus = nil
  29895. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29896. }
  29897. // StatusCleared returns if the "status" field was cleared in this mutation.
  29898. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29899. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29900. return ok
  29901. }
  29902. // ResetStatus resets all changes to the "status" field.
  29903. func (m *UsageStatisticHourMutation) ResetStatus() {
  29904. m.status = nil
  29905. m.addstatus = nil
  29906. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29907. }
  29908. // SetDeletedAt sets the "deleted_at" field.
  29909. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29910. m.deleted_at = &t
  29911. }
  29912. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29913. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29914. v := m.deleted_at
  29915. if v == nil {
  29916. return
  29917. }
  29918. return *v, true
  29919. }
  29920. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29921. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29923. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29924. if !m.op.Is(OpUpdateOne) {
  29925. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29926. }
  29927. if m.id == nil || m.oldValue == nil {
  29928. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29929. }
  29930. oldValue, err := m.oldValue(ctx)
  29931. if err != nil {
  29932. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29933. }
  29934. return oldValue.DeletedAt, nil
  29935. }
  29936. // ClearDeletedAt clears the value of the "deleted_at" field.
  29937. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29938. m.deleted_at = nil
  29939. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29940. }
  29941. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29942. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29943. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29944. return ok
  29945. }
  29946. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29947. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29948. m.deleted_at = nil
  29949. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29950. }
  29951. // SetAddtime sets the "addtime" field.
  29952. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29953. m.addtime = &u
  29954. m.addaddtime = nil
  29955. }
  29956. // Addtime returns the value of the "addtime" field in the mutation.
  29957. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29958. v := m.addtime
  29959. if v == nil {
  29960. return
  29961. }
  29962. return *v, true
  29963. }
  29964. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29965. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29967. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29968. if !m.op.Is(OpUpdateOne) {
  29969. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29970. }
  29971. if m.id == nil || m.oldValue == nil {
  29972. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29973. }
  29974. oldValue, err := m.oldValue(ctx)
  29975. if err != nil {
  29976. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29977. }
  29978. return oldValue.Addtime, nil
  29979. }
  29980. // AddAddtime adds u to the "addtime" field.
  29981. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29982. if m.addaddtime != nil {
  29983. *m.addaddtime += u
  29984. } else {
  29985. m.addaddtime = &u
  29986. }
  29987. }
  29988. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29989. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29990. v := m.addaddtime
  29991. if v == nil {
  29992. return
  29993. }
  29994. return *v, true
  29995. }
  29996. // ResetAddtime resets all changes to the "addtime" field.
  29997. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29998. m.addtime = nil
  29999. m.addaddtime = nil
  30000. }
  30001. // SetType sets the "type" field.
  30002. func (m *UsageStatisticHourMutation) SetType(i int) {
  30003. m._type = &i
  30004. m.add_type = nil
  30005. }
  30006. // GetType returns the value of the "type" field in the mutation.
  30007. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  30008. v := m._type
  30009. if v == nil {
  30010. return
  30011. }
  30012. return *v, true
  30013. }
  30014. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  30015. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30017. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  30018. if !m.op.Is(OpUpdateOne) {
  30019. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30020. }
  30021. if m.id == nil || m.oldValue == nil {
  30022. return v, errors.New("OldType requires an ID field in the mutation")
  30023. }
  30024. oldValue, err := m.oldValue(ctx)
  30025. if err != nil {
  30026. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30027. }
  30028. return oldValue.Type, nil
  30029. }
  30030. // AddType adds i to the "type" field.
  30031. func (m *UsageStatisticHourMutation) AddType(i int) {
  30032. if m.add_type != nil {
  30033. *m.add_type += i
  30034. } else {
  30035. m.add_type = &i
  30036. }
  30037. }
  30038. // AddedType returns the value that was added to the "type" field in this mutation.
  30039. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30040. v := m.add_type
  30041. if v == nil {
  30042. return
  30043. }
  30044. return *v, true
  30045. }
  30046. // ResetType resets all changes to the "type" field.
  30047. func (m *UsageStatisticHourMutation) ResetType() {
  30048. m._type = nil
  30049. m.add_type = nil
  30050. }
  30051. // SetBotID sets the "bot_id" field.
  30052. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30053. m.bot_id = &s
  30054. }
  30055. // BotID returns the value of the "bot_id" field in the mutation.
  30056. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30057. v := m.bot_id
  30058. if v == nil {
  30059. return
  30060. }
  30061. return *v, true
  30062. }
  30063. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30064. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30066. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30067. if !m.op.Is(OpUpdateOne) {
  30068. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30069. }
  30070. if m.id == nil || m.oldValue == nil {
  30071. return v, errors.New("OldBotID requires an ID field in the mutation")
  30072. }
  30073. oldValue, err := m.oldValue(ctx)
  30074. if err != nil {
  30075. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30076. }
  30077. return oldValue.BotID, nil
  30078. }
  30079. // ClearBotID clears the value of the "bot_id" field.
  30080. func (m *UsageStatisticHourMutation) ClearBotID() {
  30081. m.bot_id = nil
  30082. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30083. }
  30084. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30085. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30086. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30087. return ok
  30088. }
  30089. // ResetBotID resets all changes to the "bot_id" field.
  30090. func (m *UsageStatisticHourMutation) ResetBotID() {
  30091. m.bot_id = nil
  30092. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30093. }
  30094. // SetOrganizationID sets the "organization_id" field.
  30095. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30096. m.organization_id = &u
  30097. m.addorganization_id = nil
  30098. }
  30099. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30100. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30101. v := m.organization_id
  30102. if v == nil {
  30103. return
  30104. }
  30105. return *v, true
  30106. }
  30107. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30108. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30110. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30111. if !m.op.Is(OpUpdateOne) {
  30112. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30113. }
  30114. if m.id == nil || m.oldValue == nil {
  30115. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30116. }
  30117. oldValue, err := m.oldValue(ctx)
  30118. if err != nil {
  30119. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30120. }
  30121. return oldValue.OrganizationID, nil
  30122. }
  30123. // AddOrganizationID adds u to the "organization_id" field.
  30124. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30125. if m.addorganization_id != nil {
  30126. *m.addorganization_id += u
  30127. } else {
  30128. m.addorganization_id = &u
  30129. }
  30130. }
  30131. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30132. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30133. v := m.addorganization_id
  30134. if v == nil {
  30135. return
  30136. }
  30137. return *v, true
  30138. }
  30139. // ClearOrganizationID clears the value of the "organization_id" field.
  30140. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30141. m.organization_id = nil
  30142. m.addorganization_id = nil
  30143. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30144. }
  30145. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30146. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30147. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30148. return ok
  30149. }
  30150. // ResetOrganizationID resets all changes to the "organization_id" field.
  30151. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30152. m.organization_id = nil
  30153. m.addorganization_id = nil
  30154. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30155. }
  30156. // SetAiResponse sets the "ai_response" field.
  30157. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30158. m.ai_response = &u
  30159. m.addai_response = nil
  30160. }
  30161. // AiResponse returns the value of the "ai_response" field in the mutation.
  30162. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30163. v := m.ai_response
  30164. if v == nil {
  30165. return
  30166. }
  30167. return *v, true
  30168. }
  30169. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30170. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30172. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30173. if !m.op.Is(OpUpdateOne) {
  30174. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30175. }
  30176. if m.id == nil || m.oldValue == nil {
  30177. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30178. }
  30179. oldValue, err := m.oldValue(ctx)
  30180. if err != nil {
  30181. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30182. }
  30183. return oldValue.AiResponse, nil
  30184. }
  30185. // AddAiResponse adds u to the "ai_response" field.
  30186. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30187. if m.addai_response != nil {
  30188. *m.addai_response += u
  30189. } else {
  30190. m.addai_response = &u
  30191. }
  30192. }
  30193. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30194. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30195. v := m.addai_response
  30196. if v == nil {
  30197. return
  30198. }
  30199. return *v, true
  30200. }
  30201. // ResetAiResponse resets all changes to the "ai_response" field.
  30202. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30203. m.ai_response = nil
  30204. m.addai_response = nil
  30205. }
  30206. // SetSopRun sets the "sop_run" field.
  30207. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30208. m.sop_run = &u
  30209. m.addsop_run = nil
  30210. }
  30211. // SopRun returns the value of the "sop_run" field in the mutation.
  30212. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30213. v := m.sop_run
  30214. if v == nil {
  30215. return
  30216. }
  30217. return *v, true
  30218. }
  30219. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30220. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30222. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30223. if !m.op.Is(OpUpdateOne) {
  30224. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30225. }
  30226. if m.id == nil || m.oldValue == nil {
  30227. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30228. }
  30229. oldValue, err := m.oldValue(ctx)
  30230. if err != nil {
  30231. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30232. }
  30233. return oldValue.SopRun, nil
  30234. }
  30235. // AddSopRun adds u to the "sop_run" field.
  30236. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30237. if m.addsop_run != nil {
  30238. *m.addsop_run += u
  30239. } else {
  30240. m.addsop_run = &u
  30241. }
  30242. }
  30243. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30244. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30245. v := m.addsop_run
  30246. if v == nil {
  30247. return
  30248. }
  30249. return *v, true
  30250. }
  30251. // ResetSopRun resets all changes to the "sop_run" field.
  30252. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30253. m.sop_run = nil
  30254. m.addsop_run = nil
  30255. }
  30256. // SetTotalFriend sets the "total_friend" field.
  30257. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30258. m.total_friend = &u
  30259. m.addtotal_friend = nil
  30260. }
  30261. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30262. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30263. v := m.total_friend
  30264. if v == nil {
  30265. return
  30266. }
  30267. return *v, true
  30268. }
  30269. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30270. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30272. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30273. if !m.op.Is(OpUpdateOne) {
  30274. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30275. }
  30276. if m.id == nil || m.oldValue == nil {
  30277. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30278. }
  30279. oldValue, err := m.oldValue(ctx)
  30280. if err != nil {
  30281. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30282. }
  30283. return oldValue.TotalFriend, nil
  30284. }
  30285. // AddTotalFriend adds u to the "total_friend" field.
  30286. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30287. if m.addtotal_friend != nil {
  30288. *m.addtotal_friend += u
  30289. } else {
  30290. m.addtotal_friend = &u
  30291. }
  30292. }
  30293. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30294. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30295. v := m.addtotal_friend
  30296. if v == nil {
  30297. return
  30298. }
  30299. return *v, true
  30300. }
  30301. // ResetTotalFriend resets all changes to the "total_friend" field.
  30302. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30303. m.total_friend = nil
  30304. m.addtotal_friend = nil
  30305. }
  30306. // SetTotalGroup sets the "total_group" field.
  30307. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30308. m.total_group = &u
  30309. m.addtotal_group = nil
  30310. }
  30311. // TotalGroup returns the value of the "total_group" field in the mutation.
  30312. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30313. v := m.total_group
  30314. if v == nil {
  30315. return
  30316. }
  30317. return *v, true
  30318. }
  30319. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30320. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30322. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30323. if !m.op.Is(OpUpdateOne) {
  30324. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30325. }
  30326. if m.id == nil || m.oldValue == nil {
  30327. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30328. }
  30329. oldValue, err := m.oldValue(ctx)
  30330. if err != nil {
  30331. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30332. }
  30333. return oldValue.TotalGroup, nil
  30334. }
  30335. // AddTotalGroup adds u to the "total_group" field.
  30336. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30337. if m.addtotal_group != nil {
  30338. *m.addtotal_group += u
  30339. } else {
  30340. m.addtotal_group = &u
  30341. }
  30342. }
  30343. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30344. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30345. v := m.addtotal_group
  30346. if v == nil {
  30347. return
  30348. }
  30349. return *v, true
  30350. }
  30351. // ResetTotalGroup resets all changes to the "total_group" field.
  30352. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30353. m.total_group = nil
  30354. m.addtotal_group = nil
  30355. }
  30356. // SetAccountBalance sets the "account_balance" field.
  30357. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30358. m.account_balance = &u
  30359. m.addaccount_balance = nil
  30360. }
  30361. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30362. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30363. v := m.account_balance
  30364. if v == nil {
  30365. return
  30366. }
  30367. return *v, true
  30368. }
  30369. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30370. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30372. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30373. if !m.op.Is(OpUpdateOne) {
  30374. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30375. }
  30376. if m.id == nil || m.oldValue == nil {
  30377. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30378. }
  30379. oldValue, err := m.oldValue(ctx)
  30380. if err != nil {
  30381. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30382. }
  30383. return oldValue.AccountBalance, nil
  30384. }
  30385. // AddAccountBalance adds u to the "account_balance" field.
  30386. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30387. if m.addaccount_balance != nil {
  30388. *m.addaccount_balance += u
  30389. } else {
  30390. m.addaccount_balance = &u
  30391. }
  30392. }
  30393. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30394. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30395. v := m.addaccount_balance
  30396. if v == nil {
  30397. return
  30398. }
  30399. return *v, true
  30400. }
  30401. // ResetAccountBalance resets all changes to the "account_balance" field.
  30402. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30403. m.account_balance = nil
  30404. m.addaccount_balance = nil
  30405. }
  30406. // SetConsumeToken sets the "consume_token" field.
  30407. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30408. m.consume_token = &u
  30409. m.addconsume_token = nil
  30410. }
  30411. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30412. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30413. v := m.consume_token
  30414. if v == nil {
  30415. return
  30416. }
  30417. return *v, true
  30418. }
  30419. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30420. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30422. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30423. if !m.op.Is(OpUpdateOne) {
  30424. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30425. }
  30426. if m.id == nil || m.oldValue == nil {
  30427. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30428. }
  30429. oldValue, err := m.oldValue(ctx)
  30430. if err != nil {
  30431. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30432. }
  30433. return oldValue.ConsumeToken, nil
  30434. }
  30435. // AddConsumeToken adds u to the "consume_token" field.
  30436. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30437. if m.addconsume_token != nil {
  30438. *m.addconsume_token += u
  30439. } else {
  30440. m.addconsume_token = &u
  30441. }
  30442. }
  30443. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30444. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30445. v := m.addconsume_token
  30446. if v == nil {
  30447. return
  30448. }
  30449. return *v, true
  30450. }
  30451. // ResetConsumeToken resets all changes to the "consume_token" field.
  30452. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30453. m.consume_token = nil
  30454. m.addconsume_token = nil
  30455. }
  30456. // SetActiveUser sets the "active_user" field.
  30457. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30458. m.active_user = &u
  30459. m.addactive_user = nil
  30460. }
  30461. // ActiveUser returns the value of the "active_user" field in the mutation.
  30462. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30463. v := m.active_user
  30464. if v == nil {
  30465. return
  30466. }
  30467. return *v, true
  30468. }
  30469. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30470. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30472. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30473. if !m.op.Is(OpUpdateOne) {
  30474. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30475. }
  30476. if m.id == nil || m.oldValue == nil {
  30477. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30478. }
  30479. oldValue, err := m.oldValue(ctx)
  30480. if err != nil {
  30481. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30482. }
  30483. return oldValue.ActiveUser, nil
  30484. }
  30485. // AddActiveUser adds u to the "active_user" field.
  30486. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30487. if m.addactive_user != nil {
  30488. *m.addactive_user += u
  30489. } else {
  30490. m.addactive_user = &u
  30491. }
  30492. }
  30493. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30494. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30495. v := m.addactive_user
  30496. if v == nil {
  30497. return
  30498. }
  30499. return *v, true
  30500. }
  30501. // ResetActiveUser resets all changes to the "active_user" field.
  30502. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30503. m.active_user = nil
  30504. m.addactive_user = nil
  30505. }
  30506. // SetNewUser sets the "new_user" field.
  30507. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30508. m.new_user = &i
  30509. m.addnew_user = nil
  30510. }
  30511. // NewUser returns the value of the "new_user" field in the mutation.
  30512. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30513. v := m.new_user
  30514. if v == nil {
  30515. return
  30516. }
  30517. return *v, true
  30518. }
  30519. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30520. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30522. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30523. if !m.op.Is(OpUpdateOne) {
  30524. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30525. }
  30526. if m.id == nil || m.oldValue == nil {
  30527. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30528. }
  30529. oldValue, err := m.oldValue(ctx)
  30530. if err != nil {
  30531. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30532. }
  30533. return oldValue.NewUser, nil
  30534. }
  30535. // AddNewUser adds i to the "new_user" field.
  30536. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30537. if m.addnew_user != nil {
  30538. *m.addnew_user += i
  30539. } else {
  30540. m.addnew_user = &i
  30541. }
  30542. }
  30543. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30544. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30545. v := m.addnew_user
  30546. if v == nil {
  30547. return
  30548. }
  30549. return *v, true
  30550. }
  30551. // ResetNewUser resets all changes to the "new_user" field.
  30552. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30553. m.new_user = nil
  30554. m.addnew_user = nil
  30555. }
  30556. // SetLabelDist sets the "label_dist" field.
  30557. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30558. m.label_dist = &ctd
  30559. m.appendlabel_dist = nil
  30560. }
  30561. // LabelDist returns the value of the "label_dist" field in the mutation.
  30562. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30563. v := m.label_dist
  30564. if v == nil {
  30565. return
  30566. }
  30567. return *v, true
  30568. }
  30569. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30570. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30572. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30573. if !m.op.Is(OpUpdateOne) {
  30574. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30575. }
  30576. if m.id == nil || m.oldValue == nil {
  30577. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30578. }
  30579. oldValue, err := m.oldValue(ctx)
  30580. if err != nil {
  30581. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30582. }
  30583. return oldValue.LabelDist, nil
  30584. }
  30585. // AppendLabelDist adds ctd to the "label_dist" field.
  30586. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30587. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30588. }
  30589. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30590. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30591. if len(m.appendlabel_dist) == 0 {
  30592. return nil, false
  30593. }
  30594. return m.appendlabel_dist, true
  30595. }
  30596. // ResetLabelDist resets all changes to the "label_dist" field.
  30597. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30598. m.label_dist = nil
  30599. m.appendlabel_dist = nil
  30600. }
  30601. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30602. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30603. m.predicates = append(m.predicates, ps...)
  30604. }
  30605. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30606. // users can use type-assertion to append predicates that do not depend on any generated package.
  30607. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30608. p := make([]predicate.UsageStatisticHour, len(ps))
  30609. for i := range ps {
  30610. p[i] = ps[i]
  30611. }
  30612. m.Where(p...)
  30613. }
  30614. // Op returns the operation name.
  30615. func (m *UsageStatisticHourMutation) Op() Op {
  30616. return m.op
  30617. }
  30618. // SetOp allows setting the mutation operation.
  30619. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30620. m.op = op
  30621. }
  30622. // Type returns the node type of this mutation (UsageStatisticHour).
  30623. func (m *UsageStatisticHourMutation) Type() string {
  30624. return m.typ
  30625. }
  30626. // Fields returns all fields that were changed during this mutation. Note that in
  30627. // order to get all numeric fields that were incremented/decremented, call
  30628. // AddedFields().
  30629. func (m *UsageStatisticHourMutation) Fields() []string {
  30630. fields := make([]string, 0, 17)
  30631. if m.created_at != nil {
  30632. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30633. }
  30634. if m.updated_at != nil {
  30635. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30636. }
  30637. if m.status != nil {
  30638. fields = append(fields, usagestatistichour.FieldStatus)
  30639. }
  30640. if m.deleted_at != nil {
  30641. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30642. }
  30643. if m.addtime != nil {
  30644. fields = append(fields, usagestatistichour.FieldAddtime)
  30645. }
  30646. if m._type != nil {
  30647. fields = append(fields, usagestatistichour.FieldType)
  30648. }
  30649. if m.bot_id != nil {
  30650. fields = append(fields, usagestatistichour.FieldBotID)
  30651. }
  30652. if m.organization_id != nil {
  30653. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30654. }
  30655. if m.ai_response != nil {
  30656. fields = append(fields, usagestatistichour.FieldAiResponse)
  30657. }
  30658. if m.sop_run != nil {
  30659. fields = append(fields, usagestatistichour.FieldSopRun)
  30660. }
  30661. if m.total_friend != nil {
  30662. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30663. }
  30664. if m.total_group != nil {
  30665. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30666. }
  30667. if m.account_balance != nil {
  30668. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30669. }
  30670. if m.consume_token != nil {
  30671. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30672. }
  30673. if m.active_user != nil {
  30674. fields = append(fields, usagestatistichour.FieldActiveUser)
  30675. }
  30676. if m.new_user != nil {
  30677. fields = append(fields, usagestatistichour.FieldNewUser)
  30678. }
  30679. if m.label_dist != nil {
  30680. fields = append(fields, usagestatistichour.FieldLabelDist)
  30681. }
  30682. return fields
  30683. }
  30684. // Field returns the value of a field with the given name. The second boolean
  30685. // return value indicates that this field was not set, or was not defined in the
  30686. // schema.
  30687. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30688. switch name {
  30689. case usagestatistichour.FieldCreatedAt:
  30690. return m.CreatedAt()
  30691. case usagestatistichour.FieldUpdatedAt:
  30692. return m.UpdatedAt()
  30693. case usagestatistichour.FieldStatus:
  30694. return m.Status()
  30695. case usagestatistichour.FieldDeletedAt:
  30696. return m.DeletedAt()
  30697. case usagestatistichour.FieldAddtime:
  30698. return m.Addtime()
  30699. case usagestatistichour.FieldType:
  30700. return m.GetType()
  30701. case usagestatistichour.FieldBotID:
  30702. return m.BotID()
  30703. case usagestatistichour.FieldOrganizationID:
  30704. return m.OrganizationID()
  30705. case usagestatistichour.FieldAiResponse:
  30706. return m.AiResponse()
  30707. case usagestatistichour.FieldSopRun:
  30708. return m.SopRun()
  30709. case usagestatistichour.FieldTotalFriend:
  30710. return m.TotalFriend()
  30711. case usagestatistichour.FieldTotalGroup:
  30712. return m.TotalGroup()
  30713. case usagestatistichour.FieldAccountBalance:
  30714. return m.AccountBalance()
  30715. case usagestatistichour.FieldConsumeToken:
  30716. return m.ConsumeToken()
  30717. case usagestatistichour.FieldActiveUser:
  30718. return m.ActiveUser()
  30719. case usagestatistichour.FieldNewUser:
  30720. return m.NewUser()
  30721. case usagestatistichour.FieldLabelDist:
  30722. return m.LabelDist()
  30723. }
  30724. return nil, false
  30725. }
  30726. // OldField returns the old value of the field from the database. An error is
  30727. // returned if the mutation operation is not UpdateOne, or the query to the
  30728. // database failed.
  30729. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30730. switch name {
  30731. case usagestatistichour.FieldCreatedAt:
  30732. return m.OldCreatedAt(ctx)
  30733. case usagestatistichour.FieldUpdatedAt:
  30734. return m.OldUpdatedAt(ctx)
  30735. case usagestatistichour.FieldStatus:
  30736. return m.OldStatus(ctx)
  30737. case usagestatistichour.FieldDeletedAt:
  30738. return m.OldDeletedAt(ctx)
  30739. case usagestatistichour.FieldAddtime:
  30740. return m.OldAddtime(ctx)
  30741. case usagestatistichour.FieldType:
  30742. return m.OldType(ctx)
  30743. case usagestatistichour.FieldBotID:
  30744. return m.OldBotID(ctx)
  30745. case usagestatistichour.FieldOrganizationID:
  30746. return m.OldOrganizationID(ctx)
  30747. case usagestatistichour.FieldAiResponse:
  30748. return m.OldAiResponse(ctx)
  30749. case usagestatistichour.FieldSopRun:
  30750. return m.OldSopRun(ctx)
  30751. case usagestatistichour.FieldTotalFriend:
  30752. return m.OldTotalFriend(ctx)
  30753. case usagestatistichour.FieldTotalGroup:
  30754. return m.OldTotalGroup(ctx)
  30755. case usagestatistichour.FieldAccountBalance:
  30756. return m.OldAccountBalance(ctx)
  30757. case usagestatistichour.FieldConsumeToken:
  30758. return m.OldConsumeToken(ctx)
  30759. case usagestatistichour.FieldActiveUser:
  30760. return m.OldActiveUser(ctx)
  30761. case usagestatistichour.FieldNewUser:
  30762. return m.OldNewUser(ctx)
  30763. case usagestatistichour.FieldLabelDist:
  30764. return m.OldLabelDist(ctx)
  30765. }
  30766. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30767. }
  30768. // SetField sets the value of a field with the given name. It returns an error if
  30769. // the field is not defined in the schema, or if the type mismatched the field
  30770. // type.
  30771. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30772. switch name {
  30773. case usagestatistichour.FieldCreatedAt:
  30774. v, ok := value.(time.Time)
  30775. if !ok {
  30776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30777. }
  30778. m.SetCreatedAt(v)
  30779. return nil
  30780. case usagestatistichour.FieldUpdatedAt:
  30781. v, ok := value.(time.Time)
  30782. if !ok {
  30783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30784. }
  30785. m.SetUpdatedAt(v)
  30786. return nil
  30787. case usagestatistichour.FieldStatus:
  30788. v, ok := value.(uint8)
  30789. if !ok {
  30790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30791. }
  30792. m.SetStatus(v)
  30793. return nil
  30794. case usagestatistichour.FieldDeletedAt:
  30795. v, ok := value.(time.Time)
  30796. if !ok {
  30797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30798. }
  30799. m.SetDeletedAt(v)
  30800. return nil
  30801. case usagestatistichour.FieldAddtime:
  30802. v, ok := value.(uint64)
  30803. if !ok {
  30804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30805. }
  30806. m.SetAddtime(v)
  30807. return nil
  30808. case usagestatistichour.FieldType:
  30809. v, ok := value.(int)
  30810. if !ok {
  30811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30812. }
  30813. m.SetType(v)
  30814. return nil
  30815. case usagestatistichour.FieldBotID:
  30816. v, ok := value.(string)
  30817. if !ok {
  30818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30819. }
  30820. m.SetBotID(v)
  30821. return nil
  30822. case usagestatistichour.FieldOrganizationID:
  30823. v, ok := value.(uint64)
  30824. if !ok {
  30825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30826. }
  30827. m.SetOrganizationID(v)
  30828. return nil
  30829. case usagestatistichour.FieldAiResponse:
  30830. v, ok := value.(uint64)
  30831. if !ok {
  30832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30833. }
  30834. m.SetAiResponse(v)
  30835. return nil
  30836. case usagestatistichour.FieldSopRun:
  30837. v, ok := value.(uint64)
  30838. if !ok {
  30839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30840. }
  30841. m.SetSopRun(v)
  30842. return nil
  30843. case usagestatistichour.FieldTotalFriend:
  30844. v, ok := value.(uint64)
  30845. if !ok {
  30846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30847. }
  30848. m.SetTotalFriend(v)
  30849. return nil
  30850. case usagestatistichour.FieldTotalGroup:
  30851. v, ok := value.(uint64)
  30852. if !ok {
  30853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30854. }
  30855. m.SetTotalGroup(v)
  30856. return nil
  30857. case usagestatistichour.FieldAccountBalance:
  30858. v, ok := value.(uint64)
  30859. if !ok {
  30860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30861. }
  30862. m.SetAccountBalance(v)
  30863. return nil
  30864. case usagestatistichour.FieldConsumeToken:
  30865. v, ok := value.(uint64)
  30866. if !ok {
  30867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30868. }
  30869. m.SetConsumeToken(v)
  30870. return nil
  30871. case usagestatistichour.FieldActiveUser:
  30872. v, ok := value.(uint64)
  30873. if !ok {
  30874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30875. }
  30876. m.SetActiveUser(v)
  30877. return nil
  30878. case usagestatistichour.FieldNewUser:
  30879. v, ok := value.(int64)
  30880. if !ok {
  30881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30882. }
  30883. m.SetNewUser(v)
  30884. return nil
  30885. case usagestatistichour.FieldLabelDist:
  30886. v, ok := value.([]custom_types.LabelDist)
  30887. if !ok {
  30888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30889. }
  30890. m.SetLabelDist(v)
  30891. return nil
  30892. }
  30893. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30894. }
  30895. // AddedFields returns all numeric fields that were incremented/decremented during
  30896. // this mutation.
  30897. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30898. var fields []string
  30899. if m.addstatus != nil {
  30900. fields = append(fields, usagestatistichour.FieldStatus)
  30901. }
  30902. if m.addaddtime != nil {
  30903. fields = append(fields, usagestatistichour.FieldAddtime)
  30904. }
  30905. if m.add_type != nil {
  30906. fields = append(fields, usagestatistichour.FieldType)
  30907. }
  30908. if m.addorganization_id != nil {
  30909. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30910. }
  30911. if m.addai_response != nil {
  30912. fields = append(fields, usagestatistichour.FieldAiResponse)
  30913. }
  30914. if m.addsop_run != nil {
  30915. fields = append(fields, usagestatistichour.FieldSopRun)
  30916. }
  30917. if m.addtotal_friend != nil {
  30918. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30919. }
  30920. if m.addtotal_group != nil {
  30921. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30922. }
  30923. if m.addaccount_balance != nil {
  30924. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30925. }
  30926. if m.addconsume_token != nil {
  30927. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30928. }
  30929. if m.addactive_user != nil {
  30930. fields = append(fields, usagestatistichour.FieldActiveUser)
  30931. }
  30932. if m.addnew_user != nil {
  30933. fields = append(fields, usagestatistichour.FieldNewUser)
  30934. }
  30935. return fields
  30936. }
  30937. // AddedField returns the numeric value that was incremented/decremented on a field
  30938. // with the given name. The second boolean return value indicates that this field
  30939. // was not set, or was not defined in the schema.
  30940. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30941. switch name {
  30942. case usagestatistichour.FieldStatus:
  30943. return m.AddedStatus()
  30944. case usagestatistichour.FieldAddtime:
  30945. return m.AddedAddtime()
  30946. case usagestatistichour.FieldType:
  30947. return m.AddedType()
  30948. case usagestatistichour.FieldOrganizationID:
  30949. return m.AddedOrganizationID()
  30950. case usagestatistichour.FieldAiResponse:
  30951. return m.AddedAiResponse()
  30952. case usagestatistichour.FieldSopRun:
  30953. return m.AddedSopRun()
  30954. case usagestatistichour.FieldTotalFriend:
  30955. return m.AddedTotalFriend()
  30956. case usagestatistichour.FieldTotalGroup:
  30957. return m.AddedTotalGroup()
  30958. case usagestatistichour.FieldAccountBalance:
  30959. return m.AddedAccountBalance()
  30960. case usagestatistichour.FieldConsumeToken:
  30961. return m.AddedConsumeToken()
  30962. case usagestatistichour.FieldActiveUser:
  30963. return m.AddedActiveUser()
  30964. case usagestatistichour.FieldNewUser:
  30965. return m.AddedNewUser()
  30966. }
  30967. return nil, false
  30968. }
  30969. // AddField adds the value to the field with the given name. It returns an error if
  30970. // the field is not defined in the schema, or if the type mismatched the field
  30971. // type.
  30972. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30973. switch name {
  30974. case usagestatistichour.FieldStatus:
  30975. v, ok := value.(int8)
  30976. if !ok {
  30977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30978. }
  30979. m.AddStatus(v)
  30980. return nil
  30981. case usagestatistichour.FieldAddtime:
  30982. v, ok := value.(int64)
  30983. if !ok {
  30984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30985. }
  30986. m.AddAddtime(v)
  30987. return nil
  30988. case usagestatistichour.FieldType:
  30989. v, ok := value.(int)
  30990. if !ok {
  30991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30992. }
  30993. m.AddType(v)
  30994. return nil
  30995. case usagestatistichour.FieldOrganizationID:
  30996. v, ok := value.(int64)
  30997. if !ok {
  30998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30999. }
  31000. m.AddOrganizationID(v)
  31001. return nil
  31002. case usagestatistichour.FieldAiResponse:
  31003. v, ok := value.(int64)
  31004. if !ok {
  31005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31006. }
  31007. m.AddAiResponse(v)
  31008. return nil
  31009. case usagestatistichour.FieldSopRun:
  31010. v, ok := value.(int64)
  31011. if !ok {
  31012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31013. }
  31014. m.AddSopRun(v)
  31015. return nil
  31016. case usagestatistichour.FieldTotalFriend:
  31017. v, ok := value.(int64)
  31018. if !ok {
  31019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31020. }
  31021. m.AddTotalFriend(v)
  31022. return nil
  31023. case usagestatistichour.FieldTotalGroup:
  31024. v, ok := value.(int64)
  31025. if !ok {
  31026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31027. }
  31028. m.AddTotalGroup(v)
  31029. return nil
  31030. case usagestatistichour.FieldAccountBalance:
  31031. v, ok := value.(int64)
  31032. if !ok {
  31033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31034. }
  31035. m.AddAccountBalance(v)
  31036. return nil
  31037. case usagestatistichour.FieldConsumeToken:
  31038. v, ok := value.(int64)
  31039. if !ok {
  31040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31041. }
  31042. m.AddConsumeToken(v)
  31043. return nil
  31044. case usagestatistichour.FieldActiveUser:
  31045. v, ok := value.(int64)
  31046. if !ok {
  31047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31048. }
  31049. m.AddActiveUser(v)
  31050. return nil
  31051. case usagestatistichour.FieldNewUser:
  31052. v, ok := value.(int64)
  31053. if !ok {
  31054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31055. }
  31056. m.AddNewUser(v)
  31057. return nil
  31058. }
  31059. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31060. }
  31061. // ClearedFields returns all nullable fields that were cleared during this
  31062. // mutation.
  31063. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31064. var fields []string
  31065. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31066. fields = append(fields, usagestatistichour.FieldStatus)
  31067. }
  31068. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31069. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31070. }
  31071. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31072. fields = append(fields, usagestatistichour.FieldBotID)
  31073. }
  31074. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31075. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31076. }
  31077. return fields
  31078. }
  31079. // FieldCleared returns a boolean indicating if a field with the given name was
  31080. // cleared in this mutation.
  31081. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31082. _, ok := m.clearedFields[name]
  31083. return ok
  31084. }
  31085. // ClearField clears the value of the field with the given name. It returns an
  31086. // error if the field is not defined in the schema.
  31087. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31088. switch name {
  31089. case usagestatistichour.FieldStatus:
  31090. m.ClearStatus()
  31091. return nil
  31092. case usagestatistichour.FieldDeletedAt:
  31093. m.ClearDeletedAt()
  31094. return nil
  31095. case usagestatistichour.FieldBotID:
  31096. m.ClearBotID()
  31097. return nil
  31098. case usagestatistichour.FieldOrganizationID:
  31099. m.ClearOrganizationID()
  31100. return nil
  31101. }
  31102. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31103. }
  31104. // ResetField resets all changes in the mutation for the field with the given name.
  31105. // It returns an error if the field is not defined in the schema.
  31106. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31107. switch name {
  31108. case usagestatistichour.FieldCreatedAt:
  31109. m.ResetCreatedAt()
  31110. return nil
  31111. case usagestatistichour.FieldUpdatedAt:
  31112. m.ResetUpdatedAt()
  31113. return nil
  31114. case usagestatistichour.FieldStatus:
  31115. m.ResetStatus()
  31116. return nil
  31117. case usagestatistichour.FieldDeletedAt:
  31118. m.ResetDeletedAt()
  31119. return nil
  31120. case usagestatistichour.FieldAddtime:
  31121. m.ResetAddtime()
  31122. return nil
  31123. case usagestatistichour.FieldType:
  31124. m.ResetType()
  31125. return nil
  31126. case usagestatistichour.FieldBotID:
  31127. m.ResetBotID()
  31128. return nil
  31129. case usagestatistichour.FieldOrganizationID:
  31130. m.ResetOrganizationID()
  31131. return nil
  31132. case usagestatistichour.FieldAiResponse:
  31133. m.ResetAiResponse()
  31134. return nil
  31135. case usagestatistichour.FieldSopRun:
  31136. m.ResetSopRun()
  31137. return nil
  31138. case usagestatistichour.FieldTotalFriend:
  31139. m.ResetTotalFriend()
  31140. return nil
  31141. case usagestatistichour.FieldTotalGroup:
  31142. m.ResetTotalGroup()
  31143. return nil
  31144. case usagestatistichour.FieldAccountBalance:
  31145. m.ResetAccountBalance()
  31146. return nil
  31147. case usagestatistichour.FieldConsumeToken:
  31148. m.ResetConsumeToken()
  31149. return nil
  31150. case usagestatistichour.FieldActiveUser:
  31151. m.ResetActiveUser()
  31152. return nil
  31153. case usagestatistichour.FieldNewUser:
  31154. m.ResetNewUser()
  31155. return nil
  31156. case usagestatistichour.FieldLabelDist:
  31157. m.ResetLabelDist()
  31158. return nil
  31159. }
  31160. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31161. }
  31162. // AddedEdges returns all edge names that were set/added in this mutation.
  31163. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31164. edges := make([]string, 0, 0)
  31165. return edges
  31166. }
  31167. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31168. // name in this mutation.
  31169. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31170. return nil
  31171. }
  31172. // RemovedEdges returns all edge names that were removed in this mutation.
  31173. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31174. edges := make([]string, 0, 0)
  31175. return edges
  31176. }
  31177. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31178. // the given name in this mutation.
  31179. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31180. return nil
  31181. }
  31182. // ClearedEdges returns all edge names that were cleared in this mutation.
  31183. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31184. edges := make([]string, 0, 0)
  31185. return edges
  31186. }
  31187. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31188. // was cleared in this mutation.
  31189. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31190. return false
  31191. }
  31192. // ClearEdge clears the value of the edge with the given name. It returns an error
  31193. // if that edge is not defined in the schema.
  31194. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31195. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31196. }
  31197. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31198. // It returns an error if the edge is not defined in the schema.
  31199. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31200. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31201. }
  31202. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31203. type UsageStatisticMonthMutation struct {
  31204. config
  31205. op Op
  31206. typ string
  31207. id *uint64
  31208. created_at *time.Time
  31209. updated_at *time.Time
  31210. status *uint8
  31211. addstatus *int8
  31212. deleted_at *time.Time
  31213. addtime *uint64
  31214. addaddtime *int64
  31215. _type *int
  31216. add_type *int
  31217. bot_id *string
  31218. organization_id *uint64
  31219. addorganization_id *int64
  31220. ai_response *uint64
  31221. addai_response *int64
  31222. sop_run *uint64
  31223. addsop_run *int64
  31224. total_friend *uint64
  31225. addtotal_friend *int64
  31226. total_group *uint64
  31227. addtotal_group *int64
  31228. account_balance *uint64
  31229. addaccount_balance *int64
  31230. consume_token *uint64
  31231. addconsume_token *int64
  31232. active_user *uint64
  31233. addactive_user *int64
  31234. new_user *int64
  31235. addnew_user *int64
  31236. label_dist *[]custom_types.LabelDist
  31237. appendlabel_dist []custom_types.LabelDist
  31238. clearedFields map[string]struct{}
  31239. done bool
  31240. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31241. predicates []predicate.UsageStatisticMonth
  31242. }
  31243. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31244. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31245. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31246. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31247. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31248. m := &UsageStatisticMonthMutation{
  31249. config: c,
  31250. op: op,
  31251. typ: TypeUsageStatisticMonth,
  31252. clearedFields: make(map[string]struct{}),
  31253. }
  31254. for _, opt := range opts {
  31255. opt(m)
  31256. }
  31257. return m
  31258. }
  31259. // withUsageStatisticMonthID sets the ID field of the mutation.
  31260. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31261. return func(m *UsageStatisticMonthMutation) {
  31262. var (
  31263. err error
  31264. once sync.Once
  31265. value *UsageStatisticMonth
  31266. )
  31267. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31268. once.Do(func() {
  31269. if m.done {
  31270. err = errors.New("querying old values post mutation is not allowed")
  31271. } else {
  31272. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31273. }
  31274. })
  31275. return value, err
  31276. }
  31277. m.id = &id
  31278. }
  31279. }
  31280. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31281. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31282. return func(m *UsageStatisticMonthMutation) {
  31283. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31284. return node, nil
  31285. }
  31286. m.id = &node.ID
  31287. }
  31288. }
  31289. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31290. // executed in a transaction (ent.Tx), a transactional client is returned.
  31291. func (m UsageStatisticMonthMutation) Client() *Client {
  31292. client := &Client{config: m.config}
  31293. client.init()
  31294. return client
  31295. }
  31296. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31297. // it returns an error otherwise.
  31298. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31299. if _, ok := m.driver.(*txDriver); !ok {
  31300. return nil, errors.New("ent: mutation is not running in a transaction")
  31301. }
  31302. tx := &Tx{config: m.config}
  31303. tx.init()
  31304. return tx, nil
  31305. }
  31306. // SetID sets the value of the id field. Note that this
  31307. // operation is only accepted on creation of UsageStatisticMonth entities.
  31308. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31309. m.id = &id
  31310. }
  31311. // ID returns the ID value in the mutation. Note that the ID is only available
  31312. // if it was provided to the builder or after it was returned from the database.
  31313. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31314. if m.id == nil {
  31315. return
  31316. }
  31317. return *m.id, true
  31318. }
  31319. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31320. // That means, if the mutation is applied within a transaction with an isolation level such
  31321. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31322. // or updated by the mutation.
  31323. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31324. switch {
  31325. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31326. id, exists := m.ID()
  31327. if exists {
  31328. return []uint64{id}, nil
  31329. }
  31330. fallthrough
  31331. case m.op.Is(OpUpdate | OpDelete):
  31332. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31333. default:
  31334. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31335. }
  31336. }
  31337. // SetCreatedAt sets the "created_at" field.
  31338. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31339. m.created_at = &t
  31340. }
  31341. // CreatedAt returns the value of the "created_at" field in the mutation.
  31342. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31343. v := m.created_at
  31344. if v == nil {
  31345. return
  31346. }
  31347. return *v, true
  31348. }
  31349. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31350. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31352. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31353. if !m.op.Is(OpUpdateOne) {
  31354. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31355. }
  31356. if m.id == nil || m.oldValue == nil {
  31357. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31358. }
  31359. oldValue, err := m.oldValue(ctx)
  31360. if err != nil {
  31361. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31362. }
  31363. return oldValue.CreatedAt, nil
  31364. }
  31365. // ResetCreatedAt resets all changes to the "created_at" field.
  31366. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31367. m.created_at = nil
  31368. }
  31369. // SetUpdatedAt sets the "updated_at" field.
  31370. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31371. m.updated_at = &t
  31372. }
  31373. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31374. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31375. v := m.updated_at
  31376. if v == nil {
  31377. return
  31378. }
  31379. return *v, true
  31380. }
  31381. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31382. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31384. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31385. if !m.op.Is(OpUpdateOne) {
  31386. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31387. }
  31388. if m.id == nil || m.oldValue == nil {
  31389. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31390. }
  31391. oldValue, err := m.oldValue(ctx)
  31392. if err != nil {
  31393. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31394. }
  31395. return oldValue.UpdatedAt, nil
  31396. }
  31397. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31398. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31399. m.updated_at = nil
  31400. }
  31401. // SetStatus sets the "status" field.
  31402. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31403. m.status = &u
  31404. m.addstatus = nil
  31405. }
  31406. // Status returns the value of the "status" field in the mutation.
  31407. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31408. v := m.status
  31409. if v == nil {
  31410. return
  31411. }
  31412. return *v, true
  31413. }
  31414. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31415. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31417. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31418. if !m.op.Is(OpUpdateOne) {
  31419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31420. }
  31421. if m.id == nil || m.oldValue == nil {
  31422. return v, errors.New("OldStatus requires an ID field in the mutation")
  31423. }
  31424. oldValue, err := m.oldValue(ctx)
  31425. if err != nil {
  31426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31427. }
  31428. return oldValue.Status, nil
  31429. }
  31430. // AddStatus adds u to the "status" field.
  31431. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31432. if m.addstatus != nil {
  31433. *m.addstatus += u
  31434. } else {
  31435. m.addstatus = &u
  31436. }
  31437. }
  31438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31439. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31440. v := m.addstatus
  31441. if v == nil {
  31442. return
  31443. }
  31444. return *v, true
  31445. }
  31446. // ClearStatus clears the value of the "status" field.
  31447. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31448. m.status = nil
  31449. m.addstatus = nil
  31450. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31451. }
  31452. // StatusCleared returns if the "status" field was cleared in this mutation.
  31453. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31454. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31455. return ok
  31456. }
  31457. // ResetStatus resets all changes to the "status" field.
  31458. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31459. m.status = nil
  31460. m.addstatus = nil
  31461. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31462. }
  31463. // SetDeletedAt sets the "deleted_at" field.
  31464. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31465. m.deleted_at = &t
  31466. }
  31467. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31468. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31469. v := m.deleted_at
  31470. if v == nil {
  31471. return
  31472. }
  31473. return *v, true
  31474. }
  31475. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31476. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31478. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31479. if !m.op.Is(OpUpdateOne) {
  31480. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31481. }
  31482. if m.id == nil || m.oldValue == nil {
  31483. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31484. }
  31485. oldValue, err := m.oldValue(ctx)
  31486. if err != nil {
  31487. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31488. }
  31489. return oldValue.DeletedAt, nil
  31490. }
  31491. // ClearDeletedAt clears the value of the "deleted_at" field.
  31492. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31493. m.deleted_at = nil
  31494. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31495. }
  31496. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31497. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31498. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31499. return ok
  31500. }
  31501. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31502. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31503. m.deleted_at = nil
  31504. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31505. }
  31506. // SetAddtime sets the "addtime" field.
  31507. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31508. m.addtime = &u
  31509. m.addaddtime = nil
  31510. }
  31511. // Addtime returns the value of the "addtime" field in the mutation.
  31512. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31513. v := m.addtime
  31514. if v == nil {
  31515. return
  31516. }
  31517. return *v, true
  31518. }
  31519. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31520. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31522. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31523. if !m.op.Is(OpUpdateOne) {
  31524. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31525. }
  31526. if m.id == nil || m.oldValue == nil {
  31527. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31528. }
  31529. oldValue, err := m.oldValue(ctx)
  31530. if err != nil {
  31531. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31532. }
  31533. return oldValue.Addtime, nil
  31534. }
  31535. // AddAddtime adds u to the "addtime" field.
  31536. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31537. if m.addaddtime != nil {
  31538. *m.addaddtime += u
  31539. } else {
  31540. m.addaddtime = &u
  31541. }
  31542. }
  31543. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31544. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31545. v := m.addaddtime
  31546. if v == nil {
  31547. return
  31548. }
  31549. return *v, true
  31550. }
  31551. // ResetAddtime resets all changes to the "addtime" field.
  31552. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31553. m.addtime = nil
  31554. m.addaddtime = nil
  31555. }
  31556. // SetType sets the "type" field.
  31557. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31558. m._type = &i
  31559. m.add_type = nil
  31560. }
  31561. // GetType returns the value of the "type" field in the mutation.
  31562. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31563. v := m._type
  31564. if v == nil {
  31565. return
  31566. }
  31567. return *v, true
  31568. }
  31569. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31570. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31572. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31573. if !m.op.Is(OpUpdateOne) {
  31574. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31575. }
  31576. if m.id == nil || m.oldValue == nil {
  31577. return v, errors.New("OldType requires an ID field in the mutation")
  31578. }
  31579. oldValue, err := m.oldValue(ctx)
  31580. if err != nil {
  31581. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31582. }
  31583. return oldValue.Type, nil
  31584. }
  31585. // AddType adds i to the "type" field.
  31586. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31587. if m.add_type != nil {
  31588. *m.add_type += i
  31589. } else {
  31590. m.add_type = &i
  31591. }
  31592. }
  31593. // AddedType returns the value that was added to the "type" field in this mutation.
  31594. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31595. v := m.add_type
  31596. if v == nil {
  31597. return
  31598. }
  31599. return *v, true
  31600. }
  31601. // ResetType resets all changes to the "type" field.
  31602. func (m *UsageStatisticMonthMutation) ResetType() {
  31603. m._type = nil
  31604. m.add_type = nil
  31605. }
  31606. // SetBotID sets the "bot_id" field.
  31607. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31608. m.bot_id = &s
  31609. }
  31610. // BotID returns the value of the "bot_id" field in the mutation.
  31611. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31612. v := m.bot_id
  31613. if v == nil {
  31614. return
  31615. }
  31616. return *v, true
  31617. }
  31618. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31619. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31621. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31622. if !m.op.Is(OpUpdateOne) {
  31623. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31624. }
  31625. if m.id == nil || m.oldValue == nil {
  31626. return v, errors.New("OldBotID requires an ID field in the mutation")
  31627. }
  31628. oldValue, err := m.oldValue(ctx)
  31629. if err != nil {
  31630. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31631. }
  31632. return oldValue.BotID, nil
  31633. }
  31634. // ClearBotID clears the value of the "bot_id" field.
  31635. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31636. m.bot_id = nil
  31637. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31638. }
  31639. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31640. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31641. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31642. return ok
  31643. }
  31644. // ResetBotID resets all changes to the "bot_id" field.
  31645. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31646. m.bot_id = nil
  31647. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31648. }
  31649. // SetOrganizationID sets the "organization_id" field.
  31650. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31651. m.organization_id = &u
  31652. m.addorganization_id = nil
  31653. }
  31654. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31655. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31656. v := m.organization_id
  31657. if v == nil {
  31658. return
  31659. }
  31660. return *v, true
  31661. }
  31662. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31663. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31665. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31666. if !m.op.Is(OpUpdateOne) {
  31667. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31668. }
  31669. if m.id == nil || m.oldValue == nil {
  31670. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31671. }
  31672. oldValue, err := m.oldValue(ctx)
  31673. if err != nil {
  31674. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31675. }
  31676. return oldValue.OrganizationID, nil
  31677. }
  31678. // AddOrganizationID adds u to the "organization_id" field.
  31679. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31680. if m.addorganization_id != nil {
  31681. *m.addorganization_id += u
  31682. } else {
  31683. m.addorganization_id = &u
  31684. }
  31685. }
  31686. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31687. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31688. v := m.addorganization_id
  31689. if v == nil {
  31690. return
  31691. }
  31692. return *v, true
  31693. }
  31694. // ClearOrganizationID clears the value of the "organization_id" field.
  31695. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31696. m.organization_id = nil
  31697. m.addorganization_id = nil
  31698. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31699. }
  31700. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31701. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31702. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31703. return ok
  31704. }
  31705. // ResetOrganizationID resets all changes to the "organization_id" field.
  31706. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31707. m.organization_id = nil
  31708. m.addorganization_id = nil
  31709. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31710. }
  31711. // SetAiResponse sets the "ai_response" field.
  31712. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31713. m.ai_response = &u
  31714. m.addai_response = nil
  31715. }
  31716. // AiResponse returns the value of the "ai_response" field in the mutation.
  31717. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31718. v := m.ai_response
  31719. if v == nil {
  31720. return
  31721. }
  31722. return *v, true
  31723. }
  31724. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31725. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31727. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31728. if !m.op.Is(OpUpdateOne) {
  31729. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31730. }
  31731. if m.id == nil || m.oldValue == nil {
  31732. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31733. }
  31734. oldValue, err := m.oldValue(ctx)
  31735. if err != nil {
  31736. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31737. }
  31738. return oldValue.AiResponse, nil
  31739. }
  31740. // AddAiResponse adds u to the "ai_response" field.
  31741. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31742. if m.addai_response != nil {
  31743. *m.addai_response += u
  31744. } else {
  31745. m.addai_response = &u
  31746. }
  31747. }
  31748. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31749. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31750. v := m.addai_response
  31751. if v == nil {
  31752. return
  31753. }
  31754. return *v, true
  31755. }
  31756. // ResetAiResponse resets all changes to the "ai_response" field.
  31757. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31758. m.ai_response = nil
  31759. m.addai_response = nil
  31760. }
  31761. // SetSopRun sets the "sop_run" field.
  31762. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31763. m.sop_run = &u
  31764. m.addsop_run = nil
  31765. }
  31766. // SopRun returns the value of the "sop_run" field in the mutation.
  31767. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31768. v := m.sop_run
  31769. if v == nil {
  31770. return
  31771. }
  31772. return *v, true
  31773. }
  31774. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31775. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31777. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31778. if !m.op.Is(OpUpdateOne) {
  31779. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31780. }
  31781. if m.id == nil || m.oldValue == nil {
  31782. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31783. }
  31784. oldValue, err := m.oldValue(ctx)
  31785. if err != nil {
  31786. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31787. }
  31788. return oldValue.SopRun, nil
  31789. }
  31790. // AddSopRun adds u to the "sop_run" field.
  31791. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31792. if m.addsop_run != nil {
  31793. *m.addsop_run += u
  31794. } else {
  31795. m.addsop_run = &u
  31796. }
  31797. }
  31798. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31799. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31800. v := m.addsop_run
  31801. if v == nil {
  31802. return
  31803. }
  31804. return *v, true
  31805. }
  31806. // ResetSopRun resets all changes to the "sop_run" field.
  31807. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31808. m.sop_run = nil
  31809. m.addsop_run = nil
  31810. }
  31811. // SetTotalFriend sets the "total_friend" field.
  31812. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31813. m.total_friend = &u
  31814. m.addtotal_friend = nil
  31815. }
  31816. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31817. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31818. v := m.total_friend
  31819. if v == nil {
  31820. return
  31821. }
  31822. return *v, true
  31823. }
  31824. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31825. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31827. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31828. if !m.op.Is(OpUpdateOne) {
  31829. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31830. }
  31831. if m.id == nil || m.oldValue == nil {
  31832. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31833. }
  31834. oldValue, err := m.oldValue(ctx)
  31835. if err != nil {
  31836. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31837. }
  31838. return oldValue.TotalFriend, nil
  31839. }
  31840. // AddTotalFriend adds u to the "total_friend" field.
  31841. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31842. if m.addtotal_friend != nil {
  31843. *m.addtotal_friend += u
  31844. } else {
  31845. m.addtotal_friend = &u
  31846. }
  31847. }
  31848. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31849. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31850. v := m.addtotal_friend
  31851. if v == nil {
  31852. return
  31853. }
  31854. return *v, true
  31855. }
  31856. // ResetTotalFriend resets all changes to the "total_friend" field.
  31857. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31858. m.total_friend = nil
  31859. m.addtotal_friend = nil
  31860. }
  31861. // SetTotalGroup sets the "total_group" field.
  31862. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31863. m.total_group = &u
  31864. m.addtotal_group = nil
  31865. }
  31866. // TotalGroup returns the value of the "total_group" field in the mutation.
  31867. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31868. v := m.total_group
  31869. if v == nil {
  31870. return
  31871. }
  31872. return *v, true
  31873. }
  31874. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31875. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31877. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31878. if !m.op.Is(OpUpdateOne) {
  31879. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31880. }
  31881. if m.id == nil || m.oldValue == nil {
  31882. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31883. }
  31884. oldValue, err := m.oldValue(ctx)
  31885. if err != nil {
  31886. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31887. }
  31888. return oldValue.TotalGroup, nil
  31889. }
  31890. // AddTotalGroup adds u to the "total_group" field.
  31891. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31892. if m.addtotal_group != nil {
  31893. *m.addtotal_group += u
  31894. } else {
  31895. m.addtotal_group = &u
  31896. }
  31897. }
  31898. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31899. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31900. v := m.addtotal_group
  31901. if v == nil {
  31902. return
  31903. }
  31904. return *v, true
  31905. }
  31906. // ResetTotalGroup resets all changes to the "total_group" field.
  31907. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31908. m.total_group = nil
  31909. m.addtotal_group = nil
  31910. }
  31911. // SetAccountBalance sets the "account_balance" field.
  31912. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31913. m.account_balance = &u
  31914. m.addaccount_balance = nil
  31915. }
  31916. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31917. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31918. v := m.account_balance
  31919. if v == nil {
  31920. return
  31921. }
  31922. return *v, true
  31923. }
  31924. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31925. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31927. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31928. if !m.op.Is(OpUpdateOne) {
  31929. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31930. }
  31931. if m.id == nil || m.oldValue == nil {
  31932. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31933. }
  31934. oldValue, err := m.oldValue(ctx)
  31935. if err != nil {
  31936. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31937. }
  31938. return oldValue.AccountBalance, nil
  31939. }
  31940. // AddAccountBalance adds u to the "account_balance" field.
  31941. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31942. if m.addaccount_balance != nil {
  31943. *m.addaccount_balance += u
  31944. } else {
  31945. m.addaccount_balance = &u
  31946. }
  31947. }
  31948. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31949. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31950. v := m.addaccount_balance
  31951. if v == nil {
  31952. return
  31953. }
  31954. return *v, true
  31955. }
  31956. // ResetAccountBalance resets all changes to the "account_balance" field.
  31957. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31958. m.account_balance = nil
  31959. m.addaccount_balance = nil
  31960. }
  31961. // SetConsumeToken sets the "consume_token" field.
  31962. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31963. m.consume_token = &u
  31964. m.addconsume_token = nil
  31965. }
  31966. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31967. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31968. v := m.consume_token
  31969. if v == nil {
  31970. return
  31971. }
  31972. return *v, true
  31973. }
  31974. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31975. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31977. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31978. if !m.op.Is(OpUpdateOne) {
  31979. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31980. }
  31981. if m.id == nil || m.oldValue == nil {
  31982. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31983. }
  31984. oldValue, err := m.oldValue(ctx)
  31985. if err != nil {
  31986. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31987. }
  31988. return oldValue.ConsumeToken, nil
  31989. }
  31990. // AddConsumeToken adds u to the "consume_token" field.
  31991. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31992. if m.addconsume_token != nil {
  31993. *m.addconsume_token += u
  31994. } else {
  31995. m.addconsume_token = &u
  31996. }
  31997. }
  31998. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31999. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  32000. v := m.addconsume_token
  32001. if v == nil {
  32002. return
  32003. }
  32004. return *v, true
  32005. }
  32006. // ResetConsumeToken resets all changes to the "consume_token" field.
  32007. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  32008. m.consume_token = nil
  32009. m.addconsume_token = nil
  32010. }
  32011. // SetActiveUser sets the "active_user" field.
  32012. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  32013. m.active_user = &u
  32014. m.addactive_user = nil
  32015. }
  32016. // ActiveUser returns the value of the "active_user" field in the mutation.
  32017. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  32018. v := m.active_user
  32019. if v == nil {
  32020. return
  32021. }
  32022. return *v, true
  32023. }
  32024. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  32025. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32027. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32028. if !m.op.Is(OpUpdateOne) {
  32029. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32030. }
  32031. if m.id == nil || m.oldValue == nil {
  32032. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32033. }
  32034. oldValue, err := m.oldValue(ctx)
  32035. if err != nil {
  32036. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32037. }
  32038. return oldValue.ActiveUser, nil
  32039. }
  32040. // AddActiveUser adds u to the "active_user" field.
  32041. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32042. if m.addactive_user != nil {
  32043. *m.addactive_user += u
  32044. } else {
  32045. m.addactive_user = &u
  32046. }
  32047. }
  32048. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32049. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32050. v := m.addactive_user
  32051. if v == nil {
  32052. return
  32053. }
  32054. return *v, true
  32055. }
  32056. // ResetActiveUser resets all changes to the "active_user" field.
  32057. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32058. m.active_user = nil
  32059. m.addactive_user = nil
  32060. }
  32061. // SetNewUser sets the "new_user" field.
  32062. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32063. m.new_user = &i
  32064. m.addnew_user = nil
  32065. }
  32066. // NewUser returns the value of the "new_user" field in the mutation.
  32067. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32068. v := m.new_user
  32069. if v == nil {
  32070. return
  32071. }
  32072. return *v, true
  32073. }
  32074. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32075. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32077. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32078. if !m.op.Is(OpUpdateOne) {
  32079. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32080. }
  32081. if m.id == nil || m.oldValue == nil {
  32082. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32083. }
  32084. oldValue, err := m.oldValue(ctx)
  32085. if err != nil {
  32086. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32087. }
  32088. return oldValue.NewUser, nil
  32089. }
  32090. // AddNewUser adds i to the "new_user" field.
  32091. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32092. if m.addnew_user != nil {
  32093. *m.addnew_user += i
  32094. } else {
  32095. m.addnew_user = &i
  32096. }
  32097. }
  32098. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32099. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32100. v := m.addnew_user
  32101. if v == nil {
  32102. return
  32103. }
  32104. return *v, true
  32105. }
  32106. // ResetNewUser resets all changes to the "new_user" field.
  32107. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32108. m.new_user = nil
  32109. m.addnew_user = nil
  32110. }
  32111. // SetLabelDist sets the "label_dist" field.
  32112. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32113. m.label_dist = &ctd
  32114. m.appendlabel_dist = nil
  32115. }
  32116. // LabelDist returns the value of the "label_dist" field in the mutation.
  32117. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32118. v := m.label_dist
  32119. if v == nil {
  32120. return
  32121. }
  32122. return *v, true
  32123. }
  32124. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32125. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32127. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32128. if !m.op.Is(OpUpdateOne) {
  32129. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32130. }
  32131. if m.id == nil || m.oldValue == nil {
  32132. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32133. }
  32134. oldValue, err := m.oldValue(ctx)
  32135. if err != nil {
  32136. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32137. }
  32138. return oldValue.LabelDist, nil
  32139. }
  32140. // AppendLabelDist adds ctd to the "label_dist" field.
  32141. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32142. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32143. }
  32144. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32145. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32146. if len(m.appendlabel_dist) == 0 {
  32147. return nil, false
  32148. }
  32149. return m.appendlabel_dist, true
  32150. }
  32151. // ResetLabelDist resets all changes to the "label_dist" field.
  32152. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32153. m.label_dist = nil
  32154. m.appendlabel_dist = nil
  32155. }
  32156. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32157. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32158. m.predicates = append(m.predicates, ps...)
  32159. }
  32160. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32161. // users can use type-assertion to append predicates that do not depend on any generated package.
  32162. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32163. p := make([]predicate.UsageStatisticMonth, len(ps))
  32164. for i := range ps {
  32165. p[i] = ps[i]
  32166. }
  32167. m.Where(p...)
  32168. }
  32169. // Op returns the operation name.
  32170. func (m *UsageStatisticMonthMutation) Op() Op {
  32171. return m.op
  32172. }
  32173. // SetOp allows setting the mutation operation.
  32174. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32175. m.op = op
  32176. }
  32177. // Type returns the node type of this mutation (UsageStatisticMonth).
  32178. func (m *UsageStatisticMonthMutation) Type() string {
  32179. return m.typ
  32180. }
  32181. // Fields returns all fields that were changed during this mutation. Note that in
  32182. // order to get all numeric fields that were incremented/decremented, call
  32183. // AddedFields().
  32184. func (m *UsageStatisticMonthMutation) Fields() []string {
  32185. fields := make([]string, 0, 17)
  32186. if m.created_at != nil {
  32187. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32188. }
  32189. if m.updated_at != nil {
  32190. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32191. }
  32192. if m.status != nil {
  32193. fields = append(fields, usagestatisticmonth.FieldStatus)
  32194. }
  32195. if m.deleted_at != nil {
  32196. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32197. }
  32198. if m.addtime != nil {
  32199. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32200. }
  32201. if m._type != nil {
  32202. fields = append(fields, usagestatisticmonth.FieldType)
  32203. }
  32204. if m.bot_id != nil {
  32205. fields = append(fields, usagestatisticmonth.FieldBotID)
  32206. }
  32207. if m.organization_id != nil {
  32208. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32209. }
  32210. if m.ai_response != nil {
  32211. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32212. }
  32213. if m.sop_run != nil {
  32214. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32215. }
  32216. if m.total_friend != nil {
  32217. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32218. }
  32219. if m.total_group != nil {
  32220. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32221. }
  32222. if m.account_balance != nil {
  32223. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32224. }
  32225. if m.consume_token != nil {
  32226. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32227. }
  32228. if m.active_user != nil {
  32229. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32230. }
  32231. if m.new_user != nil {
  32232. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32233. }
  32234. if m.label_dist != nil {
  32235. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32236. }
  32237. return fields
  32238. }
  32239. // Field returns the value of a field with the given name. The second boolean
  32240. // return value indicates that this field was not set, or was not defined in the
  32241. // schema.
  32242. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32243. switch name {
  32244. case usagestatisticmonth.FieldCreatedAt:
  32245. return m.CreatedAt()
  32246. case usagestatisticmonth.FieldUpdatedAt:
  32247. return m.UpdatedAt()
  32248. case usagestatisticmonth.FieldStatus:
  32249. return m.Status()
  32250. case usagestatisticmonth.FieldDeletedAt:
  32251. return m.DeletedAt()
  32252. case usagestatisticmonth.FieldAddtime:
  32253. return m.Addtime()
  32254. case usagestatisticmonth.FieldType:
  32255. return m.GetType()
  32256. case usagestatisticmonth.FieldBotID:
  32257. return m.BotID()
  32258. case usagestatisticmonth.FieldOrganizationID:
  32259. return m.OrganizationID()
  32260. case usagestatisticmonth.FieldAiResponse:
  32261. return m.AiResponse()
  32262. case usagestatisticmonth.FieldSopRun:
  32263. return m.SopRun()
  32264. case usagestatisticmonth.FieldTotalFriend:
  32265. return m.TotalFriend()
  32266. case usagestatisticmonth.FieldTotalGroup:
  32267. return m.TotalGroup()
  32268. case usagestatisticmonth.FieldAccountBalance:
  32269. return m.AccountBalance()
  32270. case usagestatisticmonth.FieldConsumeToken:
  32271. return m.ConsumeToken()
  32272. case usagestatisticmonth.FieldActiveUser:
  32273. return m.ActiveUser()
  32274. case usagestatisticmonth.FieldNewUser:
  32275. return m.NewUser()
  32276. case usagestatisticmonth.FieldLabelDist:
  32277. return m.LabelDist()
  32278. }
  32279. return nil, false
  32280. }
  32281. // OldField returns the old value of the field from the database. An error is
  32282. // returned if the mutation operation is not UpdateOne, or the query to the
  32283. // database failed.
  32284. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32285. switch name {
  32286. case usagestatisticmonth.FieldCreatedAt:
  32287. return m.OldCreatedAt(ctx)
  32288. case usagestatisticmonth.FieldUpdatedAt:
  32289. return m.OldUpdatedAt(ctx)
  32290. case usagestatisticmonth.FieldStatus:
  32291. return m.OldStatus(ctx)
  32292. case usagestatisticmonth.FieldDeletedAt:
  32293. return m.OldDeletedAt(ctx)
  32294. case usagestatisticmonth.FieldAddtime:
  32295. return m.OldAddtime(ctx)
  32296. case usagestatisticmonth.FieldType:
  32297. return m.OldType(ctx)
  32298. case usagestatisticmonth.FieldBotID:
  32299. return m.OldBotID(ctx)
  32300. case usagestatisticmonth.FieldOrganizationID:
  32301. return m.OldOrganizationID(ctx)
  32302. case usagestatisticmonth.FieldAiResponse:
  32303. return m.OldAiResponse(ctx)
  32304. case usagestatisticmonth.FieldSopRun:
  32305. return m.OldSopRun(ctx)
  32306. case usagestatisticmonth.FieldTotalFriend:
  32307. return m.OldTotalFriend(ctx)
  32308. case usagestatisticmonth.FieldTotalGroup:
  32309. return m.OldTotalGroup(ctx)
  32310. case usagestatisticmonth.FieldAccountBalance:
  32311. return m.OldAccountBalance(ctx)
  32312. case usagestatisticmonth.FieldConsumeToken:
  32313. return m.OldConsumeToken(ctx)
  32314. case usagestatisticmonth.FieldActiveUser:
  32315. return m.OldActiveUser(ctx)
  32316. case usagestatisticmonth.FieldNewUser:
  32317. return m.OldNewUser(ctx)
  32318. case usagestatisticmonth.FieldLabelDist:
  32319. return m.OldLabelDist(ctx)
  32320. }
  32321. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32322. }
  32323. // SetField sets the value of a field with the given name. It returns an error if
  32324. // the field is not defined in the schema, or if the type mismatched the field
  32325. // type.
  32326. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32327. switch name {
  32328. case usagestatisticmonth.FieldCreatedAt:
  32329. v, ok := value.(time.Time)
  32330. if !ok {
  32331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32332. }
  32333. m.SetCreatedAt(v)
  32334. return nil
  32335. case usagestatisticmonth.FieldUpdatedAt:
  32336. v, ok := value.(time.Time)
  32337. if !ok {
  32338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32339. }
  32340. m.SetUpdatedAt(v)
  32341. return nil
  32342. case usagestatisticmonth.FieldStatus:
  32343. v, ok := value.(uint8)
  32344. if !ok {
  32345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32346. }
  32347. m.SetStatus(v)
  32348. return nil
  32349. case usagestatisticmonth.FieldDeletedAt:
  32350. v, ok := value.(time.Time)
  32351. if !ok {
  32352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32353. }
  32354. m.SetDeletedAt(v)
  32355. return nil
  32356. case usagestatisticmonth.FieldAddtime:
  32357. v, ok := value.(uint64)
  32358. if !ok {
  32359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32360. }
  32361. m.SetAddtime(v)
  32362. return nil
  32363. case usagestatisticmonth.FieldType:
  32364. v, ok := value.(int)
  32365. if !ok {
  32366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32367. }
  32368. m.SetType(v)
  32369. return nil
  32370. case usagestatisticmonth.FieldBotID:
  32371. v, ok := value.(string)
  32372. if !ok {
  32373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32374. }
  32375. m.SetBotID(v)
  32376. return nil
  32377. case usagestatisticmonth.FieldOrganizationID:
  32378. v, ok := value.(uint64)
  32379. if !ok {
  32380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32381. }
  32382. m.SetOrganizationID(v)
  32383. return nil
  32384. case usagestatisticmonth.FieldAiResponse:
  32385. v, ok := value.(uint64)
  32386. if !ok {
  32387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32388. }
  32389. m.SetAiResponse(v)
  32390. return nil
  32391. case usagestatisticmonth.FieldSopRun:
  32392. v, ok := value.(uint64)
  32393. if !ok {
  32394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32395. }
  32396. m.SetSopRun(v)
  32397. return nil
  32398. case usagestatisticmonth.FieldTotalFriend:
  32399. v, ok := value.(uint64)
  32400. if !ok {
  32401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32402. }
  32403. m.SetTotalFriend(v)
  32404. return nil
  32405. case usagestatisticmonth.FieldTotalGroup:
  32406. v, ok := value.(uint64)
  32407. if !ok {
  32408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32409. }
  32410. m.SetTotalGroup(v)
  32411. return nil
  32412. case usagestatisticmonth.FieldAccountBalance:
  32413. v, ok := value.(uint64)
  32414. if !ok {
  32415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32416. }
  32417. m.SetAccountBalance(v)
  32418. return nil
  32419. case usagestatisticmonth.FieldConsumeToken:
  32420. v, ok := value.(uint64)
  32421. if !ok {
  32422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32423. }
  32424. m.SetConsumeToken(v)
  32425. return nil
  32426. case usagestatisticmonth.FieldActiveUser:
  32427. v, ok := value.(uint64)
  32428. if !ok {
  32429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32430. }
  32431. m.SetActiveUser(v)
  32432. return nil
  32433. case usagestatisticmonth.FieldNewUser:
  32434. v, ok := value.(int64)
  32435. if !ok {
  32436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32437. }
  32438. m.SetNewUser(v)
  32439. return nil
  32440. case usagestatisticmonth.FieldLabelDist:
  32441. v, ok := value.([]custom_types.LabelDist)
  32442. if !ok {
  32443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32444. }
  32445. m.SetLabelDist(v)
  32446. return nil
  32447. }
  32448. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32449. }
  32450. // AddedFields returns all numeric fields that were incremented/decremented during
  32451. // this mutation.
  32452. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32453. var fields []string
  32454. if m.addstatus != nil {
  32455. fields = append(fields, usagestatisticmonth.FieldStatus)
  32456. }
  32457. if m.addaddtime != nil {
  32458. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32459. }
  32460. if m.add_type != nil {
  32461. fields = append(fields, usagestatisticmonth.FieldType)
  32462. }
  32463. if m.addorganization_id != nil {
  32464. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32465. }
  32466. if m.addai_response != nil {
  32467. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32468. }
  32469. if m.addsop_run != nil {
  32470. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32471. }
  32472. if m.addtotal_friend != nil {
  32473. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32474. }
  32475. if m.addtotal_group != nil {
  32476. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32477. }
  32478. if m.addaccount_balance != nil {
  32479. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32480. }
  32481. if m.addconsume_token != nil {
  32482. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32483. }
  32484. if m.addactive_user != nil {
  32485. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32486. }
  32487. if m.addnew_user != nil {
  32488. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32489. }
  32490. return fields
  32491. }
  32492. // AddedField returns the numeric value that was incremented/decremented on a field
  32493. // with the given name. The second boolean return value indicates that this field
  32494. // was not set, or was not defined in the schema.
  32495. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32496. switch name {
  32497. case usagestatisticmonth.FieldStatus:
  32498. return m.AddedStatus()
  32499. case usagestatisticmonth.FieldAddtime:
  32500. return m.AddedAddtime()
  32501. case usagestatisticmonth.FieldType:
  32502. return m.AddedType()
  32503. case usagestatisticmonth.FieldOrganizationID:
  32504. return m.AddedOrganizationID()
  32505. case usagestatisticmonth.FieldAiResponse:
  32506. return m.AddedAiResponse()
  32507. case usagestatisticmonth.FieldSopRun:
  32508. return m.AddedSopRun()
  32509. case usagestatisticmonth.FieldTotalFriend:
  32510. return m.AddedTotalFriend()
  32511. case usagestatisticmonth.FieldTotalGroup:
  32512. return m.AddedTotalGroup()
  32513. case usagestatisticmonth.FieldAccountBalance:
  32514. return m.AddedAccountBalance()
  32515. case usagestatisticmonth.FieldConsumeToken:
  32516. return m.AddedConsumeToken()
  32517. case usagestatisticmonth.FieldActiveUser:
  32518. return m.AddedActiveUser()
  32519. case usagestatisticmonth.FieldNewUser:
  32520. return m.AddedNewUser()
  32521. }
  32522. return nil, false
  32523. }
  32524. // AddField adds the value to the field with the given name. It returns an error if
  32525. // the field is not defined in the schema, or if the type mismatched the field
  32526. // type.
  32527. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32528. switch name {
  32529. case usagestatisticmonth.FieldStatus:
  32530. v, ok := value.(int8)
  32531. if !ok {
  32532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32533. }
  32534. m.AddStatus(v)
  32535. return nil
  32536. case usagestatisticmonth.FieldAddtime:
  32537. v, ok := value.(int64)
  32538. if !ok {
  32539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32540. }
  32541. m.AddAddtime(v)
  32542. return nil
  32543. case usagestatisticmonth.FieldType:
  32544. v, ok := value.(int)
  32545. if !ok {
  32546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32547. }
  32548. m.AddType(v)
  32549. return nil
  32550. case usagestatisticmonth.FieldOrganizationID:
  32551. v, ok := value.(int64)
  32552. if !ok {
  32553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32554. }
  32555. m.AddOrganizationID(v)
  32556. return nil
  32557. case usagestatisticmonth.FieldAiResponse:
  32558. v, ok := value.(int64)
  32559. if !ok {
  32560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32561. }
  32562. m.AddAiResponse(v)
  32563. return nil
  32564. case usagestatisticmonth.FieldSopRun:
  32565. v, ok := value.(int64)
  32566. if !ok {
  32567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32568. }
  32569. m.AddSopRun(v)
  32570. return nil
  32571. case usagestatisticmonth.FieldTotalFriend:
  32572. v, ok := value.(int64)
  32573. if !ok {
  32574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32575. }
  32576. m.AddTotalFriend(v)
  32577. return nil
  32578. case usagestatisticmonth.FieldTotalGroup:
  32579. v, ok := value.(int64)
  32580. if !ok {
  32581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32582. }
  32583. m.AddTotalGroup(v)
  32584. return nil
  32585. case usagestatisticmonth.FieldAccountBalance:
  32586. v, ok := value.(int64)
  32587. if !ok {
  32588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32589. }
  32590. m.AddAccountBalance(v)
  32591. return nil
  32592. case usagestatisticmonth.FieldConsumeToken:
  32593. v, ok := value.(int64)
  32594. if !ok {
  32595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32596. }
  32597. m.AddConsumeToken(v)
  32598. return nil
  32599. case usagestatisticmonth.FieldActiveUser:
  32600. v, ok := value.(int64)
  32601. if !ok {
  32602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32603. }
  32604. m.AddActiveUser(v)
  32605. return nil
  32606. case usagestatisticmonth.FieldNewUser:
  32607. v, ok := value.(int64)
  32608. if !ok {
  32609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32610. }
  32611. m.AddNewUser(v)
  32612. return nil
  32613. }
  32614. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32615. }
  32616. // ClearedFields returns all nullable fields that were cleared during this
  32617. // mutation.
  32618. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32619. var fields []string
  32620. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32621. fields = append(fields, usagestatisticmonth.FieldStatus)
  32622. }
  32623. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32624. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32625. }
  32626. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32627. fields = append(fields, usagestatisticmonth.FieldBotID)
  32628. }
  32629. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32630. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32631. }
  32632. return fields
  32633. }
  32634. // FieldCleared returns a boolean indicating if a field with the given name was
  32635. // cleared in this mutation.
  32636. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32637. _, ok := m.clearedFields[name]
  32638. return ok
  32639. }
  32640. // ClearField clears the value of the field with the given name. It returns an
  32641. // error if the field is not defined in the schema.
  32642. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32643. switch name {
  32644. case usagestatisticmonth.FieldStatus:
  32645. m.ClearStatus()
  32646. return nil
  32647. case usagestatisticmonth.FieldDeletedAt:
  32648. m.ClearDeletedAt()
  32649. return nil
  32650. case usagestatisticmonth.FieldBotID:
  32651. m.ClearBotID()
  32652. return nil
  32653. case usagestatisticmonth.FieldOrganizationID:
  32654. m.ClearOrganizationID()
  32655. return nil
  32656. }
  32657. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32658. }
  32659. // ResetField resets all changes in the mutation for the field with the given name.
  32660. // It returns an error if the field is not defined in the schema.
  32661. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32662. switch name {
  32663. case usagestatisticmonth.FieldCreatedAt:
  32664. m.ResetCreatedAt()
  32665. return nil
  32666. case usagestatisticmonth.FieldUpdatedAt:
  32667. m.ResetUpdatedAt()
  32668. return nil
  32669. case usagestatisticmonth.FieldStatus:
  32670. m.ResetStatus()
  32671. return nil
  32672. case usagestatisticmonth.FieldDeletedAt:
  32673. m.ResetDeletedAt()
  32674. return nil
  32675. case usagestatisticmonth.FieldAddtime:
  32676. m.ResetAddtime()
  32677. return nil
  32678. case usagestatisticmonth.FieldType:
  32679. m.ResetType()
  32680. return nil
  32681. case usagestatisticmonth.FieldBotID:
  32682. m.ResetBotID()
  32683. return nil
  32684. case usagestatisticmonth.FieldOrganizationID:
  32685. m.ResetOrganizationID()
  32686. return nil
  32687. case usagestatisticmonth.FieldAiResponse:
  32688. m.ResetAiResponse()
  32689. return nil
  32690. case usagestatisticmonth.FieldSopRun:
  32691. m.ResetSopRun()
  32692. return nil
  32693. case usagestatisticmonth.FieldTotalFriend:
  32694. m.ResetTotalFriend()
  32695. return nil
  32696. case usagestatisticmonth.FieldTotalGroup:
  32697. m.ResetTotalGroup()
  32698. return nil
  32699. case usagestatisticmonth.FieldAccountBalance:
  32700. m.ResetAccountBalance()
  32701. return nil
  32702. case usagestatisticmonth.FieldConsumeToken:
  32703. m.ResetConsumeToken()
  32704. return nil
  32705. case usagestatisticmonth.FieldActiveUser:
  32706. m.ResetActiveUser()
  32707. return nil
  32708. case usagestatisticmonth.FieldNewUser:
  32709. m.ResetNewUser()
  32710. return nil
  32711. case usagestatisticmonth.FieldLabelDist:
  32712. m.ResetLabelDist()
  32713. return nil
  32714. }
  32715. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32716. }
  32717. // AddedEdges returns all edge names that were set/added in this mutation.
  32718. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32719. edges := make([]string, 0, 0)
  32720. return edges
  32721. }
  32722. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32723. // name in this mutation.
  32724. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32725. return nil
  32726. }
  32727. // RemovedEdges returns all edge names that were removed in this mutation.
  32728. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32729. edges := make([]string, 0, 0)
  32730. return edges
  32731. }
  32732. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32733. // the given name in this mutation.
  32734. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32735. return nil
  32736. }
  32737. // ClearedEdges returns all edge names that were cleared in this mutation.
  32738. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32739. edges := make([]string, 0, 0)
  32740. return edges
  32741. }
  32742. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32743. // was cleared in this mutation.
  32744. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32745. return false
  32746. }
  32747. // ClearEdge clears the value of the edge with the given name. It returns an error
  32748. // if that edge is not defined in the schema.
  32749. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32750. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32751. }
  32752. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32753. // It returns an error if the edge is not defined in the schema.
  32754. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32755. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32756. }
  32757. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32758. type UsageTotalMutation struct {
  32759. config
  32760. op Op
  32761. typ string
  32762. id *uint64
  32763. created_at *time.Time
  32764. updated_at *time.Time
  32765. status *uint8
  32766. addstatus *int8
  32767. _type *int
  32768. add_type *int
  32769. bot_id *string
  32770. total_tokens *uint64
  32771. addtotal_tokens *int64
  32772. start_index *uint64
  32773. addstart_index *int64
  32774. end_index *uint64
  32775. addend_index *int64
  32776. organization_id *uint64
  32777. addorganization_id *int64
  32778. clearedFields map[string]struct{}
  32779. done bool
  32780. oldValue func(context.Context) (*UsageTotal, error)
  32781. predicates []predicate.UsageTotal
  32782. }
  32783. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32784. // usagetotalOption allows management of the mutation configuration using functional options.
  32785. type usagetotalOption func(*UsageTotalMutation)
  32786. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32787. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32788. m := &UsageTotalMutation{
  32789. config: c,
  32790. op: op,
  32791. typ: TypeUsageTotal,
  32792. clearedFields: make(map[string]struct{}),
  32793. }
  32794. for _, opt := range opts {
  32795. opt(m)
  32796. }
  32797. return m
  32798. }
  32799. // withUsageTotalID sets the ID field of the mutation.
  32800. func withUsageTotalID(id uint64) usagetotalOption {
  32801. return func(m *UsageTotalMutation) {
  32802. var (
  32803. err error
  32804. once sync.Once
  32805. value *UsageTotal
  32806. )
  32807. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32808. once.Do(func() {
  32809. if m.done {
  32810. err = errors.New("querying old values post mutation is not allowed")
  32811. } else {
  32812. value, err = m.Client().UsageTotal.Get(ctx, id)
  32813. }
  32814. })
  32815. return value, err
  32816. }
  32817. m.id = &id
  32818. }
  32819. }
  32820. // withUsageTotal sets the old UsageTotal of the mutation.
  32821. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32822. return func(m *UsageTotalMutation) {
  32823. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32824. return node, nil
  32825. }
  32826. m.id = &node.ID
  32827. }
  32828. }
  32829. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32830. // executed in a transaction (ent.Tx), a transactional client is returned.
  32831. func (m UsageTotalMutation) Client() *Client {
  32832. client := &Client{config: m.config}
  32833. client.init()
  32834. return client
  32835. }
  32836. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32837. // it returns an error otherwise.
  32838. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32839. if _, ok := m.driver.(*txDriver); !ok {
  32840. return nil, errors.New("ent: mutation is not running in a transaction")
  32841. }
  32842. tx := &Tx{config: m.config}
  32843. tx.init()
  32844. return tx, nil
  32845. }
  32846. // SetID sets the value of the id field. Note that this
  32847. // operation is only accepted on creation of UsageTotal entities.
  32848. func (m *UsageTotalMutation) SetID(id uint64) {
  32849. m.id = &id
  32850. }
  32851. // ID returns the ID value in the mutation. Note that the ID is only available
  32852. // if it was provided to the builder or after it was returned from the database.
  32853. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32854. if m.id == nil {
  32855. return
  32856. }
  32857. return *m.id, true
  32858. }
  32859. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32860. // That means, if the mutation is applied within a transaction with an isolation level such
  32861. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32862. // or updated by the mutation.
  32863. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32864. switch {
  32865. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32866. id, exists := m.ID()
  32867. if exists {
  32868. return []uint64{id}, nil
  32869. }
  32870. fallthrough
  32871. case m.op.Is(OpUpdate | OpDelete):
  32872. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32873. default:
  32874. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32875. }
  32876. }
  32877. // SetCreatedAt sets the "created_at" field.
  32878. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32879. m.created_at = &t
  32880. }
  32881. // CreatedAt returns the value of the "created_at" field in the mutation.
  32882. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32883. v := m.created_at
  32884. if v == nil {
  32885. return
  32886. }
  32887. return *v, true
  32888. }
  32889. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32890. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32892. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32893. if !m.op.Is(OpUpdateOne) {
  32894. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32895. }
  32896. if m.id == nil || m.oldValue == nil {
  32897. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32898. }
  32899. oldValue, err := m.oldValue(ctx)
  32900. if err != nil {
  32901. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32902. }
  32903. return oldValue.CreatedAt, nil
  32904. }
  32905. // ResetCreatedAt resets all changes to the "created_at" field.
  32906. func (m *UsageTotalMutation) ResetCreatedAt() {
  32907. m.created_at = nil
  32908. }
  32909. // SetUpdatedAt sets the "updated_at" field.
  32910. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32911. m.updated_at = &t
  32912. }
  32913. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32914. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32915. v := m.updated_at
  32916. if v == nil {
  32917. return
  32918. }
  32919. return *v, true
  32920. }
  32921. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32922. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32924. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32925. if !m.op.Is(OpUpdateOne) {
  32926. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32927. }
  32928. if m.id == nil || m.oldValue == nil {
  32929. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32930. }
  32931. oldValue, err := m.oldValue(ctx)
  32932. if err != nil {
  32933. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32934. }
  32935. return oldValue.UpdatedAt, nil
  32936. }
  32937. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32938. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32939. m.updated_at = nil
  32940. }
  32941. // SetStatus sets the "status" field.
  32942. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32943. m.status = &u
  32944. m.addstatus = nil
  32945. }
  32946. // Status returns the value of the "status" field in the mutation.
  32947. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32948. v := m.status
  32949. if v == nil {
  32950. return
  32951. }
  32952. return *v, true
  32953. }
  32954. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32955. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32957. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32958. if !m.op.Is(OpUpdateOne) {
  32959. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32960. }
  32961. if m.id == nil || m.oldValue == nil {
  32962. return v, errors.New("OldStatus requires an ID field in the mutation")
  32963. }
  32964. oldValue, err := m.oldValue(ctx)
  32965. if err != nil {
  32966. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32967. }
  32968. return oldValue.Status, nil
  32969. }
  32970. // AddStatus adds u to the "status" field.
  32971. func (m *UsageTotalMutation) AddStatus(u int8) {
  32972. if m.addstatus != nil {
  32973. *m.addstatus += u
  32974. } else {
  32975. m.addstatus = &u
  32976. }
  32977. }
  32978. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32979. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32980. v := m.addstatus
  32981. if v == nil {
  32982. return
  32983. }
  32984. return *v, true
  32985. }
  32986. // ClearStatus clears the value of the "status" field.
  32987. func (m *UsageTotalMutation) ClearStatus() {
  32988. m.status = nil
  32989. m.addstatus = nil
  32990. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32991. }
  32992. // StatusCleared returns if the "status" field was cleared in this mutation.
  32993. func (m *UsageTotalMutation) StatusCleared() bool {
  32994. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32995. return ok
  32996. }
  32997. // ResetStatus resets all changes to the "status" field.
  32998. func (m *UsageTotalMutation) ResetStatus() {
  32999. m.status = nil
  33000. m.addstatus = nil
  33001. delete(m.clearedFields, usagetotal.FieldStatus)
  33002. }
  33003. // SetType sets the "type" field.
  33004. func (m *UsageTotalMutation) SetType(i int) {
  33005. m._type = &i
  33006. m.add_type = nil
  33007. }
  33008. // GetType returns the value of the "type" field in the mutation.
  33009. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  33010. v := m._type
  33011. if v == nil {
  33012. return
  33013. }
  33014. return *v, true
  33015. }
  33016. // OldType returns the old "type" field's value of the UsageTotal entity.
  33017. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33019. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  33020. if !m.op.Is(OpUpdateOne) {
  33021. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33022. }
  33023. if m.id == nil || m.oldValue == nil {
  33024. return v, errors.New("OldType requires an ID field in the mutation")
  33025. }
  33026. oldValue, err := m.oldValue(ctx)
  33027. if err != nil {
  33028. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33029. }
  33030. return oldValue.Type, nil
  33031. }
  33032. // AddType adds i to the "type" field.
  33033. func (m *UsageTotalMutation) AddType(i int) {
  33034. if m.add_type != nil {
  33035. *m.add_type += i
  33036. } else {
  33037. m.add_type = &i
  33038. }
  33039. }
  33040. // AddedType returns the value that was added to the "type" field in this mutation.
  33041. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33042. v := m.add_type
  33043. if v == nil {
  33044. return
  33045. }
  33046. return *v, true
  33047. }
  33048. // ClearType clears the value of the "type" field.
  33049. func (m *UsageTotalMutation) ClearType() {
  33050. m._type = nil
  33051. m.add_type = nil
  33052. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33053. }
  33054. // TypeCleared returns if the "type" field was cleared in this mutation.
  33055. func (m *UsageTotalMutation) TypeCleared() bool {
  33056. _, ok := m.clearedFields[usagetotal.FieldType]
  33057. return ok
  33058. }
  33059. // ResetType resets all changes to the "type" field.
  33060. func (m *UsageTotalMutation) ResetType() {
  33061. m._type = nil
  33062. m.add_type = nil
  33063. delete(m.clearedFields, usagetotal.FieldType)
  33064. }
  33065. // SetBotID sets the "bot_id" field.
  33066. func (m *UsageTotalMutation) SetBotID(s string) {
  33067. m.bot_id = &s
  33068. }
  33069. // BotID returns the value of the "bot_id" field in the mutation.
  33070. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33071. v := m.bot_id
  33072. if v == nil {
  33073. return
  33074. }
  33075. return *v, true
  33076. }
  33077. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33078. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33080. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33081. if !m.op.Is(OpUpdateOne) {
  33082. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33083. }
  33084. if m.id == nil || m.oldValue == nil {
  33085. return v, errors.New("OldBotID requires an ID field in the mutation")
  33086. }
  33087. oldValue, err := m.oldValue(ctx)
  33088. if err != nil {
  33089. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33090. }
  33091. return oldValue.BotID, nil
  33092. }
  33093. // ResetBotID resets all changes to the "bot_id" field.
  33094. func (m *UsageTotalMutation) ResetBotID() {
  33095. m.bot_id = nil
  33096. }
  33097. // SetTotalTokens sets the "total_tokens" field.
  33098. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33099. m.total_tokens = &u
  33100. m.addtotal_tokens = nil
  33101. }
  33102. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33103. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33104. v := m.total_tokens
  33105. if v == nil {
  33106. return
  33107. }
  33108. return *v, true
  33109. }
  33110. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33111. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33113. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33114. if !m.op.Is(OpUpdateOne) {
  33115. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33116. }
  33117. if m.id == nil || m.oldValue == nil {
  33118. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33119. }
  33120. oldValue, err := m.oldValue(ctx)
  33121. if err != nil {
  33122. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33123. }
  33124. return oldValue.TotalTokens, nil
  33125. }
  33126. // AddTotalTokens adds u to the "total_tokens" field.
  33127. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33128. if m.addtotal_tokens != nil {
  33129. *m.addtotal_tokens += u
  33130. } else {
  33131. m.addtotal_tokens = &u
  33132. }
  33133. }
  33134. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33135. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33136. v := m.addtotal_tokens
  33137. if v == nil {
  33138. return
  33139. }
  33140. return *v, true
  33141. }
  33142. // ClearTotalTokens clears the value of the "total_tokens" field.
  33143. func (m *UsageTotalMutation) ClearTotalTokens() {
  33144. m.total_tokens = nil
  33145. m.addtotal_tokens = nil
  33146. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33147. }
  33148. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33149. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33150. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33151. return ok
  33152. }
  33153. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33154. func (m *UsageTotalMutation) ResetTotalTokens() {
  33155. m.total_tokens = nil
  33156. m.addtotal_tokens = nil
  33157. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33158. }
  33159. // SetStartIndex sets the "start_index" field.
  33160. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33161. m.start_index = &u
  33162. m.addstart_index = nil
  33163. }
  33164. // StartIndex returns the value of the "start_index" field in the mutation.
  33165. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33166. v := m.start_index
  33167. if v == nil {
  33168. return
  33169. }
  33170. return *v, true
  33171. }
  33172. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33173. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33175. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33176. if !m.op.Is(OpUpdateOne) {
  33177. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33178. }
  33179. if m.id == nil || m.oldValue == nil {
  33180. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33181. }
  33182. oldValue, err := m.oldValue(ctx)
  33183. if err != nil {
  33184. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33185. }
  33186. return oldValue.StartIndex, nil
  33187. }
  33188. // AddStartIndex adds u to the "start_index" field.
  33189. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33190. if m.addstart_index != nil {
  33191. *m.addstart_index += u
  33192. } else {
  33193. m.addstart_index = &u
  33194. }
  33195. }
  33196. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33197. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33198. v := m.addstart_index
  33199. if v == nil {
  33200. return
  33201. }
  33202. return *v, true
  33203. }
  33204. // ClearStartIndex clears the value of the "start_index" field.
  33205. func (m *UsageTotalMutation) ClearStartIndex() {
  33206. m.start_index = nil
  33207. m.addstart_index = nil
  33208. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33209. }
  33210. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33211. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33212. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33213. return ok
  33214. }
  33215. // ResetStartIndex resets all changes to the "start_index" field.
  33216. func (m *UsageTotalMutation) ResetStartIndex() {
  33217. m.start_index = nil
  33218. m.addstart_index = nil
  33219. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33220. }
  33221. // SetEndIndex sets the "end_index" field.
  33222. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33223. m.end_index = &u
  33224. m.addend_index = nil
  33225. }
  33226. // EndIndex returns the value of the "end_index" field in the mutation.
  33227. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33228. v := m.end_index
  33229. if v == nil {
  33230. return
  33231. }
  33232. return *v, true
  33233. }
  33234. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33235. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33237. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33238. if !m.op.Is(OpUpdateOne) {
  33239. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33240. }
  33241. if m.id == nil || m.oldValue == nil {
  33242. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33243. }
  33244. oldValue, err := m.oldValue(ctx)
  33245. if err != nil {
  33246. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33247. }
  33248. return oldValue.EndIndex, nil
  33249. }
  33250. // AddEndIndex adds u to the "end_index" field.
  33251. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33252. if m.addend_index != nil {
  33253. *m.addend_index += u
  33254. } else {
  33255. m.addend_index = &u
  33256. }
  33257. }
  33258. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33259. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33260. v := m.addend_index
  33261. if v == nil {
  33262. return
  33263. }
  33264. return *v, true
  33265. }
  33266. // ClearEndIndex clears the value of the "end_index" field.
  33267. func (m *UsageTotalMutation) ClearEndIndex() {
  33268. m.end_index = nil
  33269. m.addend_index = nil
  33270. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33271. }
  33272. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33273. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33274. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33275. return ok
  33276. }
  33277. // ResetEndIndex resets all changes to the "end_index" field.
  33278. func (m *UsageTotalMutation) ResetEndIndex() {
  33279. m.end_index = nil
  33280. m.addend_index = nil
  33281. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33282. }
  33283. // SetOrganizationID sets the "organization_id" field.
  33284. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33285. m.organization_id = &u
  33286. m.addorganization_id = nil
  33287. }
  33288. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33289. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33290. v := m.organization_id
  33291. if v == nil {
  33292. return
  33293. }
  33294. return *v, true
  33295. }
  33296. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33297. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33299. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33300. if !m.op.Is(OpUpdateOne) {
  33301. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33302. }
  33303. if m.id == nil || m.oldValue == nil {
  33304. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33305. }
  33306. oldValue, err := m.oldValue(ctx)
  33307. if err != nil {
  33308. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33309. }
  33310. return oldValue.OrganizationID, nil
  33311. }
  33312. // AddOrganizationID adds u to the "organization_id" field.
  33313. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33314. if m.addorganization_id != nil {
  33315. *m.addorganization_id += u
  33316. } else {
  33317. m.addorganization_id = &u
  33318. }
  33319. }
  33320. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33321. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33322. v := m.addorganization_id
  33323. if v == nil {
  33324. return
  33325. }
  33326. return *v, true
  33327. }
  33328. // ClearOrganizationID clears the value of the "organization_id" field.
  33329. func (m *UsageTotalMutation) ClearOrganizationID() {
  33330. m.organization_id = nil
  33331. m.addorganization_id = nil
  33332. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33333. }
  33334. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33335. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33336. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33337. return ok
  33338. }
  33339. // ResetOrganizationID resets all changes to the "organization_id" field.
  33340. func (m *UsageTotalMutation) ResetOrganizationID() {
  33341. m.organization_id = nil
  33342. m.addorganization_id = nil
  33343. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33344. }
  33345. // Where appends a list predicates to the UsageTotalMutation builder.
  33346. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33347. m.predicates = append(m.predicates, ps...)
  33348. }
  33349. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33350. // users can use type-assertion to append predicates that do not depend on any generated package.
  33351. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33352. p := make([]predicate.UsageTotal, len(ps))
  33353. for i := range ps {
  33354. p[i] = ps[i]
  33355. }
  33356. m.Where(p...)
  33357. }
  33358. // Op returns the operation name.
  33359. func (m *UsageTotalMutation) Op() Op {
  33360. return m.op
  33361. }
  33362. // SetOp allows setting the mutation operation.
  33363. func (m *UsageTotalMutation) SetOp(op Op) {
  33364. m.op = op
  33365. }
  33366. // Type returns the node type of this mutation (UsageTotal).
  33367. func (m *UsageTotalMutation) Type() string {
  33368. return m.typ
  33369. }
  33370. // Fields returns all fields that were changed during this mutation. Note that in
  33371. // order to get all numeric fields that were incremented/decremented, call
  33372. // AddedFields().
  33373. func (m *UsageTotalMutation) Fields() []string {
  33374. fields := make([]string, 0, 9)
  33375. if m.created_at != nil {
  33376. fields = append(fields, usagetotal.FieldCreatedAt)
  33377. }
  33378. if m.updated_at != nil {
  33379. fields = append(fields, usagetotal.FieldUpdatedAt)
  33380. }
  33381. if m.status != nil {
  33382. fields = append(fields, usagetotal.FieldStatus)
  33383. }
  33384. if m._type != nil {
  33385. fields = append(fields, usagetotal.FieldType)
  33386. }
  33387. if m.bot_id != nil {
  33388. fields = append(fields, usagetotal.FieldBotID)
  33389. }
  33390. if m.total_tokens != nil {
  33391. fields = append(fields, usagetotal.FieldTotalTokens)
  33392. }
  33393. if m.start_index != nil {
  33394. fields = append(fields, usagetotal.FieldStartIndex)
  33395. }
  33396. if m.end_index != nil {
  33397. fields = append(fields, usagetotal.FieldEndIndex)
  33398. }
  33399. if m.organization_id != nil {
  33400. fields = append(fields, usagetotal.FieldOrganizationID)
  33401. }
  33402. return fields
  33403. }
  33404. // Field returns the value of a field with the given name. The second boolean
  33405. // return value indicates that this field was not set, or was not defined in the
  33406. // schema.
  33407. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33408. switch name {
  33409. case usagetotal.FieldCreatedAt:
  33410. return m.CreatedAt()
  33411. case usagetotal.FieldUpdatedAt:
  33412. return m.UpdatedAt()
  33413. case usagetotal.FieldStatus:
  33414. return m.Status()
  33415. case usagetotal.FieldType:
  33416. return m.GetType()
  33417. case usagetotal.FieldBotID:
  33418. return m.BotID()
  33419. case usagetotal.FieldTotalTokens:
  33420. return m.TotalTokens()
  33421. case usagetotal.FieldStartIndex:
  33422. return m.StartIndex()
  33423. case usagetotal.FieldEndIndex:
  33424. return m.EndIndex()
  33425. case usagetotal.FieldOrganizationID:
  33426. return m.OrganizationID()
  33427. }
  33428. return nil, false
  33429. }
  33430. // OldField returns the old value of the field from the database. An error is
  33431. // returned if the mutation operation is not UpdateOne, or the query to the
  33432. // database failed.
  33433. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33434. switch name {
  33435. case usagetotal.FieldCreatedAt:
  33436. return m.OldCreatedAt(ctx)
  33437. case usagetotal.FieldUpdatedAt:
  33438. return m.OldUpdatedAt(ctx)
  33439. case usagetotal.FieldStatus:
  33440. return m.OldStatus(ctx)
  33441. case usagetotal.FieldType:
  33442. return m.OldType(ctx)
  33443. case usagetotal.FieldBotID:
  33444. return m.OldBotID(ctx)
  33445. case usagetotal.FieldTotalTokens:
  33446. return m.OldTotalTokens(ctx)
  33447. case usagetotal.FieldStartIndex:
  33448. return m.OldStartIndex(ctx)
  33449. case usagetotal.FieldEndIndex:
  33450. return m.OldEndIndex(ctx)
  33451. case usagetotal.FieldOrganizationID:
  33452. return m.OldOrganizationID(ctx)
  33453. }
  33454. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33455. }
  33456. // SetField sets the value of a field with the given name. It returns an error if
  33457. // the field is not defined in the schema, or if the type mismatched the field
  33458. // type.
  33459. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33460. switch name {
  33461. case usagetotal.FieldCreatedAt:
  33462. v, ok := value.(time.Time)
  33463. if !ok {
  33464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33465. }
  33466. m.SetCreatedAt(v)
  33467. return nil
  33468. case usagetotal.FieldUpdatedAt:
  33469. v, ok := value.(time.Time)
  33470. if !ok {
  33471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33472. }
  33473. m.SetUpdatedAt(v)
  33474. return nil
  33475. case usagetotal.FieldStatus:
  33476. v, ok := value.(uint8)
  33477. if !ok {
  33478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33479. }
  33480. m.SetStatus(v)
  33481. return nil
  33482. case usagetotal.FieldType:
  33483. v, ok := value.(int)
  33484. if !ok {
  33485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33486. }
  33487. m.SetType(v)
  33488. return nil
  33489. case usagetotal.FieldBotID:
  33490. v, ok := value.(string)
  33491. if !ok {
  33492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33493. }
  33494. m.SetBotID(v)
  33495. return nil
  33496. case usagetotal.FieldTotalTokens:
  33497. v, ok := value.(uint64)
  33498. if !ok {
  33499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33500. }
  33501. m.SetTotalTokens(v)
  33502. return nil
  33503. case usagetotal.FieldStartIndex:
  33504. v, ok := value.(uint64)
  33505. if !ok {
  33506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33507. }
  33508. m.SetStartIndex(v)
  33509. return nil
  33510. case usagetotal.FieldEndIndex:
  33511. v, ok := value.(uint64)
  33512. if !ok {
  33513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33514. }
  33515. m.SetEndIndex(v)
  33516. return nil
  33517. case usagetotal.FieldOrganizationID:
  33518. v, ok := value.(uint64)
  33519. if !ok {
  33520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33521. }
  33522. m.SetOrganizationID(v)
  33523. return nil
  33524. }
  33525. return fmt.Errorf("unknown UsageTotal field %s", name)
  33526. }
  33527. // AddedFields returns all numeric fields that were incremented/decremented during
  33528. // this mutation.
  33529. func (m *UsageTotalMutation) AddedFields() []string {
  33530. var fields []string
  33531. if m.addstatus != nil {
  33532. fields = append(fields, usagetotal.FieldStatus)
  33533. }
  33534. if m.add_type != nil {
  33535. fields = append(fields, usagetotal.FieldType)
  33536. }
  33537. if m.addtotal_tokens != nil {
  33538. fields = append(fields, usagetotal.FieldTotalTokens)
  33539. }
  33540. if m.addstart_index != nil {
  33541. fields = append(fields, usagetotal.FieldStartIndex)
  33542. }
  33543. if m.addend_index != nil {
  33544. fields = append(fields, usagetotal.FieldEndIndex)
  33545. }
  33546. if m.addorganization_id != nil {
  33547. fields = append(fields, usagetotal.FieldOrganizationID)
  33548. }
  33549. return fields
  33550. }
  33551. // AddedField returns the numeric value that was incremented/decremented on a field
  33552. // with the given name. The second boolean return value indicates that this field
  33553. // was not set, or was not defined in the schema.
  33554. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33555. switch name {
  33556. case usagetotal.FieldStatus:
  33557. return m.AddedStatus()
  33558. case usagetotal.FieldType:
  33559. return m.AddedType()
  33560. case usagetotal.FieldTotalTokens:
  33561. return m.AddedTotalTokens()
  33562. case usagetotal.FieldStartIndex:
  33563. return m.AddedStartIndex()
  33564. case usagetotal.FieldEndIndex:
  33565. return m.AddedEndIndex()
  33566. case usagetotal.FieldOrganizationID:
  33567. return m.AddedOrganizationID()
  33568. }
  33569. return nil, false
  33570. }
  33571. // AddField adds the value to the field with the given name. It returns an error if
  33572. // the field is not defined in the schema, or if the type mismatched the field
  33573. // type.
  33574. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33575. switch name {
  33576. case usagetotal.FieldStatus:
  33577. v, ok := value.(int8)
  33578. if !ok {
  33579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33580. }
  33581. m.AddStatus(v)
  33582. return nil
  33583. case usagetotal.FieldType:
  33584. v, ok := value.(int)
  33585. if !ok {
  33586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33587. }
  33588. m.AddType(v)
  33589. return nil
  33590. case usagetotal.FieldTotalTokens:
  33591. v, ok := value.(int64)
  33592. if !ok {
  33593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33594. }
  33595. m.AddTotalTokens(v)
  33596. return nil
  33597. case usagetotal.FieldStartIndex:
  33598. v, ok := value.(int64)
  33599. if !ok {
  33600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33601. }
  33602. m.AddStartIndex(v)
  33603. return nil
  33604. case usagetotal.FieldEndIndex:
  33605. v, ok := value.(int64)
  33606. if !ok {
  33607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33608. }
  33609. m.AddEndIndex(v)
  33610. return nil
  33611. case usagetotal.FieldOrganizationID:
  33612. v, ok := value.(int64)
  33613. if !ok {
  33614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33615. }
  33616. m.AddOrganizationID(v)
  33617. return nil
  33618. }
  33619. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33620. }
  33621. // ClearedFields returns all nullable fields that were cleared during this
  33622. // mutation.
  33623. func (m *UsageTotalMutation) ClearedFields() []string {
  33624. var fields []string
  33625. if m.FieldCleared(usagetotal.FieldStatus) {
  33626. fields = append(fields, usagetotal.FieldStatus)
  33627. }
  33628. if m.FieldCleared(usagetotal.FieldType) {
  33629. fields = append(fields, usagetotal.FieldType)
  33630. }
  33631. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33632. fields = append(fields, usagetotal.FieldTotalTokens)
  33633. }
  33634. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33635. fields = append(fields, usagetotal.FieldStartIndex)
  33636. }
  33637. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33638. fields = append(fields, usagetotal.FieldEndIndex)
  33639. }
  33640. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33641. fields = append(fields, usagetotal.FieldOrganizationID)
  33642. }
  33643. return fields
  33644. }
  33645. // FieldCleared returns a boolean indicating if a field with the given name was
  33646. // cleared in this mutation.
  33647. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33648. _, ok := m.clearedFields[name]
  33649. return ok
  33650. }
  33651. // ClearField clears the value of the field with the given name. It returns an
  33652. // error if the field is not defined in the schema.
  33653. func (m *UsageTotalMutation) ClearField(name string) error {
  33654. switch name {
  33655. case usagetotal.FieldStatus:
  33656. m.ClearStatus()
  33657. return nil
  33658. case usagetotal.FieldType:
  33659. m.ClearType()
  33660. return nil
  33661. case usagetotal.FieldTotalTokens:
  33662. m.ClearTotalTokens()
  33663. return nil
  33664. case usagetotal.FieldStartIndex:
  33665. m.ClearStartIndex()
  33666. return nil
  33667. case usagetotal.FieldEndIndex:
  33668. m.ClearEndIndex()
  33669. return nil
  33670. case usagetotal.FieldOrganizationID:
  33671. m.ClearOrganizationID()
  33672. return nil
  33673. }
  33674. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33675. }
  33676. // ResetField resets all changes in the mutation for the field with the given name.
  33677. // It returns an error if the field is not defined in the schema.
  33678. func (m *UsageTotalMutation) ResetField(name string) error {
  33679. switch name {
  33680. case usagetotal.FieldCreatedAt:
  33681. m.ResetCreatedAt()
  33682. return nil
  33683. case usagetotal.FieldUpdatedAt:
  33684. m.ResetUpdatedAt()
  33685. return nil
  33686. case usagetotal.FieldStatus:
  33687. m.ResetStatus()
  33688. return nil
  33689. case usagetotal.FieldType:
  33690. m.ResetType()
  33691. return nil
  33692. case usagetotal.FieldBotID:
  33693. m.ResetBotID()
  33694. return nil
  33695. case usagetotal.FieldTotalTokens:
  33696. m.ResetTotalTokens()
  33697. return nil
  33698. case usagetotal.FieldStartIndex:
  33699. m.ResetStartIndex()
  33700. return nil
  33701. case usagetotal.FieldEndIndex:
  33702. m.ResetEndIndex()
  33703. return nil
  33704. case usagetotal.FieldOrganizationID:
  33705. m.ResetOrganizationID()
  33706. return nil
  33707. }
  33708. return fmt.Errorf("unknown UsageTotal field %s", name)
  33709. }
  33710. // AddedEdges returns all edge names that were set/added in this mutation.
  33711. func (m *UsageTotalMutation) AddedEdges() []string {
  33712. edges := make([]string, 0, 0)
  33713. return edges
  33714. }
  33715. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33716. // name in this mutation.
  33717. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33718. return nil
  33719. }
  33720. // RemovedEdges returns all edge names that were removed in this mutation.
  33721. func (m *UsageTotalMutation) RemovedEdges() []string {
  33722. edges := make([]string, 0, 0)
  33723. return edges
  33724. }
  33725. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33726. // the given name in this mutation.
  33727. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33728. return nil
  33729. }
  33730. // ClearedEdges returns all edge names that were cleared in this mutation.
  33731. func (m *UsageTotalMutation) ClearedEdges() []string {
  33732. edges := make([]string, 0, 0)
  33733. return edges
  33734. }
  33735. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33736. // was cleared in this mutation.
  33737. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33738. return false
  33739. }
  33740. // ClearEdge clears the value of the edge with the given name. It returns an error
  33741. // if that edge is not defined in the schema.
  33742. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33743. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33744. }
  33745. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33746. // It returns an error if the edge is not defined in the schema.
  33747. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33748. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33749. }
  33750. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33751. type WhatsappMutation struct {
  33752. config
  33753. op Op
  33754. typ string
  33755. id *uint64
  33756. created_at *time.Time
  33757. updated_at *time.Time
  33758. status *uint8
  33759. addstatus *int8
  33760. deleted_at *time.Time
  33761. wa_id *string
  33762. wa_name *string
  33763. callback *string
  33764. account *string
  33765. cc *string
  33766. phone *string
  33767. cc_phone *string
  33768. phone_name *string
  33769. phone_status *int8
  33770. addphone_status *int8
  33771. organization_id *uint64
  33772. addorganization_id *int64
  33773. api_base *string
  33774. api_key *string
  33775. allow_list *[]string
  33776. appendallow_list []string
  33777. group_allow_list *[]string
  33778. appendgroup_allow_list []string
  33779. block_list *[]string
  33780. appendblock_list []string
  33781. group_block_list *[]string
  33782. appendgroup_block_list []string
  33783. clearedFields map[string]struct{}
  33784. agent *uint64
  33785. clearedagent bool
  33786. done bool
  33787. oldValue func(context.Context) (*Whatsapp, error)
  33788. predicates []predicate.Whatsapp
  33789. }
  33790. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33791. // whatsappOption allows management of the mutation configuration using functional options.
  33792. type whatsappOption func(*WhatsappMutation)
  33793. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33794. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33795. m := &WhatsappMutation{
  33796. config: c,
  33797. op: op,
  33798. typ: TypeWhatsapp,
  33799. clearedFields: make(map[string]struct{}),
  33800. }
  33801. for _, opt := range opts {
  33802. opt(m)
  33803. }
  33804. return m
  33805. }
  33806. // withWhatsappID sets the ID field of the mutation.
  33807. func withWhatsappID(id uint64) whatsappOption {
  33808. return func(m *WhatsappMutation) {
  33809. var (
  33810. err error
  33811. once sync.Once
  33812. value *Whatsapp
  33813. )
  33814. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33815. once.Do(func() {
  33816. if m.done {
  33817. err = errors.New("querying old values post mutation is not allowed")
  33818. } else {
  33819. value, err = m.Client().Whatsapp.Get(ctx, id)
  33820. }
  33821. })
  33822. return value, err
  33823. }
  33824. m.id = &id
  33825. }
  33826. }
  33827. // withWhatsapp sets the old Whatsapp of the mutation.
  33828. func withWhatsapp(node *Whatsapp) whatsappOption {
  33829. return func(m *WhatsappMutation) {
  33830. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33831. return node, nil
  33832. }
  33833. m.id = &node.ID
  33834. }
  33835. }
  33836. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33837. // executed in a transaction (ent.Tx), a transactional client is returned.
  33838. func (m WhatsappMutation) Client() *Client {
  33839. client := &Client{config: m.config}
  33840. client.init()
  33841. return client
  33842. }
  33843. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33844. // it returns an error otherwise.
  33845. func (m WhatsappMutation) Tx() (*Tx, error) {
  33846. if _, ok := m.driver.(*txDriver); !ok {
  33847. return nil, errors.New("ent: mutation is not running in a transaction")
  33848. }
  33849. tx := &Tx{config: m.config}
  33850. tx.init()
  33851. return tx, nil
  33852. }
  33853. // SetID sets the value of the id field. Note that this
  33854. // operation is only accepted on creation of Whatsapp entities.
  33855. func (m *WhatsappMutation) SetID(id uint64) {
  33856. m.id = &id
  33857. }
  33858. // ID returns the ID value in the mutation. Note that the ID is only available
  33859. // if it was provided to the builder or after it was returned from the database.
  33860. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33861. if m.id == nil {
  33862. return
  33863. }
  33864. return *m.id, true
  33865. }
  33866. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33867. // That means, if the mutation is applied within a transaction with an isolation level such
  33868. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33869. // or updated by the mutation.
  33870. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33871. switch {
  33872. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33873. id, exists := m.ID()
  33874. if exists {
  33875. return []uint64{id}, nil
  33876. }
  33877. fallthrough
  33878. case m.op.Is(OpUpdate | OpDelete):
  33879. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33880. default:
  33881. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33882. }
  33883. }
  33884. // SetCreatedAt sets the "created_at" field.
  33885. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33886. m.created_at = &t
  33887. }
  33888. // CreatedAt returns the value of the "created_at" field in the mutation.
  33889. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33890. v := m.created_at
  33891. if v == nil {
  33892. return
  33893. }
  33894. return *v, true
  33895. }
  33896. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33897. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33899. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33900. if !m.op.Is(OpUpdateOne) {
  33901. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33902. }
  33903. if m.id == nil || m.oldValue == nil {
  33904. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33905. }
  33906. oldValue, err := m.oldValue(ctx)
  33907. if err != nil {
  33908. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33909. }
  33910. return oldValue.CreatedAt, nil
  33911. }
  33912. // ResetCreatedAt resets all changes to the "created_at" field.
  33913. func (m *WhatsappMutation) ResetCreatedAt() {
  33914. m.created_at = nil
  33915. }
  33916. // SetUpdatedAt sets the "updated_at" field.
  33917. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33918. m.updated_at = &t
  33919. }
  33920. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33921. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33922. v := m.updated_at
  33923. if v == nil {
  33924. return
  33925. }
  33926. return *v, true
  33927. }
  33928. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33929. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33931. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33932. if !m.op.Is(OpUpdateOne) {
  33933. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33934. }
  33935. if m.id == nil || m.oldValue == nil {
  33936. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33937. }
  33938. oldValue, err := m.oldValue(ctx)
  33939. if err != nil {
  33940. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33941. }
  33942. return oldValue.UpdatedAt, nil
  33943. }
  33944. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33945. func (m *WhatsappMutation) ResetUpdatedAt() {
  33946. m.updated_at = nil
  33947. }
  33948. // SetStatus sets the "status" field.
  33949. func (m *WhatsappMutation) SetStatus(u uint8) {
  33950. m.status = &u
  33951. m.addstatus = nil
  33952. }
  33953. // Status returns the value of the "status" field in the mutation.
  33954. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33955. v := m.status
  33956. if v == nil {
  33957. return
  33958. }
  33959. return *v, true
  33960. }
  33961. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33962. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33964. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33965. if !m.op.Is(OpUpdateOne) {
  33966. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33967. }
  33968. if m.id == nil || m.oldValue == nil {
  33969. return v, errors.New("OldStatus requires an ID field in the mutation")
  33970. }
  33971. oldValue, err := m.oldValue(ctx)
  33972. if err != nil {
  33973. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33974. }
  33975. return oldValue.Status, nil
  33976. }
  33977. // AddStatus adds u to the "status" field.
  33978. func (m *WhatsappMutation) AddStatus(u int8) {
  33979. if m.addstatus != nil {
  33980. *m.addstatus += u
  33981. } else {
  33982. m.addstatus = &u
  33983. }
  33984. }
  33985. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33986. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33987. v := m.addstatus
  33988. if v == nil {
  33989. return
  33990. }
  33991. return *v, true
  33992. }
  33993. // ClearStatus clears the value of the "status" field.
  33994. func (m *WhatsappMutation) ClearStatus() {
  33995. m.status = nil
  33996. m.addstatus = nil
  33997. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33998. }
  33999. // StatusCleared returns if the "status" field was cleared in this mutation.
  34000. func (m *WhatsappMutation) StatusCleared() bool {
  34001. _, ok := m.clearedFields[whatsapp.FieldStatus]
  34002. return ok
  34003. }
  34004. // ResetStatus resets all changes to the "status" field.
  34005. func (m *WhatsappMutation) ResetStatus() {
  34006. m.status = nil
  34007. m.addstatus = nil
  34008. delete(m.clearedFields, whatsapp.FieldStatus)
  34009. }
  34010. // SetDeletedAt sets the "deleted_at" field.
  34011. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  34012. m.deleted_at = &t
  34013. }
  34014. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34015. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  34016. v := m.deleted_at
  34017. if v == nil {
  34018. return
  34019. }
  34020. return *v, true
  34021. }
  34022. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  34023. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34025. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34026. if !m.op.Is(OpUpdateOne) {
  34027. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34028. }
  34029. if m.id == nil || m.oldValue == nil {
  34030. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34031. }
  34032. oldValue, err := m.oldValue(ctx)
  34033. if err != nil {
  34034. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34035. }
  34036. return oldValue.DeletedAt, nil
  34037. }
  34038. // ClearDeletedAt clears the value of the "deleted_at" field.
  34039. func (m *WhatsappMutation) ClearDeletedAt() {
  34040. m.deleted_at = nil
  34041. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  34042. }
  34043. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34044. func (m *WhatsappMutation) DeletedAtCleared() bool {
  34045. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  34046. return ok
  34047. }
  34048. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34049. func (m *WhatsappMutation) ResetDeletedAt() {
  34050. m.deleted_at = nil
  34051. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  34052. }
  34053. // SetWaID sets the "wa_id" field.
  34054. func (m *WhatsappMutation) SetWaID(s string) {
  34055. m.wa_id = &s
  34056. }
  34057. // WaID returns the value of the "wa_id" field in the mutation.
  34058. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  34059. v := m.wa_id
  34060. if v == nil {
  34061. return
  34062. }
  34063. return *v, true
  34064. }
  34065. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  34066. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34068. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  34069. if !m.op.Is(OpUpdateOne) {
  34070. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  34071. }
  34072. if m.id == nil || m.oldValue == nil {
  34073. return v, errors.New("OldWaID requires an ID field in the mutation")
  34074. }
  34075. oldValue, err := m.oldValue(ctx)
  34076. if err != nil {
  34077. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  34078. }
  34079. return oldValue.WaID, nil
  34080. }
  34081. // ClearWaID clears the value of the "wa_id" field.
  34082. func (m *WhatsappMutation) ClearWaID() {
  34083. m.wa_id = nil
  34084. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  34085. }
  34086. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  34087. func (m *WhatsappMutation) WaIDCleared() bool {
  34088. _, ok := m.clearedFields[whatsapp.FieldWaID]
  34089. return ok
  34090. }
  34091. // ResetWaID resets all changes to the "wa_id" field.
  34092. func (m *WhatsappMutation) ResetWaID() {
  34093. m.wa_id = nil
  34094. delete(m.clearedFields, whatsapp.FieldWaID)
  34095. }
  34096. // SetWaName sets the "wa_name" field.
  34097. func (m *WhatsappMutation) SetWaName(s string) {
  34098. m.wa_name = &s
  34099. }
  34100. // WaName returns the value of the "wa_name" field in the mutation.
  34101. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  34102. v := m.wa_name
  34103. if v == nil {
  34104. return
  34105. }
  34106. return *v, true
  34107. }
  34108. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  34109. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34111. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  34112. if !m.op.Is(OpUpdateOne) {
  34113. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  34114. }
  34115. if m.id == nil || m.oldValue == nil {
  34116. return v, errors.New("OldWaName requires an ID field in the mutation")
  34117. }
  34118. oldValue, err := m.oldValue(ctx)
  34119. if err != nil {
  34120. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  34121. }
  34122. return oldValue.WaName, nil
  34123. }
  34124. // ClearWaName clears the value of the "wa_name" field.
  34125. func (m *WhatsappMutation) ClearWaName() {
  34126. m.wa_name = nil
  34127. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  34128. }
  34129. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  34130. func (m *WhatsappMutation) WaNameCleared() bool {
  34131. _, ok := m.clearedFields[whatsapp.FieldWaName]
  34132. return ok
  34133. }
  34134. // ResetWaName resets all changes to the "wa_name" field.
  34135. func (m *WhatsappMutation) ResetWaName() {
  34136. m.wa_name = nil
  34137. delete(m.clearedFields, whatsapp.FieldWaName)
  34138. }
  34139. // SetCallback sets the "callback" field.
  34140. func (m *WhatsappMutation) SetCallback(s string) {
  34141. m.callback = &s
  34142. }
  34143. // Callback returns the value of the "callback" field in the mutation.
  34144. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34145. v := m.callback
  34146. if v == nil {
  34147. return
  34148. }
  34149. return *v, true
  34150. }
  34151. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34152. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34154. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34155. if !m.op.Is(OpUpdateOne) {
  34156. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34157. }
  34158. if m.id == nil || m.oldValue == nil {
  34159. return v, errors.New("OldCallback requires an ID field in the mutation")
  34160. }
  34161. oldValue, err := m.oldValue(ctx)
  34162. if err != nil {
  34163. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34164. }
  34165. return oldValue.Callback, nil
  34166. }
  34167. // ClearCallback clears the value of the "callback" field.
  34168. func (m *WhatsappMutation) ClearCallback() {
  34169. m.callback = nil
  34170. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  34171. }
  34172. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  34173. func (m *WhatsappMutation) CallbackCleared() bool {
  34174. _, ok := m.clearedFields[whatsapp.FieldCallback]
  34175. return ok
  34176. }
  34177. // ResetCallback resets all changes to the "callback" field.
  34178. func (m *WhatsappMutation) ResetCallback() {
  34179. m.callback = nil
  34180. delete(m.clearedFields, whatsapp.FieldCallback)
  34181. }
  34182. // SetAgentID sets the "agent_id" field.
  34183. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34184. m.agent = &u
  34185. }
  34186. // AgentID returns the value of the "agent_id" field in the mutation.
  34187. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34188. v := m.agent
  34189. if v == nil {
  34190. return
  34191. }
  34192. return *v, true
  34193. }
  34194. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34195. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34197. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34198. if !m.op.Is(OpUpdateOne) {
  34199. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34200. }
  34201. if m.id == nil || m.oldValue == nil {
  34202. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34203. }
  34204. oldValue, err := m.oldValue(ctx)
  34205. if err != nil {
  34206. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34207. }
  34208. return oldValue.AgentID, nil
  34209. }
  34210. // ResetAgentID resets all changes to the "agent_id" field.
  34211. func (m *WhatsappMutation) ResetAgentID() {
  34212. m.agent = nil
  34213. }
  34214. // SetAccount sets the "account" field.
  34215. func (m *WhatsappMutation) SetAccount(s string) {
  34216. m.account = &s
  34217. }
  34218. // Account returns the value of the "account" field in the mutation.
  34219. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34220. v := m.account
  34221. if v == nil {
  34222. return
  34223. }
  34224. return *v, true
  34225. }
  34226. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34227. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34229. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34230. if !m.op.Is(OpUpdateOne) {
  34231. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34232. }
  34233. if m.id == nil || m.oldValue == nil {
  34234. return v, errors.New("OldAccount requires an ID field in the mutation")
  34235. }
  34236. oldValue, err := m.oldValue(ctx)
  34237. if err != nil {
  34238. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34239. }
  34240. return oldValue.Account, nil
  34241. }
  34242. // ClearAccount clears the value of the "account" field.
  34243. func (m *WhatsappMutation) ClearAccount() {
  34244. m.account = nil
  34245. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  34246. }
  34247. // AccountCleared returns if the "account" field was cleared in this mutation.
  34248. func (m *WhatsappMutation) AccountCleared() bool {
  34249. _, ok := m.clearedFields[whatsapp.FieldAccount]
  34250. return ok
  34251. }
  34252. // ResetAccount resets all changes to the "account" field.
  34253. func (m *WhatsappMutation) ResetAccount() {
  34254. m.account = nil
  34255. delete(m.clearedFields, whatsapp.FieldAccount)
  34256. }
  34257. // SetCc sets the "cc" field.
  34258. func (m *WhatsappMutation) SetCc(s string) {
  34259. m.cc = &s
  34260. }
  34261. // Cc returns the value of the "cc" field in the mutation.
  34262. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  34263. v := m.cc
  34264. if v == nil {
  34265. return
  34266. }
  34267. return *v, true
  34268. }
  34269. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  34270. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34272. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  34273. if !m.op.Is(OpUpdateOne) {
  34274. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  34275. }
  34276. if m.id == nil || m.oldValue == nil {
  34277. return v, errors.New("OldCc requires an ID field in the mutation")
  34278. }
  34279. oldValue, err := m.oldValue(ctx)
  34280. if err != nil {
  34281. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  34282. }
  34283. return oldValue.Cc, nil
  34284. }
  34285. // ResetCc resets all changes to the "cc" field.
  34286. func (m *WhatsappMutation) ResetCc() {
  34287. m.cc = nil
  34288. }
  34289. // SetPhone sets the "phone" field.
  34290. func (m *WhatsappMutation) SetPhone(s string) {
  34291. m.phone = &s
  34292. }
  34293. // Phone returns the value of the "phone" field in the mutation.
  34294. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34295. v := m.phone
  34296. if v == nil {
  34297. return
  34298. }
  34299. return *v, true
  34300. }
  34301. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34302. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34304. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34305. if !m.op.Is(OpUpdateOne) {
  34306. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34307. }
  34308. if m.id == nil || m.oldValue == nil {
  34309. return v, errors.New("OldPhone requires an ID field in the mutation")
  34310. }
  34311. oldValue, err := m.oldValue(ctx)
  34312. if err != nil {
  34313. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34314. }
  34315. return oldValue.Phone, nil
  34316. }
  34317. // ResetPhone resets all changes to the "phone" field.
  34318. func (m *WhatsappMutation) ResetPhone() {
  34319. m.phone = nil
  34320. }
  34321. // SetCcPhone sets the "cc_phone" field.
  34322. func (m *WhatsappMutation) SetCcPhone(s string) {
  34323. m.cc_phone = &s
  34324. }
  34325. // CcPhone returns the value of the "cc_phone" field in the mutation.
  34326. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  34327. v := m.cc_phone
  34328. if v == nil {
  34329. return
  34330. }
  34331. return *v, true
  34332. }
  34333. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  34334. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34336. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  34337. if !m.op.Is(OpUpdateOne) {
  34338. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  34339. }
  34340. if m.id == nil || m.oldValue == nil {
  34341. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  34342. }
  34343. oldValue, err := m.oldValue(ctx)
  34344. if err != nil {
  34345. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  34346. }
  34347. return oldValue.CcPhone, nil
  34348. }
  34349. // ResetCcPhone resets all changes to the "cc_phone" field.
  34350. func (m *WhatsappMutation) ResetCcPhone() {
  34351. m.cc_phone = nil
  34352. }
  34353. // SetPhoneName sets the "phone_name" field.
  34354. func (m *WhatsappMutation) SetPhoneName(s string) {
  34355. m.phone_name = &s
  34356. }
  34357. // PhoneName returns the value of the "phone_name" field in the mutation.
  34358. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  34359. v := m.phone_name
  34360. if v == nil {
  34361. return
  34362. }
  34363. return *v, true
  34364. }
  34365. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  34366. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34368. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  34369. if !m.op.Is(OpUpdateOne) {
  34370. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  34371. }
  34372. if m.id == nil || m.oldValue == nil {
  34373. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  34374. }
  34375. oldValue, err := m.oldValue(ctx)
  34376. if err != nil {
  34377. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  34378. }
  34379. return oldValue.PhoneName, nil
  34380. }
  34381. // ResetPhoneName resets all changes to the "phone_name" field.
  34382. func (m *WhatsappMutation) ResetPhoneName() {
  34383. m.phone_name = nil
  34384. }
  34385. // SetPhoneStatus sets the "phone_status" field.
  34386. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  34387. m.phone_status = &i
  34388. m.addphone_status = nil
  34389. }
  34390. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  34391. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  34392. v := m.phone_status
  34393. if v == nil {
  34394. return
  34395. }
  34396. return *v, true
  34397. }
  34398. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  34399. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34401. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  34402. if !m.op.Is(OpUpdateOne) {
  34403. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  34404. }
  34405. if m.id == nil || m.oldValue == nil {
  34406. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  34407. }
  34408. oldValue, err := m.oldValue(ctx)
  34409. if err != nil {
  34410. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  34411. }
  34412. return oldValue.PhoneStatus, nil
  34413. }
  34414. // AddPhoneStatus adds i to the "phone_status" field.
  34415. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  34416. if m.addphone_status != nil {
  34417. *m.addphone_status += i
  34418. } else {
  34419. m.addphone_status = &i
  34420. }
  34421. }
  34422. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  34423. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  34424. v := m.addphone_status
  34425. if v == nil {
  34426. return
  34427. }
  34428. return *v, true
  34429. }
  34430. // ResetPhoneStatus resets all changes to the "phone_status" field.
  34431. func (m *WhatsappMutation) ResetPhoneStatus() {
  34432. m.phone_status = nil
  34433. m.addphone_status = nil
  34434. }
  34435. // SetOrganizationID sets the "organization_id" field.
  34436. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34437. m.organization_id = &u
  34438. m.addorganization_id = nil
  34439. }
  34440. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34441. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34442. v := m.organization_id
  34443. if v == nil {
  34444. return
  34445. }
  34446. return *v, true
  34447. }
  34448. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34449. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34451. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34452. if !m.op.Is(OpUpdateOne) {
  34453. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34454. }
  34455. if m.id == nil || m.oldValue == nil {
  34456. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34457. }
  34458. oldValue, err := m.oldValue(ctx)
  34459. if err != nil {
  34460. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34461. }
  34462. return oldValue.OrganizationID, nil
  34463. }
  34464. // AddOrganizationID adds u to the "organization_id" field.
  34465. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34466. if m.addorganization_id != nil {
  34467. *m.addorganization_id += u
  34468. } else {
  34469. m.addorganization_id = &u
  34470. }
  34471. }
  34472. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34473. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34474. v := m.addorganization_id
  34475. if v == nil {
  34476. return
  34477. }
  34478. return *v, true
  34479. }
  34480. // ClearOrganizationID clears the value of the "organization_id" field.
  34481. func (m *WhatsappMutation) ClearOrganizationID() {
  34482. m.organization_id = nil
  34483. m.addorganization_id = nil
  34484. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34485. }
  34486. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34487. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34488. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34489. return ok
  34490. }
  34491. // ResetOrganizationID resets all changes to the "organization_id" field.
  34492. func (m *WhatsappMutation) ResetOrganizationID() {
  34493. m.organization_id = nil
  34494. m.addorganization_id = nil
  34495. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34496. }
  34497. // SetAPIBase sets the "api_base" field.
  34498. func (m *WhatsappMutation) SetAPIBase(s string) {
  34499. m.api_base = &s
  34500. }
  34501. // APIBase returns the value of the "api_base" field in the mutation.
  34502. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34503. v := m.api_base
  34504. if v == nil {
  34505. return
  34506. }
  34507. return *v, true
  34508. }
  34509. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34510. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34512. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34513. if !m.op.Is(OpUpdateOne) {
  34514. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34515. }
  34516. if m.id == nil || m.oldValue == nil {
  34517. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34518. }
  34519. oldValue, err := m.oldValue(ctx)
  34520. if err != nil {
  34521. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34522. }
  34523. return oldValue.APIBase, nil
  34524. }
  34525. // ClearAPIBase clears the value of the "api_base" field.
  34526. func (m *WhatsappMutation) ClearAPIBase() {
  34527. m.api_base = nil
  34528. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34529. }
  34530. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34531. func (m *WhatsappMutation) APIBaseCleared() bool {
  34532. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34533. return ok
  34534. }
  34535. // ResetAPIBase resets all changes to the "api_base" field.
  34536. func (m *WhatsappMutation) ResetAPIBase() {
  34537. m.api_base = nil
  34538. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34539. }
  34540. // SetAPIKey sets the "api_key" field.
  34541. func (m *WhatsappMutation) SetAPIKey(s string) {
  34542. m.api_key = &s
  34543. }
  34544. // APIKey returns the value of the "api_key" field in the mutation.
  34545. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34546. v := m.api_key
  34547. if v == nil {
  34548. return
  34549. }
  34550. return *v, true
  34551. }
  34552. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34553. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34555. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34556. if !m.op.Is(OpUpdateOne) {
  34557. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34558. }
  34559. if m.id == nil || m.oldValue == nil {
  34560. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34561. }
  34562. oldValue, err := m.oldValue(ctx)
  34563. if err != nil {
  34564. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34565. }
  34566. return oldValue.APIKey, nil
  34567. }
  34568. // ClearAPIKey clears the value of the "api_key" field.
  34569. func (m *WhatsappMutation) ClearAPIKey() {
  34570. m.api_key = nil
  34571. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34572. }
  34573. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34574. func (m *WhatsappMutation) APIKeyCleared() bool {
  34575. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34576. return ok
  34577. }
  34578. // ResetAPIKey resets all changes to the "api_key" field.
  34579. func (m *WhatsappMutation) ResetAPIKey() {
  34580. m.api_key = nil
  34581. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34582. }
  34583. // SetAllowList sets the "allow_list" field.
  34584. func (m *WhatsappMutation) SetAllowList(s []string) {
  34585. m.allow_list = &s
  34586. m.appendallow_list = nil
  34587. }
  34588. // AllowList returns the value of the "allow_list" field in the mutation.
  34589. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34590. v := m.allow_list
  34591. if v == nil {
  34592. return
  34593. }
  34594. return *v, true
  34595. }
  34596. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34597. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34599. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34600. if !m.op.Is(OpUpdateOne) {
  34601. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34602. }
  34603. if m.id == nil || m.oldValue == nil {
  34604. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34605. }
  34606. oldValue, err := m.oldValue(ctx)
  34607. if err != nil {
  34608. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34609. }
  34610. return oldValue.AllowList, nil
  34611. }
  34612. // AppendAllowList adds s to the "allow_list" field.
  34613. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34614. m.appendallow_list = append(m.appendallow_list, s...)
  34615. }
  34616. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34617. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34618. if len(m.appendallow_list) == 0 {
  34619. return nil, false
  34620. }
  34621. return m.appendallow_list, true
  34622. }
  34623. // ClearAllowList clears the value of the "allow_list" field.
  34624. func (m *WhatsappMutation) ClearAllowList() {
  34625. m.allow_list = nil
  34626. m.appendallow_list = nil
  34627. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34628. }
  34629. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34630. func (m *WhatsappMutation) AllowListCleared() bool {
  34631. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34632. return ok
  34633. }
  34634. // ResetAllowList resets all changes to the "allow_list" field.
  34635. func (m *WhatsappMutation) ResetAllowList() {
  34636. m.allow_list = nil
  34637. m.appendallow_list = nil
  34638. delete(m.clearedFields, whatsapp.FieldAllowList)
  34639. }
  34640. // SetGroupAllowList sets the "group_allow_list" field.
  34641. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34642. m.group_allow_list = &s
  34643. m.appendgroup_allow_list = nil
  34644. }
  34645. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34646. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34647. v := m.group_allow_list
  34648. if v == nil {
  34649. return
  34650. }
  34651. return *v, true
  34652. }
  34653. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34654. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34656. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34657. if !m.op.Is(OpUpdateOne) {
  34658. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34659. }
  34660. if m.id == nil || m.oldValue == nil {
  34661. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34662. }
  34663. oldValue, err := m.oldValue(ctx)
  34664. if err != nil {
  34665. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34666. }
  34667. return oldValue.GroupAllowList, nil
  34668. }
  34669. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34670. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34671. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34672. }
  34673. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34674. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34675. if len(m.appendgroup_allow_list) == 0 {
  34676. return nil, false
  34677. }
  34678. return m.appendgroup_allow_list, true
  34679. }
  34680. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34681. func (m *WhatsappMutation) ClearGroupAllowList() {
  34682. m.group_allow_list = nil
  34683. m.appendgroup_allow_list = nil
  34684. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34685. }
  34686. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34687. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34688. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34689. return ok
  34690. }
  34691. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34692. func (m *WhatsappMutation) ResetGroupAllowList() {
  34693. m.group_allow_list = nil
  34694. m.appendgroup_allow_list = nil
  34695. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34696. }
  34697. // SetBlockList sets the "block_list" field.
  34698. func (m *WhatsappMutation) SetBlockList(s []string) {
  34699. m.block_list = &s
  34700. m.appendblock_list = nil
  34701. }
  34702. // BlockList returns the value of the "block_list" field in the mutation.
  34703. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34704. v := m.block_list
  34705. if v == nil {
  34706. return
  34707. }
  34708. return *v, true
  34709. }
  34710. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34711. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34713. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34714. if !m.op.Is(OpUpdateOne) {
  34715. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34716. }
  34717. if m.id == nil || m.oldValue == nil {
  34718. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34719. }
  34720. oldValue, err := m.oldValue(ctx)
  34721. if err != nil {
  34722. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34723. }
  34724. return oldValue.BlockList, nil
  34725. }
  34726. // AppendBlockList adds s to the "block_list" field.
  34727. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34728. m.appendblock_list = append(m.appendblock_list, s...)
  34729. }
  34730. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34731. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34732. if len(m.appendblock_list) == 0 {
  34733. return nil, false
  34734. }
  34735. return m.appendblock_list, true
  34736. }
  34737. // ClearBlockList clears the value of the "block_list" field.
  34738. func (m *WhatsappMutation) ClearBlockList() {
  34739. m.block_list = nil
  34740. m.appendblock_list = nil
  34741. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34742. }
  34743. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34744. func (m *WhatsappMutation) BlockListCleared() bool {
  34745. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34746. return ok
  34747. }
  34748. // ResetBlockList resets all changes to the "block_list" field.
  34749. func (m *WhatsappMutation) ResetBlockList() {
  34750. m.block_list = nil
  34751. m.appendblock_list = nil
  34752. delete(m.clearedFields, whatsapp.FieldBlockList)
  34753. }
  34754. // SetGroupBlockList sets the "group_block_list" field.
  34755. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34756. m.group_block_list = &s
  34757. m.appendgroup_block_list = nil
  34758. }
  34759. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34760. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34761. v := m.group_block_list
  34762. if v == nil {
  34763. return
  34764. }
  34765. return *v, true
  34766. }
  34767. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34768. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34770. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34771. if !m.op.Is(OpUpdateOne) {
  34772. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34773. }
  34774. if m.id == nil || m.oldValue == nil {
  34775. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34776. }
  34777. oldValue, err := m.oldValue(ctx)
  34778. if err != nil {
  34779. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34780. }
  34781. return oldValue.GroupBlockList, nil
  34782. }
  34783. // AppendGroupBlockList adds s to the "group_block_list" field.
  34784. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34785. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34786. }
  34787. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34788. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34789. if len(m.appendgroup_block_list) == 0 {
  34790. return nil, false
  34791. }
  34792. return m.appendgroup_block_list, true
  34793. }
  34794. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34795. func (m *WhatsappMutation) ClearGroupBlockList() {
  34796. m.group_block_list = nil
  34797. m.appendgroup_block_list = nil
  34798. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34799. }
  34800. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34801. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34802. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34803. return ok
  34804. }
  34805. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34806. func (m *WhatsappMutation) ResetGroupBlockList() {
  34807. m.group_block_list = nil
  34808. m.appendgroup_block_list = nil
  34809. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34810. }
  34811. // ClearAgent clears the "agent" edge to the Agent entity.
  34812. func (m *WhatsappMutation) ClearAgent() {
  34813. m.clearedagent = true
  34814. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  34815. }
  34816. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34817. func (m *WhatsappMutation) AgentCleared() bool {
  34818. return m.clearedagent
  34819. }
  34820. // AgentIDs returns the "agent" edge IDs in the mutation.
  34821. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34822. // AgentID instead. It exists only for internal usage by the builders.
  34823. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  34824. if id := m.agent; id != nil {
  34825. ids = append(ids, *id)
  34826. }
  34827. return
  34828. }
  34829. // ResetAgent resets all changes to the "agent" edge.
  34830. func (m *WhatsappMutation) ResetAgent() {
  34831. m.agent = nil
  34832. m.clearedagent = false
  34833. }
  34834. // Where appends a list predicates to the WhatsappMutation builder.
  34835. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34836. m.predicates = append(m.predicates, ps...)
  34837. }
  34838. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34839. // users can use type-assertion to append predicates that do not depend on any generated package.
  34840. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34841. p := make([]predicate.Whatsapp, len(ps))
  34842. for i := range ps {
  34843. p[i] = ps[i]
  34844. }
  34845. m.Where(p...)
  34846. }
  34847. // Op returns the operation name.
  34848. func (m *WhatsappMutation) Op() Op {
  34849. return m.op
  34850. }
  34851. // SetOp allows setting the mutation operation.
  34852. func (m *WhatsappMutation) SetOp(op Op) {
  34853. m.op = op
  34854. }
  34855. // Type returns the node type of this mutation (Whatsapp).
  34856. func (m *WhatsappMutation) Type() string {
  34857. return m.typ
  34858. }
  34859. // Fields returns all fields that were changed during this mutation. Note that in
  34860. // order to get all numeric fields that were incremented/decremented, call
  34861. // AddedFields().
  34862. func (m *WhatsappMutation) Fields() []string {
  34863. fields := make([]string, 0, 21)
  34864. if m.created_at != nil {
  34865. fields = append(fields, whatsapp.FieldCreatedAt)
  34866. }
  34867. if m.updated_at != nil {
  34868. fields = append(fields, whatsapp.FieldUpdatedAt)
  34869. }
  34870. if m.status != nil {
  34871. fields = append(fields, whatsapp.FieldStatus)
  34872. }
  34873. if m.deleted_at != nil {
  34874. fields = append(fields, whatsapp.FieldDeletedAt)
  34875. }
  34876. if m.wa_id != nil {
  34877. fields = append(fields, whatsapp.FieldWaID)
  34878. }
  34879. if m.wa_name != nil {
  34880. fields = append(fields, whatsapp.FieldWaName)
  34881. }
  34882. if m.callback != nil {
  34883. fields = append(fields, whatsapp.FieldCallback)
  34884. }
  34885. if m.agent != nil {
  34886. fields = append(fields, whatsapp.FieldAgentID)
  34887. }
  34888. if m.account != nil {
  34889. fields = append(fields, whatsapp.FieldAccount)
  34890. }
  34891. if m.cc != nil {
  34892. fields = append(fields, whatsapp.FieldCc)
  34893. }
  34894. if m.phone != nil {
  34895. fields = append(fields, whatsapp.FieldPhone)
  34896. }
  34897. if m.cc_phone != nil {
  34898. fields = append(fields, whatsapp.FieldCcPhone)
  34899. }
  34900. if m.phone_name != nil {
  34901. fields = append(fields, whatsapp.FieldPhoneName)
  34902. }
  34903. if m.phone_status != nil {
  34904. fields = append(fields, whatsapp.FieldPhoneStatus)
  34905. }
  34906. if m.organization_id != nil {
  34907. fields = append(fields, whatsapp.FieldOrganizationID)
  34908. }
  34909. if m.api_base != nil {
  34910. fields = append(fields, whatsapp.FieldAPIBase)
  34911. }
  34912. if m.api_key != nil {
  34913. fields = append(fields, whatsapp.FieldAPIKey)
  34914. }
  34915. if m.allow_list != nil {
  34916. fields = append(fields, whatsapp.FieldAllowList)
  34917. }
  34918. if m.group_allow_list != nil {
  34919. fields = append(fields, whatsapp.FieldGroupAllowList)
  34920. }
  34921. if m.block_list != nil {
  34922. fields = append(fields, whatsapp.FieldBlockList)
  34923. }
  34924. if m.group_block_list != nil {
  34925. fields = append(fields, whatsapp.FieldGroupBlockList)
  34926. }
  34927. return fields
  34928. }
  34929. // Field returns the value of a field with the given name. The second boolean
  34930. // return value indicates that this field was not set, or was not defined in the
  34931. // schema.
  34932. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34933. switch name {
  34934. case whatsapp.FieldCreatedAt:
  34935. return m.CreatedAt()
  34936. case whatsapp.FieldUpdatedAt:
  34937. return m.UpdatedAt()
  34938. case whatsapp.FieldStatus:
  34939. return m.Status()
  34940. case whatsapp.FieldDeletedAt:
  34941. return m.DeletedAt()
  34942. case whatsapp.FieldWaID:
  34943. return m.WaID()
  34944. case whatsapp.FieldWaName:
  34945. return m.WaName()
  34946. case whatsapp.FieldCallback:
  34947. return m.Callback()
  34948. case whatsapp.FieldAgentID:
  34949. return m.AgentID()
  34950. case whatsapp.FieldAccount:
  34951. return m.Account()
  34952. case whatsapp.FieldCc:
  34953. return m.Cc()
  34954. case whatsapp.FieldPhone:
  34955. return m.Phone()
  34956. case whatsapp.FieldCcPhone:
  34957. return m.CcPhone()
  34958. case whatsapp.FieldPhoneName:
  34959. return m.PhoneName()
  34960. case whatsapp.FieldPhoneStatus:
  34961. return m.PhoneStatus()
  34962. case whatsapp.FieldOrganizationID:
  34963. return m.OrganizationID()
  34964. case whatsapp.FieldAPIBase:
  34965. return m.APIBase()
  34966. case whatsapp.FieldAPIKey:
  34967. return m.APIKey()
  34968. case whatsapp.FieldAllowList:
  34969. return m.AllowList()
  34970. case whatsapp.FieldGroupAllowList:
  34971. return m.GroupAllowList()
  34972. case whatsapp.FieldBlockList:
  34973. return m.BlockList()
  34974. case whatsapp.FieldGroupBlockList:
  34975. return m.GroupBlockList()
  34976. }
  34977. return nil, false
  34978. }
  34979. // OldField returns the old value of the field from the database. An error is
  34980. // returned if the mutation operation is not UpdateOne, or the query to the
  34981. // database failed.
  34982. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34983. switch name {
  34984. case whatsapp.FieldCreatedAt:
  34985. return m.OldCreatedAt(ctx)
  34986. case whatsapp.FieldUpdatedAt:
  34987. return m.OldUpdatedAt(ctx)
  34988. case whatsapp.FieldStatus:
  34989. return m.OldStatus(ctx)
  34990. case whatsapp.FieldDeletedAt:
  34991. return m.OldDeletedAt(ctx)
  34992. case whatsapp.FieldWaID:
  34993. return m.OldWaID(ctx)
  34994. case whatsapp.FieldWaName:
  34995. return m.OldWaName(ctx)
  34996. case whatsapp.FieldCallback:
  34997. return m.OldCallback(ctx)
  34998. case whatsapp.FieldAgentID:
  34999. return m.OldAgentID(ctx)
  35000. case whatsapp.FieldAccount:
  35001. return m.OldAccount(ctx)
  35002. case whatsapp.FieldCc:
  35003. return m.OldCc(ctx)
  35004. case whatsapp.FieldPhone:
  35005. return m.OldPhone(ctx)
  35006. case whatsapp.FieldCcPhone:
  35007. return m.OldCcPhone(ctx)
  35008. case whatsapp.FieldPhoneName:
  35009. return m.OldPhoneName(ctx)
  35010. case whatsapp.FieldPhoneStatus:
  35011. return m.OldPhoneStatus(ctx)
  35012. case whatsapp.FieldOrganizationID:
  35013. return m.OldOrganizationID(ctx)
  35014. case whatsapp.FieldAPIBase:
  35015. return m.OldAPIBase(ctx)
  35016. case whatsapp.FieldAPIKey:
  35017. return m.OldAPIKey(ctx)
  35018. case whatsapp.FieldAllowList:
  35019. return m.OldAllowList(ctx)
  35020. case whatsapp.FieldGroupAllowList:
  35021. return m.OldGroupAllowList(ctx)
  35022. case whatsapp.FieldBlockList:
  35023. return m.OldBlockList(ctx)
  35024. case whatsapp.FieldGroupBlockList:
  35025. return m.OldGroupBlockList(ctx)
  35026. }
  35027. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  35028. }
  35029. // SetField sets the value of a field with the given name. It returns an error if
  35030. // the field is not defined in the schema, or if the type mismatched the field
  35031. // type.
  35032. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  35033. switch name {
  35034. case whatsapp.FieldCreatedAt:
  35035. v, ok := value.(time.Time)
  35036. if !ok {
  35037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35038. }
  35039. m.SetCreatedAt(v)
  35040. return nil
  35041. case whatsapp.FieldUpdatedAt:
  35042. v, ok := value.(time.Time)
  35043. if !ok {
  35044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35045. }
  35046. m.SetUpdatedAt(v)
  35047. return nil
  35048. case whatsapp.FieldStatus:
  35049. v, ok := value.(uint8)
  35050. if !ok {
  35051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35052. }
  35053. m.SetStatus(v)
  35054. return nil
  35055. case whatsapp.FieldDeletedAt:
  35056. v, ok := value.(time.Time)
  35057. if !ok {
  35058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35059. }
  35060. m.SetDeletedAt(v)
  35061. return nil
  35062. case whatsapp.FieldWaID:
  35063. v, ok := value.(string)
  35064. if !ok {
  35065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35066. }
  35067. m.SetWaID(v)
  35068. return nil
  35069. case whatsapp.FieldWaName:
  35070. v, ok := value.(string)
  35071. if !ok {
  35072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35073. }
  35074. m.SetWaName(v)
  35075. return nil
  35076. case whatsapp.FieldCallback:
  35077. v, ok := value.(string)
  35078. if !ok {
  35079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35080. }
  35081. m.SetCallback(v)
  35082. return nil
  35083. case whatsapp.FieldAgentID:
  35084. v, ok := value.(uint64)
  35085. if !ok {
  35086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35087. }
  35088. m.SetAgentID(v)
  35089. return nil
  35090. case whatsapp.FieldAccount:
  35091. v, ok := value.(string)
  35092. if !ok {
  35093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35094. }
  35095. m.SetAccount(v)
  35096. return nil
  35097. case whatsapp.FieldCc:
  35098. v, ok := value.(string)
  35099. if !ok {
  35100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35101. }
  35102. m.SetCc(v)
  35103. return nil
  35104. case whatsapp.FieldPhone:
  35105. v, ok := value.(string)
  35106. if !ok {
  35107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35108. }
  35109. m.SetPhone(v)
  35110. return nil
  35111. case whatsapp.FieldCcPhone:
  35112. v, ok := value.(string)
  35113. if !ok {
  35114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35115. }
  35116. m.SetCcPhone(v)
  35117. return nil
  35118. case whatsapp.FieldPhoneName:
  35119. v, ok := value.(string)
  35120. if !ok {
  35121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35122. }
  35123. m.SetPhoneName(v)
  35124. return nil
  35125. case whatsapp.FieldPhoneStatus:
  35126. v, ok := value.(int8)
  35127. if !ok {
  35128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35129. }
  35130. m.SetPhoneStatus(v)
  35131. return nil
  35132. case whatsapp.FieldOrganizationID:
  35133. v, ok := value.(uint64)
  35134. if !ok {
  35135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35136. }
  35137. m.SetOrganizationID(v)
  35138. return nil
  35139. case whatsapp.FieldAPIBase:
  35140. v, ok := value.(string)
  35141. if !ok {
  35142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35143. }
  35144. m.SetAPIBase(v)
  35145. return nil
  35146. case whatsapp.FieldAPIKey:
  35147. v, ok := value.(string)
  35148. if !ok {
  35149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35150. }
  35151. m.SetAPIKey(v)
  35152. return nil
  35153. case whatsapp.FieldAllowList:
  35154. v, ok := value.([]string)
  35155. if !ok {
  35156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35157. }
  35158. m.SetAllowList(v)
  35159. return nil
  35160. case whatsapp.FieldGroupAllowList:
  35161. v, ok := value.([]string)
  35162. if !ok {
  35163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35164. }
  35165. m.SetGroupAllowList(v)
  35166. return nil
  35167. case whatsapp.FieldBlockList:
  35168. v, ok := value.([]string)
  35169. if !ok {
  35170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35171. }
  35172. m.SetBlockList(v)
  35173. return nil
  35174. case whatsapp.FieldGroupBlockList:
  35175. v, ok := value.([]string)
  35176. if !ok {
  35177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35178. }
  35179. m.SetGroupBlockList(v)
  35180. return nil
  35181. }
  35182. return fmt.Errorf("unknown Whatsapp field %s", name)
  35183. }
  35184. // AddedFields returns all numeric fields that were incremented/decremented during
  35185. // this mutation.
  35186. func (m *WhatsappMutation) AddedFields() []string {
  35187. var fields []string
  35188. if m.addstatus != nil {
  35189. fields = append(fields, whatsapp.FieldStatus)
  35190. }
  35191. if m.addphone_status != nil {
  35192. fields = append(fields, whatsapp.FieldPhoneStatus)
  35193. }
  35194. if m.addorganization_id != nil {
  35195. fields = append(fields, whatsapp.FieldOrganizationID)
  35196. }
  35197. return fields
  35198. }
  35199. // AddedField returns the numeric value that was incremented/decremented on a field
  35200. // with the given name. The second boolean return value indicates that this field
  35201. // was not set, or was not defined in the schema.
  35202. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  35203. switch name {
  35204. case whatsapp.FieldStatus:
  35205. return m.AddedStatus()
  35206. case whatsapp.FieldPhoneStatus:
  35207. return m.AddedPhoneStatus()
  35208. case whatsapp.FieldOrganizationID:
  35209. return m.AddedOrganizationID()
  35210. }
  35211. return nil, false
  35212. }
  35213. // AddField adds the value to the field with the given name. It returns an error if
  35214. // the field is not defined in the schema, or if the type mismatched the field
  35215. // type.
  35216. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  35217. switch name {
  35218. case whatsapp.FieldStatus:
  35219. v, ok := value.(int8)
  35220. if !ok {
  35221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35222. }
  35223. m.AddStatus(v)
  35224. return nil
  35225. case whatsapp.FieldPhoneStatus:
  35226. v, ok := value.(int8)
  35227. if !ok {
  35228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35229. }
  35230. m.AddPhoneStatus(v)
  35231. return nil
  35232. case whatsapp.FieldOrganizationID:
  35233. v, ok := value.(int64)
  35234. if !ok {
  35235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35236. }
  35237. m.AddOrganizationID(v)
  35238. return nil
  35239. }
  35240. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  35241. }
  35242. // ClearedFields returns all nullable fields that were cleared during this
  35243. // mutation.
  35244. func (m *WhatsappMutation) ClearedFields() []string {
  35245. var fields []string
  35246. if m.FieldCleared(whatsapp.FieldStatus) {
  35247. fields = append(fields, whatsapp.FieldStatus)
  35248. }
  35249. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  35250. fields = append(fields, whatsapp.FieldDeletedAt)
  35251. }
  35252. if m.FieldCleared(whatsapp.FieldWaID) {
  35253. fields = append(fields, whatsapp.FieldWaID)
  35254. }
  35255. if m.FieldCleared(whatsapp.FieldWaName) {
  35256. fields = append(fields, whatsapp.FieldWaName)
  35257. }
  35258. if m.FieldCleared(whatsapp.FieldCallback) {
  35259. fields = append(fields, whatsapp.FieldCallback)
  35260. }
  35261. if m.FieldCleared(whatsapp.FieldAccount) {
  35262. fields = append(fields, whatsapp.FieldAccount)
  35263. }
  35264. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  35265. fields = append(fields, whatsapp.FieldOrganizationID)
  35266. }
  35267. if m.FieldCleared(whatsapp.FieldAPIBase) {
  35268. fields = append(fields, whatsapp.FieldAPIBase)
  35269. }
  35270. if m.FieldCleared(whatsapp.FieldAPIKey) {
  35271. fields = append(fields, whatsapp.FieldAPIKey)
  35272. }
  35273. if m.FieldCleared(whatsapp.FieldAllowList) {
  35274. fields = append(fields, whatsapp.FieldAllowList)
  35275. }
  35276. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  35277. fields = append(fields, whatsapp.FieldGroupAllowList)
  35278. }
  35279. if m.FieldCleared(whatsapp.FieldBlockList) {
  35280. fields = append(fields, whatsapp.FieldBlockList)
  35281. }
  35282. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  35283. fields = append(fields, whatsapp.FieldGroupBlockList)
  35284. }
  35285. return fields
  35286. }
  35287. // FieldCleared returns a boolean indicating if a field with the given name was
  35288. // cleared in this mutation.
  35289. func (m *WhatsappMutation) FieldCleared(name string) bool {
  35290. _, ok := m.clearedFields[name]
  35291. return ok
  35292. }
  35293. // ClearField clears the value of the field with the given name. It returns an
  35294. // error if the field is not defined in the schema.
  35295. func (m *WhatsappMutation) ClearField(name string) error {
  35296. switch name {
  35297. case whatsapp.FieldStatus:
  35298. m.ClearStatus()
  35299. return nil
  35300. case whatsapp.FieldDeletedAt:
  35301. m.ClearDeletedAt()
  35302. return nil
  35303. case whatsapp.FieldWaID:
  35304. m.ClearWaID()
  35305. return nil
  35306. case whatsapp.FieldWaName:
  35307. m.ClearWaName()
  35308. return nil
  35309. case whatsapp.FieldCallback:
  35310. m.ClearCallback()
  35311. return nil
  35312. case whatsapp.FieldAccount:
  35313. m.ClearAccount()
  35314. return nil
  35315. case whatsapp.FieldOrganizationID:
  35316. m.ClearOrganizationID()
  35317. return nil
  35318. case whatsapp.FieldAPIBase:
  35319. m.ClearAPIBase()
  35320. return nil
  35321. case whatsapp.FieldAPIKey:
  35322. m.ClearAPIKey()
  35323. return nil
  35324. case whatsapp.FieldAllowList:
  35325. m.ClearAllowList()
  35326. return nil
  35327. case whatsapp.FieldGroupAllowList:
  35328. m.ClearGroupAllowList()
  35329. return nil
  35330. case whatsapp.FieldBlockList:
  35331. m.ClearBlockList()
  35332. return nil
  35333. case whatsapp.FieldGroupBlockList:
  35334. m.ClearGroupBlockList()
  35335. return nil
  35336. }
  35337. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35338. }
  35339. // ResetField resets all changes in the mutation for the field with the given name.
  35340. // It returns an error if the field is not defined in the schema.
  35341. func (m *WhatsappMutation) ResetField(name string) error {
  35342. switch name {
  35343. case whatsapp.FieldCreatedAt:
  35344. m.ResetCreatedAt()
  35345. return nil
  35346. case whatsapp.FieldUpdatedAt:
  35347. m.ResetUpdatedAt()
  35348. return nil
  35349. case whatsapp.FieldStatus:
  35350. m.ResetStatus()
  35351. return nil
  35352. case whatsapp.FieldDeletedAt:
  35353. m.ResetDeletedAt()
  35354. return nil
  35355. case whatsapp.FieldWaID:
  35356. m.ResetWaID()
  35357. return nil
  35358. case whatsapp.FieldWaName:
  35359. m.ResetWaName()
  35360. return nil
  35361. case whatsapp.FieldCallback:
  35362. m.ResetCallback()
  35363. return nil
  35364. case whatsapp.FieldAgentID:
  35365. m.ResetAgentID()
  35366. return nil
  35367. case whatsapp.FieldAccount:
  35368. m.ResetAccount()
  35369. return nil
  35370. case whatsapp.FieldCc:
  35371. m.ResetCc()
  35372. return nil
  35373. case whatsapp.FieldPhone:
  35374. m.ResetPhone()
  35375. return nil
  35376. case whatsapp.FieldCcPhone:
  35377. m.ResetCcPhone()
  35378. return nil
  35379. case whatsapp.FieldPhoneName:
  35380. m.ResetPhoneName()
  35381. return nil
  35382. case whatsapp.FieldPhoneStatus:
  35383. m.ResetPhoneStatus()
  35384. return nil
  35385. case whatsapp.FieldOrganizationID:
  35386. m.ResetOrganizationID()
  35387. return nil
  35388. case whatsapp.FieldAPIBase:
  35389. m.ResetAPIBase()
  35390. return nil
  35391. case whatsapp.FieldAPIKey:
  35392. m.ResetAPIKey()
  35393. return nil
  35394. case whatsapp.FieldAllowList:
  35395. m.ResetAllowList()
  35396. return nil
  35397. case whatsapp.FieldGroupAllowList:
  35398. m.ResetGroupAllowList()
  35399. return nil
  35400. case whatsapp.FieldBlockList:
  35401. m.ResetBlockList()
  35402. return nil
  35403. case whatsapp.FieldGroupBlockList:
  35404. m.ResetGroupBlockList()
  35405. return nil
  35406. }
  35407. return fmt.Errorf("unknown Whatsapp field %s", name)
  35408. }
  35409. // AddedEdges returns all edge names that were set/added in this mutation.
  35410. func (m *WhatsappMutation) AddedEdges() []string {
  35411. edges := make([]string, 0, 1)
  35412. if m.agent != nil {
  35413. edges = append(edges, whatsapp.EdgeAgent)
  35414. }
  35415. return edges
  35416. }
  35417. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35418. // name in this mutation.
  35419. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35420. switch name {
  35421. case whatsapp.EdgeAgent:
  35422. if id := m.agent; id != nil {
  35423. return []ent.Value{*id}
  35424. }
  35425. }
  35426. return nil
  35427. }
  35428. // RemovedEdges returns all edge names that were removed in this mutation.
  35429. func (m *WhatsappMutation) RemovedEdges() []string {
  35430. edges := make([]string, 0, 1)
  35431. return edges
  35432. }
  35433. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35434. // the given name in this mutation.
  35435. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35436. return nil
  35437. }
  35438. // ClearedEdges returns all edge names that were cleared in this mutation.
  35439. func (m *WhatsappMutation) ClearedEdges() []string {
  35440. edges := make([]string, 0, 1)
  35441. if m.clearedagent {
  35442. edges = append(edges, whatsapp.EdgeAgent)
  35443. }
  35444. return edges
  35445. }
  35446. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35447. // was cleared in this mutation.
  35448. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35449. switch name {
  35450. case whatsapp.EdgeAgent:
  35451. return m.clearedagent
  35452. }
  35453. return false
  35454. }
  35455. // ClearEdge clears the value of the edge with the given name. It returns an error
  35456. // if that edge is not defined in the schema.
  35457. func (m *WhatsappMutation) ClearEdge(name string) error {
  35458. switch name {
  35459. case whatsapp.EdgeAgent:
  35460. m.ClearAgent()
  35461. return nil
  35462. }
  35463. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35464. }
  35465. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35466. // It returns an error if the edge is not defined in the schema.
  35467. func (m *WhatsappMutation) ResetEdge(name string) error {
  35468. switch name {
  35469. case whatsapp.EdgeAgent:
  35470. m.ResetAgent()
  35471. return nil
  35472. }
  35473. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35474. }
  35475. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  35476. type WhatsappChannelMutation struct {
  35477. config
  35478. op Op
  35479. typ string
  35480. id *uint64
  35481. created_at *time.Time
  35482. updated_at *time.Time
  35483. status *uint8
  35484. addstatus *int8
  35485. deleted_at *time.Time
  35486. ak *string
  35487. sk *string
  35488. wa_id *string
  35489. wa_name *string
  35490. waba_id *uint64
  35491. addwaba_id *int64
  35492. business_id *uint64
  35493. addbusiness_id *int64
  35494. organization_id *uint64
  35495. addorganization_id *int64
  35496. verify_account *string
  35497. clearedFields map[string]struct{}
  35498. done bool
  35499. oldValue func(context.Context) (*WhatsappChannel, error)
  35500. predicates []predicate.WhatsappChannel
  35501. }
  35502. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  35503. // whatsappchannelOption allows management of the mutation configuration using functional options.
  35504. type whatsappchannelOption func(*WhatsappChannelMutation)
  35505. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  35506. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  35507. m := &WhatsappChannelMutation{
  35508. config: c,
  35509. op: op,
  35510. typ: TypeWhatsappChannel,
  35511. clearedFields: make(map[string]struct{}),
  35512. }
  35513. for _, opt := range opts {
  35514. opt(m)
  35515. }
  35516. return m
  35517. }
  35518. // withWhatsappChannelID sets the ID field of the mutation.
  35519. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  35520. return func(m *WhatsappChannelMutation) {
  35521. var (
  35522. err error
  35523. once sync.Once
  35524. value *WhatsappChannel
  35525. )
  35526. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  35527. once.Do(func() {
  35528. if m.done {
  35529. err = errors.New("querying old values post mutation is not allowed")
  35530. } else {
  35531. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  35532. }
  35533. })
  35534. return value, err
  35535. }
  35536. m.id = &id
  35537. }
  35538. }
  35539. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  35540. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  35541. return func(m *WhatsappChannelMutation) {
  35542. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  35543. return node, nil
  35544. }
  35545. m.id = &node.ID
  35546. }
  35547. }
  35548. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35549. // executed in a transaction (ent.Tx), a transactional client is returned.
  35550. func (m WhatsappChannelMutation) Client() *Client {
  35551. client := &Client{config: m.config}
  35552. client.init()
  35553. return client
  35554. }
  35555. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35556. // it returns an error otherwise.
  35557. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  35558. if _, ok := m.driver.(*txDriver); !ok {
  35559. return nil, errors.New("ent: mutation is not running in a transaction")
  35560. }
  35561. tx := &Tx{config: m.config}
  35562. tx.init()
  35563. return tx, nil
  35564. }
  35565. // SetID sets the value of the id field. Note that this
  35566. // operation is only accepted on creation of WhatsappChannel entities.
  35567. func (m *WhatsappChannelMutation) SetID(id uint64) {
  35568. m.id = &id
  35569. }
  35570. // ID returns the ID value in the mutation. Note that the ID is only available
  35571. // if it was provided to the builder or after it was returned from the database.
  35572. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  35573. if m.id == nil {
  35574. return
  35575. }
  35576. return *m.id, true
  35577. }
  35578. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35579. // That means, if the mutation is applied within a transaction with an isolation level such
  35580. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35581. // or updated by the mutation.
  35582. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  35583. switch {
  35584. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35585. id, exists := m.ID()
  35586. if exists {
  35587. return []uint64{id}, nil
  35588. }
  35589. fallthrough
  35590. case m.op.Is(OpUpdate | OpDelete):
  35591. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  35592. default:
  35593. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35594. }
  35595. }
  35596. // SetCreatedAt sets the "created_at" field.
  35597. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  35598. m.created_at = &t
  35599. }
  35600. // CreatedAt returns the value of the "created_at" field in the mutation.
  35601. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  35602. v := m.created_at
  35603. if v == nil {
  35604. return
  35605. }
  35606. return *v, true
  35607. }
  35608. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  35609. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35611. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35612. if !m.op.Is(OpUpdateOne) {
  35613. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35614. }
  35615. if m.id == nil || m.oldValue == nil {
  35616. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35617. }
  35618. oldValue, err := m.oldValue(ctx)
  35619. if err != nil {
  35620. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35621. }
  35622. return oldValue.CreatedAt, nil
  35623. }
  35624. // ResetCreatedAt resets all changes to the "created_at" field.
  35625. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  35626. m.created_at = nil
  35627. }
  35628. // SetUpdatedAt sets the "updated_at" field.
  35629. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  35630. m.updated_at = &t
  35631. }
  35632. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35633. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  35634. v := m.updated_at
  35635. if v == nil {
  35636. return
  35637. }
  35638. return *v, true
  35639. }
  35640. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  35641. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35643. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35644. if !m.op.Is(OpUpdateOne) {
  35645. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35646. }
  35647. if m.id == nil || m.oldValue == nil {
  35648. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35649. }
  35650. oldValue, err := m.oldValue(ctx)
  35651. if err != nil {
  35652. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35653. }
  35654. return oldValue.UpdatedAt, nil
  35655. }
  35656. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35657. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  35658. m.updated_at = nil
  35659. }
  35660. // SetStatus sets the "status" field.
  35661. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  35662. m.status = &u
  35663. m.addstatus = nil
  35664. }
  35665. // Status returns the value of the "status" field in the mutation.
  35666. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  35667. v := m.status
  35668. if v == nil {
  35669. return
  35670. }
  35671. return *v, true
  35672. }
  35673. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  35674. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35676. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35677. if !m.op.Is(OpUpdateOne) {
  35678. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35679. }
  35680. if m.id == nil || m.oldValue == nil {
  35681. return v, errors.New("OldStatus requires an ID field in the mutation")
  35682. }
  35683. oldValue, err := m.oldValue(ctx)
  35684. if err != nil {
  35685. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35686. }
  35687. return oldValue.Status, nil
  35688. }
  35689. // AddStatus adds u to the "status" field.
  35690. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  35691. if m.addstatus != nil {
  35692. *m.addstatus += u
  35693. } else {
  35694. m.addstatus = &u
  35695. }
  35696. }
  35697. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35698. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  35699. v := m.addstatus
  35700. if v == nil {
  35701. return
  35702. }
  35703. return *v, true
  35704. }
  35705. // ClearStatus clears the value of the "status" field.
  35706. func (m *WhatsappChannelMutation) ClearStatus() {
  35707. m.status = nil
  35708. m.addstatus = nil
  35709. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  35710. }
  35711. // StatusCleared returns if the "status" field was cleared in this mutation.
  35712. func (m *WhatsappChannelMutation) StatusCleared() bool {
  35713. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  35714. return ok
  35715. }
  35716. // ResetStatus resets all changes to the "status" field.
  35717. func (m *WhatsappChannelMutation) ResetStatus() {
  35718. m.status = nil
  35719. m.addstatus = nil
  35720. delete(m.clearedFields, whatsappchannel.FieldStatus)
  35721. }
  35722. // SetDeletedAt sets the "deleted_at" field.
  35723. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  35724. m.deleted_at = &t
  35725. }
  35726. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35727. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  35728. v := m.deleted_at
  35729. if v == nil {
  35730. return
  35731. }
  35732. return *v, true
  35733. }
  35734. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  35735. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35737. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35738. if !m.op.Is(OpUpdateOne) {
  35739. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35740. }
  35741. if m.id == nil || m.oldValue == nil {
  35742. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35743. }
  35744. oldValue, err := m.oldValue(ctx)
  35745. if err != nil {
  35746. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35747. }
  35748. return oldValue.DeletedAt, nil
  35749. }
  35750. // ClearDeletedAt clears the value of the "deleted_at" field.
  35751. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  35752. m.deleted_at = nil
  35753. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  35754. }
  35755. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35756. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  35757. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  35758. return ok
  35759. }
  35760. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35761. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  35762. m.deleted_at = nil
  35763. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  35764. }
  35765. // SetAk sets the "ak" field.
  35766. func (m *WhatsappChannelMutation) SetAk(s string) {
  35767. m.ak = &s
  35768. }
  35769. // Ak returns the value of the "ak" field in the mutation.
  35770. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  35771. v := m.ak
  35772. if v == nil {
  35773. return
  35774. }
  35775. return *v, true
  35776. }
  35777. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  35778. // If the WhatsappChannel 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 *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  35781. if !m.op.Is(OpUpdateOne) {
  35782. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  35783. }
  35784. if m.id == nil || m.oldValue == nil {
  35785. return v, errors.New("OldAk 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 OldAk: %w", err)
  35790. }
  35791. return oldValue.Ak, nil
  35792. }
  35793. // ClearAk clears the value of the "ak" field.
  35794. func (m *WhatsappChannelMutation) ClearAk() {
  35795. m.ak = nil
  35796. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  35797. }
  35798. // AkCleared returns if the "ak" field was cleared in this mutation.
  35799. func (m *WhatsappChannelMutation) AkCleared() bool {
  35800. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  35801. return ok
  35802. }
  35803. // ResetAk resets all changes to the "ak" field.
  35804. func (m *WhatsappChannelMutation) ResetAk() {
  35805. m.ak = nil
  35806. delete(m.clearedFields, whatsappchannel.FieldAk)
  35807. }
  35808. // SetSk sets the "sk" field.
  35809. func (m *WhatsappChannelMutation) SetSk(s string) {
  35810. m.sk = &s
  35811. }
  35812. // Sk returns the value of the "sk" field in the mutation.
  35813. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  35814. v := m.sk
  35815. if v == nil {
  35816. return
  35817. }
  35818. return *v, true
  35819. }
  35820. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  35821. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35823. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  35824. if !m.op.Is(OpUpdateOne) {
  35825. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  35826. }
  35827. if m.id == nil || m.oldValue == nil {
  35828. return v, errors.New("OldSk requires an ID field in the mutation")
  35829. }
  35830. oldValue, err := m.oldValue(ctx)
  35831. if err != nil {
  35832. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  35833. }
  35834. return oldValue.Sk, nil
  35835. }
  35836. // ResetSk resets all changes to the "sk" field.
  35837. func (m *WhatsappChannelMutation) ResetSk() {
  35838. m.sk = nil
  35839. }
  35840. // SetWaID sets the "wa_id" field.
  35841. func (m *WhatsappChannelMutation) SetWaID(s string) {
  35842. m.wa_id = &s
  35843. }
  35844. // WaID returns the value of the "wa_id" field in the mutation.
  35845. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  35846. v := m.wa_id
  35847. if v == nil {
  35848. return
  35849. }
  35850. return *v, true
  35851. }
  35852. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  35853. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35855. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  35856. if !m.op.Is(OpUpdateOne) {
  35857. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35858. }
  35859. if m.id == nil || m.oldValue == nil {
  35860. return v, errors.New("OldWaID requires an ID field in the mutation")
  35861. }
  35862. oldValue, err := m.oldValue(ctx)
  35863. if err != nil {
  35864. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35865. }
  35866. return oldValue.WaID, nil
  35867. }
  35868. // ClearWaID clears the value of the "wa_id" field.
  35869. func (m *WhatsappChannelMutation) ClearWaID() {
  35870. m.wa_id = nil
  35871. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  35872. }
  35873. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35874. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  35875. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  35876. return ok
  35877. }
  35878. // ResetWaID resets all changes to the "wa_id" field.
  35879. func (m *WhatsappChannelMutation) ResetWaID() {
  35880. m.wa_id = nil
  35881. delete(m.clearedFields, whatsappchannel.FieldWaID)
  35882. }
  35883. // SetWaName sets the "wa_name" field.
  35884. func (m *WhatsappChannelMutation) SetWaName(s string) {
  35885. m.wa_name = &s
  35886. }
  35887. // WaName returns the value of the "wa_name" field in the mutation.
  35888. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  35889. v := m.wa_name
  35890. if v == nil {
  35891. return
  35892. }
  35893. return *v, true
  35894. }
  35895. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  35896. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35898. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  35899. if !m.op.Is(OpUpdateOne) {
  35900. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35901. }
  35902. if m.id == nil || m.oldValue == nil {
  35903. return v, errors.New("OldWaName requires an ID field in the mutation")
  35904. }
  35905. oldValue, err := m.oldValue(ctx)
  35906. if err != nil {
  35907. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35908. }
  35909. return oldValue.WaName, nil
  35910. }
  35911. // ClearWaName clears the value of the "wa_name" field.
  35912. func (m *WhatsappChannelMutation) ClearWaName() {
  35913. m.wa_name = nil
  35914. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  35915. }
  35916. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35917. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  35918. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  35919. return ok
  35920. }
  35921. // ResetWaName resets all changes to the "wa_name" field.
  35922. func (m *WhatsappChannelMutation) ResetWaName() {
  35923. m.wa_name = nil
  35924. delete(m.clearedFields, whatsappchannel.FieldWaName)
  35925. }
  35926. // SetWabaID sets the "waba_id" field.
  35927. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  35928. m.waba_id = &u
  35929. m.addwaba_id = nil
  35930. }
  35931. // WabaID returns the value of the "waba_id" field in the mutation.
  35932. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  35933. v := m.waba_id
  35934. if v == nil {
  35935. return
  35936. }
  35937. return *v, true
  35938. }
  35939. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  35940. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35942. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  35943. if !m.op.Is(OpUpdateOne) {
  35944. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  35945. }
  35946. if m.id == nil || m.oldValue == nil {
  35947. return v, errors.New("OldWabaID requires an ID field in the mutation")
  35948. }
  35949. oldValue, err := m.oldValue(ctx)
  35950. if err != nil {
  35951. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  35952. }
  35953. return oldValue.WabaID, nil
  35954. }
  35955. // AddWabaID adds u to the "waba_id" field.
  35956. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  35957. if m.addwaba_id != nil {
  35958. *m.addwaba_id += u
  35959. } else {
  35960. m.addwaba_id = &u
  35961. }
  35962. }
  35963. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  35964. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  35965. v := m.addwaba_id
  35966. if v == nil {
  35967. return
  35968. }
  35969. return *v, true
  35970. }
  35971. // ResetWabaID resets all changes to the "waba_id" field.
  35972. func (m *WhatsappChannelMutation) ResetWabaID() {
  35973. m.waba_id = nil
  35974. m.addwaba_id = nil
  35975. }
  35976. // SetBusinessID sets the "business_id" field.
  35977. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  35978. m.business_id = &u
  35979. m.addbusiness_id = nil
  35980. }
  35981. // BusinessID returns the value of the "business_id" field in the mutation.
  35982. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  35983. v := m.business_id
  35984. if v == nil {
  35985. return
  35986. }
  35987. return *v, true
  35988. }
  35989. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  35990. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35992. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  35993. if !m.op.Is(OpUpdateOne) {
  35994. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  35995. }
  35996. if m.id == nil || m.oldValue == nil {
  35997. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  35998. }
  35999. oldValue, err := m.oldValue(ctx)
  36000. if err != nil {
  36001. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  36002. }
  36003. return oldValue.BusinessID, nil
  36004. }
  36005. // AddBusinessID adds u to the "business_id" field.
  36006. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  36007. if m.addbusiness_id != nil {
  36008. *m.addbusiness_id += u
  36009. } else {
  36010. m.addbusiness_id = &u
  36011. }
  36012. }
  36013. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  36014. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  36015. v := m.addbusiness_id
  36016. if v == nil {
  36017. return
  36018. }
  36019. return *v, true
  36020. }
  36021. // ResetBusinessID resets all changes to the "business_id" field.
  36022. func (m *WhatsappChannelMutation) ResetBusinessID() {
  36023. m.business_id = nil
  36024. m.addbusiness_id = nil
  36025. }
  36026. // SetOrganizationID sets the "organization_id" field.
  36027. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  36028. m.organization_id = &u
  36029. m.addorganization_id = nil
  36030. }
  36031. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36032. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  36033. v := m.organization_id
  36034. if v == nil {
  36035. return
  36036. }
  36037. return *v, true
  36038. }
  36039. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  36040. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36042. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36043. if !m.op.Is(OpUpdateOne) {
  36044. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36045. }
  36046. if m.id == nil || m.oldValue == nil {
  36047. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36048. }
  36049. oldValue, err := m.oldValue(ctx)
  36050. if err != nil {
  36051. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36052. }
  36053. return oldValue.OrganizationID, nil
  36054. }
  36055. // AddOrganizationID adds u to the "organization_id" field.
  36056. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  36057. if m.addorganization_id != nil {
  36058. *m.addorganization_id += u
  36059. } else {
  36060. m.addorganization_id = &u
  36061. }
  36062. }
  36063. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36064. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  36065. v := m.addorganization_id
  36066. if v == nil {
  36067. return
  36068. }
  36069. return *v, true
  36070. }
  36071. // ClearOrganizationID clears the value of the "organization_id" field.
  36072. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  36073. m.organization_id = nil
  36074. m.addorganization_id = nil
  36075. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  36076. }
  36077. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36078. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  36079. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  36080. return ok
  36081. }
  36082. // ResetOrganizationID resets all changes to the "organization_id" field.
  36083. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  36084. m.organization_id = nil
  36085. m.addorganization_id = nil
  36086. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  36087. }
  36088. // SetVerifyAccount sets the "verify_account" field.
  36089. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  36090. m.verify_account = &s
  36091. }
  36092. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  36093. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  36094. v := m.verify_account
  36095. if v == nil {
  36096. return
  36097. }
  36098. return *v, true
  36099. }
  36100. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  36101. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36103. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  36104. if !m.op.Is(OpUpdateOne) {
  36105. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  36106. }
  36107. if m.id == nil || m.oldValue == nil {
  36108. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  36109. }
  36110. oldValue, err := m.oldValue(ctx)
  36111. if err != nil {
  36112. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  36113. }
  36114. return oldValue.VerifyAccount, nil
  36115. }
  36116. // ResetVerifyAccount resets all changes to the "verify_account" field.
  36117. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  36118. m.verify_account = nil
  36119. }
  36120. // Where appends a list predicates to the WhatsappChannelMutation builder.
  36121. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  36122. m.predicates = append(m.predicates, ps...)
  36123. }
  36124. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  36125. // users can use type-assertion to append predicates that do not depend on any generated package.
  36126. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  36127. p := make([]predicate.WhatsappChannel, len(ps))
  36128. for i := range ps {
  36129. p[i] = ps[i]
  36130. }
  36131. m.Where(p...)
  36132. }
  36133. // Op returns the operation name.
  36134. func (m *WhatsappChannelMutation) Op() Op {
  36135. return m.op
  36136. }
  36137. // SetOp allows setting the mutation operation.
  36138. func (m *WhatsappChannelMutation) SetOp(op Op) {
  36139. m.op = op
  36140. }
  36141. // Type returns the node type of this mutation (WhatsappChannel).
  36142. func (m *WhatsappChannelMutation) Type() string {
  36143. return m.typ
  36144. }
  36145. // Fields returns all fields that were changed during this mutation. Note that in
  36146. // order to get all numeric fields that were incremented/decremented, call
  36147. // AddedFields().
  36148. func (m *WhatsappChannelMutation) Fields() []string {
  36149. fields := make([]string, 0, 12)
  36150. if m.created_at != nil {
  36151. fields = append(fields, whatsappchannel.FieldCreatedAt)
  36152. }
  36153. if m.updated_at != nil {
  36154. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  36155. }
  36156. if m.status != nil {
  36157. fields = append(fields, whatsappchannel.FieldStatus)
  36158. }
  36159. if m.deleted_at != nil {
  36160. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36161. }
  36162. if m.ak != nil {
  36163. fields = append(fields, whatsappchannel.FieldAk)
  36164. }
  36165. if m.sk != nil {
  36166. fields = append(fields, whatsappchannel.FieldSk)
  36167. }
  36168. if m.wa_id != nil {
  36169. fields = append(fields, whatsappchannel.FieldWaID)
  36170. }
  36171. if m.wa_name != nil {
  36172. fields = append(fields, whatsappchannel.FieldWaName)
  36173. }
  36174. if m.waba_id != nil {
  36175. fields = append(fields, whatsappchannel.FieldWabaID)
  36176. }
  36177. if m.business_id != nil {
  36178. fields = append(fields, whatsappchannel.FieldBusinessID)
  36179. }
  36180. if m.organization_id != nil {
  36181. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36182. }
  36183. if m.verify_account != nil {
  36184. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  36185. }
  36186. return fields
  36187. }
  36188. // Field returns the value of a field with the given name. The second boolean
  36189. // return value indicates that this field was not set, or was not defined in the
  36190. // schema.
  36191. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  36192. switch name {
  36193. case whatsappchannel.FieldCreatedAt:
  36194. return m.CreatedAt()
  36195. case whatsappchannel.FieldUpdatedAt:
  36196. return m.UpdatedAt()
  36197. case whatsappchannel.FieldStatus:
  36198. return m.Status()
  36199. case whatsappchannel.FieldDeletedAt:
  36200. return m.DeletedAt()
  36201. case whatsappchannel.FieldAk:
  36202. return m.Ak()
  36203. case whatsappchannel.FieldSk:
  36204. return m.Sk()
  36205. case whatsappchannel.FieldWaID:
  36206. return m.WaID()
  36207. case whatsappchannel.FieldWaName:
  36208. return m.WaName()
  36209. case whatsappchannel.FieldWabaID:
  36210. return m.WabaID()
  36211. case whatsappchannel.FieldBusinessID:
  36212. return m.BusinessID()
  36213. case whatsappchannel.FieldOrganizationID:
  36214. return m.OrganizationID()
  36215. case whatsappchannel.FieldVerifyAccount:
  36216. return m.VerifyAccount()
  36217. }
  36218. return nil, false
  36219. }
  36220. // OldField returns the old value of the field from the database. An error is
  36221. // returned if the mutation operation is not UpdateOne, or the query to the
  36222. // database failed.
  36223. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36224. switch name {
  36225. case whatsappchannel.FieldCreatedAt:
  36226. return m.OldCreatedAt(ctx)
  36227. case whatsappchannel.FieldUpdatedAt:
  36228. return m.OldUpdatedAt(ctx)
  36229. case whatsappchannel.FieldStatus:
  36230. return m.OldStatus(ctx)
  36231. case whatsappchannel.FieldDeletedAt:
  36232. return m.OldDeletedAt(ctx)
  36233. case whatsappchannel.FieldAk:
  36234. return m.OldAk(ctx)
  36235. case whatsappchannel.FieldSk:
  36236. return m.OldSk(ctx)
  36237. case whatsappchannel.FieldWaID:
  36238. return m.OldWaID(ctx)
  36239. case whatsappchannel.FieldWaName:
  36240. return m.OldWaName(ctx)
  36241. case whatsappchannel.FieldWabaID:
  36242. return m.OldWabaID(ctx)
  36243. case whatsappchannel.FieldBusinessID:
  36244. return m.OldBusinessID(ctx)
  36245. case whatsappchannel.FieldOrganizationID:
  36246. return m.OldOrganizationID(ctx)
  36247. case whatsappchannel.FieldVerifyAccount:
  36248. return m.OldVerifyAccount(ctx)
  36249. }
  36250. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  36251. }
  36252. // SetField sets the value of a field with the given name. It returns an error if
  36253. // the field is not defined in the schema, or if the type mismatched the field
  36254. // type.
  36255. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  36256. switch name {
  36257. case whatsappchannel.FieldCreatedAt:
  36258. v, ok := value.(time.Time)
  36259. if !ok {
  36260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36261. }
  36262. m.SetCreatedAt(v)
  36263. return nil
  36264. case whatsappchannel.FieldUpdatedAt:
  36265. v, ok := value.(time.Time)
  36266. if !ok {
  36267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36268. }
  36269. m.SetUpdatedAt(v)
  36270. return nil
  36271. case whatsappchannel.FieldStatus:
  36272. v, ok := value.(uint8)
  36273. if !ok {
  36274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36275. }
  36276. m.SetStatus(v)
  36277. return nil
  36278. case whatsappchannel.FieldDeletedAt:
  36279. v, ok := value.(time.Time)
  36280. if !ok {
  36281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36282. }
  36283. m.SetDeletedAt(v)
  36284. return nil
  36285. case whatsappchannel.FieldAk:
  36286. v, ok := value.(string)
  36287. if !ok {
  36288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36289. }
  36290. m.SetAk(v)
  36291. return nil
  36292. case whatsappchannel.FieldSk:
  36293. v, ok := value.(string)
  36294. if !ok {
  36295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36296. }
  36297. m.SetSk(v)
  36298. return nil
  36299. case whatsappchannel.FieldWaID:
  36300. v, ok := value.(string)
  36301. if !ok {
  36302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36303. }
  36304. m.SetWaID(v)
  36305. return nil
  36306. case whatsappchannel.FieldWaName:
  36307. v, ok := value.(string)
  36308. if !ok {
  36309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36310. }
  36311. m.SetWaName(v)
  36312. return nil
  36313. case whatsappchannel.FieldWabaID:
  36314. v, ok := value.(uint64)
  36315. if !ok {
  36316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36317. }
  36318. m.SetWabaID(v)
  36319. return nil
  36320. case whatsappchannel.FieldBusinessID:
  36321. v, ok := value.(uint64)
  36322. if !ok {
  36323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36324. }
  36325. m.SetBusinessID(v)
  36326. return nil
  36327. case whatsappchannel.FieldOrganizationID:
  36328. v, ok := value.(uint64)
  36329. if !ok {
  36330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36331. }
  36332. m.SetOrganizationID(v)
  36333. return nil
  36334. case whatsappchannel.FieldVerifyAccount:
  36335. v, ok := value.(string)
  36336. if !ok {
  36337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36338. }
  36339. m.SetVerifyAccount(v)
  36340. return nil
  36341. }
  36342. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36343. }
  36344. // AddedFields returns all numeric fields that were incremented/decremented during
  36345. // this mutation.
  36346. func (m *WhatsappChannelMutation) AddedFields() []string {
  36347. var fields []string
  36348. if m.addstatus != nil {
  36349. fields = append(fields, whatsappchannel.FieldStatus)
  36350. }
  36351. if m.addwaba_id != nil {
  36352. fields = append(fields, whatsappchannel.FieldWabaID)
  36353. }
  36354. if m.addbusiness_id != nil {
  36355. fields = append(fields, whatsappchannel.FieldBusinessID)
  36356. }
  36357. if m.addorganization_id != nil {
  36358. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36359. }
  36360. return fields
  36361. }
  36362. // AddedField returns the numeric value that was incremented/decremented on a field
  36363. // with the given name. The second boolean return value indicates that this field
  36364. // was not set, or was not defined in the schema.
  36365. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  36366. switch name {
  36367. case whatsappchannel.FieldStatus:
  36368. return m.AddedStatus()
  36369. case whatsappchannel.FieldWabaID:
  36370. return m.AddedWabaID()
  36371. case whatsappchannel.FieldBusinessID:
  36372. return m.AddedBusinessID()
  36373. case whatsappchannel.FieldOrganizationID:
  36374. return m.AddedOrganizationID()
  36375. }
  36376. return nil, false
  36377. }
  36378. // AddField adds the value to the field with the given name. It returns an error if
  36379. // the field is not defined in the schema, or if the type mismatched the field
  36380. // type.
  36381. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  36382. switch name {
  36383. case whatsappchannel.FieldStatus:
  36384. v, ok := value.(int8)
  36385. if !ok {
  36386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36387. }
  36388. m.AddStatus(v)
  36389. return nil
  36390. case whatsappchannel.FieldWabaID:
  36391. v, ok := value.(int64)
  36392. if !ok {
  36393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36394. }
  36395. m.AddWabaID(v)
  36396. return nil
  36397. case whatsappchannel.FieldBusinessID:
  36398. v, ok := value.(int64)
  36399. if !ok {
  36400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36401. }
  36402. m.AddBusinessID(v)
  36403. return nil
  36404. case whatsappchannel.FieldOrganizationID:
  36405. v, ok := value.(int64)
  36406. if !ok {
  36407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36408. }
  36409. m.AddOrganizationID(v)
  36410. return nil
  36411. }
  36412. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  36413. }
  36414. // ClearedFields returns all nullable fields that were cleared during this
  36415. // mutation.
  36416. func (m *WhatsappChannelMutation) ClearedFields() []string {
  36417. var fields []string
  36418. if m.FieldCleared(whatsappchannel.FieldStatus) {
  36419. fields = append(fields, whatsappchannel.FieldStatus)
  36420. }
  36421. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  36422. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36423. }
  36424. if m.FieldCleared(whatsappchannel.FieldAk) {
  36425. fields = append(fields, whatsappchannel.FieldAk)
  36426. }
  36427. if m.FieldCleared(whatsappchannel.FieldWaID) {
  36428. fields = append(fields, whatsappchannel.FieldWaID)
  36429. }
  36430. if m.FieldCleared(whatsappchannel.FieldWaName) {
  36431. fields = append(fields, whatsappchannel.FieldWaName)
  36432. }
  36433. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  36434. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36435. }
  36436. return fields
  36437. }
  36438. // FieldCleared returns a boolean indicating if a field with the given name was
  36439. // cleared in this mutation.
  36440. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  36441. _, ok := m.clearedFields[name]
  36442. return ok
  36443. }
  36444. // ClearField clears the value of the field with the given name. It returns an
  36445. // error if the field is not defined in the schema.
  36446. func (m *WhatsappChannelMutation) ClearField(name string) error {
  36447. switch name {
  36448. case whatsappchannel.FieldStatus:
  36449. m.ClearStatus()
  36450. return nil
  36451. case whatsappchannel.FieldDeletedAt:
  36452. m.ClearDeletedAt()
  36453. return nil
  36454. case whatsappchannel.FieldAk:
  36455. m.ClearAk()
  36456. return nil
  36457. case whatsappchannel.FieldWaID:
  36458. m.ClearWaID()
  36459. return nil
  36460. case whatsappchannel.FieldWaName:
  36461. m.ClearWaName()
  36462. return nil
  36463. case whatsappchannel.FieldOrganizationID:
  36464. m.ClearOrganizationID()
  36465. return nil
  36466. }
  36467. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  36468. }
  36469. // ResetField resets all changes in the mutation for the field with the given name.
  36470. // It returns an error if the field is not defined in the schema.
  36471. func (m *WhatsappChannelMutation) ResetField(name string) error {
  36472. switch name {
  36473. case whatsappchannel.FieldCreatedAt:
  36474. m.ResetCreatedAt()
  36475. return nil
  36476. case whatsappchannel.FieldUpdatedAt:
  36477. m.ResetUpdatedAt()
  36478. return nil
  36479. case whatsappchannel.FieldStatus:
  36480. m.ResetStatus()
  36481. return nil
  36482. case whatsappchannel.FieldDeletedAt:
  36483. m.ResetDeletedAt()
  36484. return nil
  36485. case whatsappchannel.FieldAk:
  36486. m.ResetAk()
  36487. return nil
  36488. case whatsappchannel.FieldSk:
  36489. m.ResetSk()
  36490. return nil
  36491. case whatsappchannel.FieldWaID:
  36492. m.ResetWaID()
  36493. return nil
  36494. case whatsappchannel.FieldWaName:
  36495. m.ResetWaName()
  36496. return nil
  36497. case whatsappchannel.FieldWabaID:
  36498. m.ResetWabaID()
  36499. return nil
  36500. case whatsappchannel.FieldBusinessID:
  36501. m.ResetBusinessID()
  36502. return nil
  36503. case whatsappchannel.FieldOrganizationID:
  36504. m.ResetOrganizationID()
  36505. return nil
  36506. case whatsappchannel.FieldVerifyAccount:
  36507. m.ResetVerifyAccount()
  36508. return nil
  36509. }
  36510. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36511. }
  36512. // AddedEdges returns all edge names that were set/added in this mutation.
  36513. func (m *WhatsappChannelMutation) AddedEdges() []string {
  36514. edges := make([]string, 0, 0)
  36515. return edges
  36516. }
  36517. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36518. // name in this mutation.
  36519. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  36520. return nil
  36521. }
  36522. // RemovedEdges returns all edge names that were removed in this mutation.
  36523. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  36524. edges := make([]string, 0, 0)
  36525. return edges
  36526. }
  36527. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36528. // the given name in this mutation.
  36529. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  36530. return nil
  36531. }
  36532. // ClearedEdges returns all edge names that were cleared in this mutation.
  36533. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  36534. edges := make([]string, 0, 0)
  36535. return edges
  36536. }
  36537. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36538. // was cleared in this mutation.
  36539. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  36540. return false
  36541. }
  36542. // ClearEdge clears the value of the edge with the given name. It returns an error
  36543. // if that edge is not defined in the schema.
  36544. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  36545. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  36546. }
  36547. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36548. // It returns an error if the edge is not defined in the schema.
  36549. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  36550. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  36551. }
  36552. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  36553. type WorkExperienceMutation struct {
  36554. config
  36555. op Op
  36556. typ string
  36557. id *uint64
  36558. created_at *time.Time
  36559. updated_at *time.Time
  36560. deleted_at *time.Time
  36561. start_date *time.Time
  36562. end_date *time.Time
  36563. company *string
  36564. experience *string
  36565. organization_id *uint64
  36566. addorganization_id *int64
  36567. clearedFields map[string]struct{}
  36568. employee *uint64
  36569. clearedemployee bool
  36570. done bool
  36571. oldValue func(context.Context) (*WorkExperience, error)
  36572. predicates []predicate.WorkExperience
  36573. }
  36574. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  36575. // workexperienceOption allows management of the mutation configuration using functional options.
  36576. type workexperienceOption func(*WorkExperienceMutation)
  36577. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  36578. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  36579. m := &WorkExperienceMutation{
  36580. config: c,
  36581. op: op,
  36582. typ: TypeWorkExperience,
  36583. clearedFields: make(map[string]struct{}),
  36584. }
  36585. for _, opt := range opts {
  36586. opt(m)
  36587. }
  36588. return m
  36589. }
  36590. // withWorkExperienceID sets the ID field of the mutation.
  36591. func withWorkExperienceID(id uint64) workexperienceOption {
  36592. return func(m *WorkExperienceMutation) {
  36593. var (
  36594. err error
  36595. once sync.Once
  36596. value *WorkExperience
  36597. )
  36598. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  36599. once.Do(func() {
  36600. if m.done {
  36601. err = errors.New("querying old values post mutation is not allowed")
  36602. } else {
  36603. value, err = m.Client().WorkExperience.Get(ctx, id)
  36604. }
  36605. })
  36606. return value, err
  36607. }
  36608. m.id = &id
  36609. }
  36610. }
  36611. // withWorkExperience sets the old WorkExperience of the mutation.
  36612. func withWorkExperience(node *WorkExperience) workexperienceOption {
  36613. return func(m *WorkExperienceMutation) {
  36614. m.oldValue = func(context.Context) (*WorkExperience, error) {
  36615. return node, nil
  36616. }
  36617. m.id = &node.ID
  36618. }
  36619. }
  36620. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36621. // executed in a transaction (ent.Tx), a transactional client is returned.
  36622. func (m WorkExperienceMutation) Client() *Client {
  36623. client := &Client{config: m.config}
  36624. client.init()
  36625. return client
  36626. }
  36627. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36628. // it returns an error otherwise.
  36629. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  36630. if _, ok := m.driver.(*txDriver); !ok {
  36631. return nil, errors.New("ent: mutation is not running in a transaction")
  36632. }
  36633. tx := &Tx{config: m.config}
  36634. tx.init()
  36635. return tx, nil
  36636. }
  36637. // SetID sets the value of the id field. Note that this
  36638. // operation is only accepted on creation of WorkExperience entities.
  36639. func (m *WorkExperienceMutation) SetID(id uint64) {
  36640. m.id = &id
  36641. }
  36642. // ID returns the ID value in the mutation. Note that the ID is only available
  36643. // if it was provided to the builder or after it was returned from the database.
  36644. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  36645. if m.id == nil {
  36646. return
  36647. }
  36648. return *m.id, true
  36649. }
  36650. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36651. // That means, if the mutation is applied within a transaction with an isolation level such
  36652. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36653. // or updated by the mutation.
  36654. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  36655. switch {
  36656. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36657. id, exists := m.ID()
  36658. if exists {
  36659. return []uint64{id}, nil
  36660. }
  36661. fallthrough
  36662. case m.op.Is(OpUpdate | OpDelete):
  36663. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  36664. default:
  36665. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36666. }
  36667. }
  36668. // SetCreatedAt sets the "created_at" field.
  36669. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  36670. m.created_at = &t
  36671. }
  36672. // CreatedAt returns the value of the "created_at" field in the mutation.
  36673. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  36674. v := m.created_at
  36675. if v == nil {
  36676. return
  36677. }
  36678. return *v, true
  36679. }
  36680. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  36681. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36683. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36684. if !m.op.Is(OpUpdateOne) {
  36685. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36686. }
  36687. if m.id == nil || m.oldValue == nil {
  36688. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36689. }
  36690. oldValue, err := m.oldValue(ctx)
  36691. if err != nil {
  36692. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36693. }
  36694. return oldValue.CreatedAt, nil
  36695. }
  36696. // ResetCreatedAt resets all changes to the "created_at" field.
  36697. func (m *WorkExperienceMutation) ResetCreatedAt() {
  36698. m.created_at = nil
  36699. }
  36700. // SetUpdatedAt sets the "updated_at" field.
  36701. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  36702. m.updated_at = &t
  36703. }
  36704. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36705. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  36706. v := m.updated_at
  36707. if v == nil {
  36708. return
  36709. }
  36710. return *v, true
  36711. }
  36712. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  36713. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36715. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36716. if !m.op.Is(OpUpdateOne) {
  36717. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36718. }
  36719. if m.id == nil || m.oldValue == nil {
  36720. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36721. }
  36722. oldValue, err := m.oldValue(ctx)
  36723. if err != nil {
  36724. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36725. }
  36726. return oldValue.UpdatedAt, nil
  36727. }
  36728. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36729. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  36730. m.updated_at = nil
  36731. }
  36732. // SetDeletedAt sets the "deleted_at" field.
  36733. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  36734. m.deleted_at = &t
  36735. }
  36736. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36737. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  36738. v := m.deleted_at
  36739. if v == nil {
  36740. return
  36741. }
  36742. return *v, true
  36743. }
  36744. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  36745. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36747. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36748. if !m.op.Is(OpUpdateOne) {
  36749. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36750. }
  36751. if m.id == nil || m.oldValue == nil {
  36752. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36753. }
  36754. oldValue, err := m.oldValue(ctx)
  36755. if err != nil {
  36756. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36757. }
  36758. return oldValue.DeletedAt, nil
  36759. }
  36760. // ClearDeletedAt clears the value of the "deleted_at" field.
  36761. func (m *WorkExperienceMutation) ClearDeletedAt() {
  36762. m.deleted_at = nil
  36763. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  36764. }
  36765. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36766. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  36767. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  36768. return ok
  36769. }
  36770. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36771. func (m *WorkExperienceMutation) ResetDeletedAt() {
  36772. m.deleted_at = nil
  36773. delete(m.clearedFields, workexperience.FieldDeletedAt)
  36774. }
  36775. // SetEmployeeID sets the "employee_id" field.
  36776. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  36777. m.employee = &u
  36778. }
  36779. // EmployeeID returns the value of the "employee_id" field in the mutation.
  36780. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  36781. v := m.employee
  36782. if v == nil {
  36783. return
  36784. }
  36785. return *v, true
  36786. }
  36787. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  36788. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36790. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  36791. if !m.op.Is(OpUpdateOne) {
  36792. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  36793. }
  36794. if m.id == nil || m.oldValue == nil {
  36795. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  36796. }
  36797. oldValue, err := m.oldValue(ctx)
  36798. if err != nil {
  36799. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  36800. }
  36801. return oldValue.EmployeeID, nil
  36802. }
  36803. // ResetEmployeeID resets all changes to the "employee_id" field.
  36804. func (m *WorkExperienceMutation) ResetEmployeeID() {
  36805. m.employee = nil
  36806. }
  36807. // SetStartDate sets the "start_date" field.
  36808. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  36809. m.start_date = &t
  36810. }
  36811. // StartDate returns the value of the "start_date" field in the mutation.
  36812. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  36813. v := m.start_date
  36814. if v == nil {
  36815. return
  36816. }
  36817. return *v, true
  36818. }
  36819. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  36820. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36822. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  36823. if !m.op.Is(OpUpdateOne) {
  36824. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  36825. }
  36826. if m.id == nil || m.oldValue == nil {
  36827. return v, errors.New("OldStartDate requires an ID field in the mutation")
  36828. }
  36829. oldValue, err := m.oldValue(ctx)
  36830. if err != nil {
  36831. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  36832. }
  36833. return oldValue.StartDate, nil
  36834. }
  36835. // ResetStartDate resets all changes to the "start_date" field.
  36836. func (m *WorkExperienceMutation) ResetStartDate() {
  36837. m.start_date = nil
  36838. }
  36839. // SetEndDate sets the "end_date" field.
  36840. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  36841. m.end_date = &t
  36842. }
  36843. // EndDate returns the value of the "end_date" field in the mutation.
  36844. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  36845. v := m.end_date
  36846. if v == nil {
  36847. return
  36848. }
  36849. return *v, true
  36850. }
  36851. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  36852. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36854. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  36855. if !m.op.Is(OpUpdateOne) {
  36856. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  36857. }
  36858. if m.id == nil || m.oldValue == nil {
  36859. return v, errors.New("OldEndDate requires an ID field in the mutation")
  36860. }
  36861. oldValue, err := m.oldValue(ctx)
  36862. if err != nil {
  36863. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  36864. }
  36865. return oldValue.EndDate, nil
  36866. }
  36867. // ResetEndDate resets all changes to the "end_date" field.
  36868. func (m *WorkExperienceMutation) ResetEndDate() {
  36869. m.end_date = nil
  36870. }
  36871. // SetCompany sets the "company" field.
  36872. func (m *WorkExperienceMutation) SetCompany(s string) {
  36873. m.company = &s
  36874. }
  36875. // Company returns the value of the "company" field in the mutation.
  36876. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  36877. v := m.company
  36878. if v == nil {
  36879. return
  36880. }
  36881. return *v, true
  36882. }
  36883. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  36884. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36886. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  36887. if !m.op.Is(OpUpdateOne) {
  36888. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  36889. }
  36890. if m.id == nil || m.oldValue == nil {
  36891. return v, errors.New("OldCompany requires an ID field in the mutation")
  36892. }
  36893. oldValue, err := m.oldValue(ctx)
  36894. if err != nil {
  36895. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  36896. }
  36897. return oldValue.Company, nil
  36898. }
  36899. // ResetCompany resets all changes to the "company" field.
  36900. func (m *WorkExperienceMutation) ResetCompany() {
  36901. m.company = nil
  36902. }
  36903. // SetExperience sets the "experience" field.
  36904. func (m *WorkExperienceMutation) SetExperience(s string) {
  36905. m.experience = &s
  36906. }
  36907. // Experience returns the value of the "experience" field in the mutation.
  36908. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  36909. v := m.experience
  36910. if v == nil {
  36911. return
  36912. }
  36913. return *v, true
  36914. }
  36915. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  36916. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36918. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  36919. if !m.op.Is(OpUpdateOne) {
  36920. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  36921. }
  36922. if m.id == nil || m.oldValue == nil {
  36923. return v, errors.New("OldExperience requires an ID field in the mutation")
  36924. }
  36925. oldValue, err := m.oldValue(ctx)
  36926. if err != nil {
  36927. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  36928. }
  36929. return oldValue.Experience, nil
  36930. }
  36931. // ResetExperience resets all changes to the "experience" field.
  36932. func (m *WorkExperienceMutation) ResetExperience() {
  36933. m.experience = nil
  36934. }
  36935. // SetOrganizationID sets the "organization_id" field.
  36936. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  36937. m.organization_id = &u
  36938. m.addorganization_id = nil
  36939. }
  36940. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36941. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  36942. v := m.organization_id
  36943. if v == nil {
  36944. return
  36945. }
  36946. return *v, true
  36947. }
  36948. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  36949. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36951. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36952. if !m.op.Is(OpUpdateOne) {
  36953. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36954. }
  36955. if m.id == nil || m.oldValue == nil {
  36956. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36957. }
  36958. oldValue, err := m.oldValue(ctx)
  36959. if err != nil {
  36960. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36961. }
  36962. return oldValue.OrganizationID, nil
  36963. }
  36964. // AddOrganizationID adds u to the "organization_id" field.
  36965. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  36966. if m.addorganization_id != nil {
  36967. *m.addorganization_id += u
  36968. } else {
  36969. m.addorganization_id = &u
  36970. }
  36971. }
  36972. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36973. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  36974. v := m.addorganization_id
  36975. if v == nil {
  36976. return
  36977. }
  36978. return *v, true
  36979. }
  36980. // ResetOrganizationID resets all changes to the "organization_id" field.
  36981. func (m *WorkExperienceMutation) ResetOrganizationID() {
  36982. m.organization_id = nil
  36983. m.addorganization_id = nil
  36984. }
  36985. // ClearEmployee clears the "employee" edge to the Employee entity.
  36986. func (m *WorkExperienceMutation) ClearEmployee() {
  36987. m.clearedemployee = true
  36988. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  36989. }
  36990. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  36991. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  36992. return m.clearedemployee
  36993. }
  36994. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  36995. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36996. // EmployeeID instead. It exists only for internal usage by the builders.
  36997. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  36998. if id := m.employee; id != nil {
  36999. ids = append(ids, *id)
  37000. }
  37001. return
  37002. }
  37003. // ResetEmployee resets all changes to the "employee" edge.
  37004. func (m *WorkExperienceMutation) ResetEmployee() {
  37005. m.employee = nil
  37006. m.clearedemployee = false
  37007. }
  37008. // Where appends a list predicates to the WorkExperienceMutation builder.
  37009. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  37010. m.predicates = append(m.predicates, ps...)
  37011. }
  37012. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  37013. // users can use type-assertion to append predicates that do not depend on any generated package.
  37014. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  37015. p := make([]predicate.WorkExperience, len(ps))
  37016. for i := range ps {
  37017. p[i] = ps[i]
  37018. }
  37019. m.Where(p...)
  37020. }
  37021. // Op returns the operation name.
  37022. func (m *WorkExperienceMutation) Op() Op {
  37023. return m.op
  37024. }
  37025. // SetOp allows setting the mutation operation.
  37026. func (m *WorkExperienceMutation) SetOp(op Op) {
  37027. m.op = op
  37028. }
  37029. // Type returns the node type of this mutation (WorkExperience).
  37030. func (m *WorkExperienceMutation) Type() string {
  37031. return m.typ
  37032. }
  37033. // Fields returns all fields that were changed during this mutation. Note that in
  37034. // order to get all numeric fields that were incremented/decremented, call
  37035. // AddedFields().
  37036. func (m *WorkExperienceMutation) Fields() []string {
  37037. fields := make([]string, 0, 9)
  37038. if m.created_at != nil {
  37039. fields = append(fields, workexperience.FieldCreatedAt)
  37040. }
  37041. if m.updated_at != nil {
  37042. fields = append(fields, workexperience.FieldUpdatedAt)
  37043. }
  37044. if m.deleted_at != nil {
  37045. fields = append(fields, workexperience.FieldDeletedAt)
  37046. }
  37047. if m.employee != nil {
  37048. fields = append(fields, workexperience.FieldEmployeeID)
  37049. }
  37050. if m.start_date != nil {
  37051. fields = append(fields, workexperience.FieldStartDate)
  37052. }
  37053. if m.end_date != nil {
  37054. fields = append(fields, workexperience.FieldEndDate)
  37055. }
  37056. if m.company != nil {
  37057. fields = append(fields, workexperience.FieldCompany)
  37058. }
  37059. if m.experience != nil {
  37060. fields = append(fields, workexperience.FieldExperience)
  37061. }
  37062. if m.organization_id != nil {
  37063. fields = append(fields, workexperience.FieldOrganizationID)
  37064. }
  37065. return fields
  37066. }
  37067. // Field returns the value of a field with the given name. The second boolean
  37068. // return value indicates that this field was not set, or was not defined in the
  37069. // schema.
  37070. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  37071. switch name {
  37072. case workexperience.FieldCreatedAt:
  37073. return m.CreatedAt()
  37074. case workexperience.FieldUpdatedAt:
  37075. return m.UpdatedAt()
  37076. case workexperience.FieldDeletedAt:
  37077. return m.DeletedAt()
  37078. case workexperience.FieldEmployeeID:
  37079. return m.EmployeeID()
  37080. case workexperience.FieldStartDate:
  37081. return m.StartDate()
  37082. case workexperience.FieldEndDate:
  37083. return m.EndDate()
  37084. case workexperience.FieldCompany:
  37085. return m.Company()
  37086. case workexperience.FieldExperience:
  37087. return m.Experience()
  37088. case workexperience.FieldOrganizationID:
  37089. return m.OrganizationID()
  37090. }
  37091. return nil, false
  37092. }
  37093. // OldField returns the old value of the field from the database. An error is
  37094. // returned if the mutation operation is not UpdateOne, or the query to the
  37095. // database failed.
  37096. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37097. switch name {
  37098. case workexperience.FieldCreatedAt:
  37099. return m.OldCreatedAt(ctx)
  37100. case workexperience.FieldUpdatedAt:
  37101. return m.OldUpdatedAt(ctx)
  37102. case workexperience.FieldDeletedAt:
  37103. return m.OldDeletedAt(ctx)
  37104. case workexperience.FieldEmployeeID:
  37105. return m.OldEmployeeID(ctx)
  37106. case workexperience.FieldStartDate:
  37107. return m.OldStartDate(ctx)
  37108. case workexperience.FieldEndDate:
  37109. return m.OldEndDate(ctx)
  37110. case workexperience.FieldCompany:
  37111. return m.OldCompany(ctx)
  37112. case workexperience.FieldExperience:
  37113. return m.OldExperience(ctx)
  37114. case workexperience.FieldOrganizationID:
  37115. return m.OldOrganizationID(ctx)
  37116. }
  37117. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  37118. }
  37119. // SetField sets the value of a field with the given name. It returns an error if
  37120. // the field is not defined in the schema, or if the type mismatched the field
  37121. // type.
  37122. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  37123. switch name {
  37124. case workexperience.FieldCreatedAt:
  37125. v, ok := value.(time.Time)
  37126. if !ok {
  37127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37128. }
  37129. m.SetCreatedAt(v)
  37130. return nil
  37131. case workexperience.FieldUpdatedAt:
  37132. v, ok := value.(time.Time)
  37133. if !ok {
  37134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37135. }
  37136. m.SetUpdatedAt(v)
  37137. return nil
  37138. case workexperience.FieldDeletedAt:
  37139. v, ok := value.(time.Time)
  37140. if !ok {
  37141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37142. }
  37143. m.SetDeletedAt(v)
  37144. return nil
  37145. case workexperience.FieldEmployeeID:
  37146. v, ok := value.(uint64)
  37147. if !ok {
  37148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37149. }
  37150. m.SetEmployeeID(v)
  37151. return nil
  37152. case workexperience.FieldStartDate:
  37153. v, ok := value.(time.Time)
  37154. if !ok {
  37155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37156. }
  37157. m.SetStartDate(v)
  37158. return nil
  37159. case workexperience.FieldEndDate:
  37160. v, ok := value.(time.Time)
  37161. if !ok {
  37162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37163. }
  37164. m.SetEndDate(v)
  37165. return nil
  37166. case workexperience.FieldCompany:
  37167. v, ok := value.(string)
  37168. if !ok {
  37169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37170. }
  37171. m.SetCompany(v)
  37172. return nil
  37173. case workexperience.FieldExperience:
  37174. v, ok := value.(string)
  37175. if !ok {
  37176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37177. }
  37178. m.SetExperience(v)
  37179. return nil
  37180. case workexperience.FieldOrganizationID:
  37181. v, ok := value.(uint64)
  37182. if !ok {
  37183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37184. }
  37185. m.SetOrganizationID(v)
  37186. return nil
  37187. }
  37188. return fmt.Errorf("unknown WorkExperience field %s", name)
  37189. }
  37190. // AddedFields returns all numeric fields that were incremented/decremented during
  37191. // this mutation.
  37192. func (m *WorkExperienceMutation) AddedFields() []string {
  37193. var fields []string
  37194. if m.addorganization_id != nil {
  37195. fields = append(fields, workexperience.FieldOrganizationID)
  37196. }
  37197. return fields
  37198. }
  37199. // AddedField returns the numeric value that was incremented/decremented on a field
  37200. // with the given name. The second boolean return value indicates that this field
  37201. // was not set, or was not defined in the schema.
  37202. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  37203. switch name {
  37204. case workexperience.FieldOrganizationID:
  37205. return m.AddedOrganizationID()
  37206. }
  37207. return nil, false
  37208. }
  37209. // AddField adds the value to the field with the given name. It returns an error if
  37210. // the field is not defined in the schema, or if the type mismatched the field
  37211. // type.
  37212. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  37213. switch name {
  37214. case workexperience.FieldOrganizationID:
  37215. v, ok := value.(int64)
  37216. if !ok {
  37217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37218. }
  37219. m.AddOrganizationID(v)
  37220. return nil
  37221. }
  37222. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  37223. }
  37224. // ClearedFields returns all nullable fields that were cleared during this
  37225. // mutation.
  37226. func (m *WorkExperienceMutation) ClearedFields() []string {
  37227. var fields []string
  37228. if m.FieldCleared(workexperience.FieldDeletedAt) {
  37229. fields = append(fields, workexperience.FieldDeletedAt)
  37230. }
  37231. return fields
  37232. }
  37233. // FieldCleared returns a boolean indicating if a field with the given name was
  37234. // cleared in this mutation.
  37235. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  37236. _, ok := m.clearedFields[name]
  37237. return ok
  37238. }
  37239. // ClearField clears the value of the field with the given name. It returns an
  37240. // error if the field is not defined in the schema.
  37241. func (m *WorkExperienceMutation) ClearField(name string) error {
  37242. switch name {
  37243. case workexperience.FieldDeletedAt:
  37244. m.ClearDeletedAt()
  37245. return nil
  37246. }
  37247. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  37248. }
  37249. // ResetField resets all changes in the mutation for the field with the given name.
  37250. // It returns an error if the field is not defined in the schema.
  37251. func (m *WorkExperienceMutation) ResetField(name string) error {
  37252. switch name {
  37253. case workexperience.FieldCreatedAt:
  37254. m.ResetCreatedAt()
  37255. return nil
  37256. case workexperience.FieldUpdatedAt:
  37257. m.ResetUpdatedAt()
  37258. return nil
  37259. case workexperience.FieldDeletedAt:
  37260. m.ResetDeletedAt()
  37261. return nil
  37262. case workexperience.FieldEmployeeID:
  37263. m.ResetEmployeeID()
  37264. return nil
  37265. case workexperience.FieldStartDate:
  37266. m.ResetStartDate()
  37267. return nil
  37268. case workexperience.FieldEndDate:
  37269. m.ResetEndDate()
  37270. return nil
  37271. case workexperience.FieldCompany:
  37272. m.ResetCompany()
  37273. return nil
  37274. case workexperience.FieldExperience:
  37275. m.ResetExperience()
  37276. return nil
  37277. case workexperience.FieldOrganizationID:
  37278. m.ResetOrganizationID()
  37279. return nil
  37280. }
  37281. return fmt.Errorf("unknown WorkExperience field %s", name)
  37282. }
  37283. // AddedEdges returns all edge names that were set/added in this mutation.
  37284. func (m *WorkExperienceMutation) AddedEdges() []string {
  37285. edges := make([]string, 0, 1)
  37286. if m.employee != nil {
  37287. edges = append(edges, workexperience.EdgeEmployee)
  37288. }
  37289. return edges
  37290. }
  37291. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37292. // name in this mutation.
  37293. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  37294. switch name {
  37295. case workexperience.EdgeEmployee:
  37296. if id := m.employee; id != nil {
  37297. return []ent.Value{*id}
  37298. }
  37299. }
  37300. return nil
  37301. }
  37302. // RemovedEdges returns all edge names that were removed in this mutation.
  37303. func (m *WorkExperienceMutation) RemovedEdges() []string {
  37304. edges := make([]string, 0, 1)
  37305. return edges
  37306. }
  37307. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37308. // the given name in this mutation.
  37309. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  37310. return nil
  37311. }
  37312. // ClearedEdges returns all edge names that were cleared in this mutation.
  37313. func (m *WorkExperienceMutation) ClearedEdges() []string {
  37314. edges := make([]string, 0, 1)
  37315. if m.clearedemployee {
  37316. edges = append(edges, workexperience.EdgeEmployee)
  37317. }
  37318. return edges
  37319. }
  37320. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37321. // was cleared in this mutation.
  37322. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  37323. switch name {
  37324. case workexperience.EdgeEmployee:
  37325. return m.clearedemployee
  37326. }
  37327. return false
  37328. }
  37329. // ClearEdge clears the value of the edge with the given name. It returns an error
  37330. // if that edge is not defined in the schema.
  37331. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  37332. switch name {
  37333. case workexperience.EdgeEmployee:
  37334. m.ClearEmployee()
  37335. return nil
  37336. }
  37337. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  37338. }
  37339. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37340. // It returns an error if the edge is not defined in the schema.
  37341. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  37342. switch name {
  37343. case workexperience.EdgeEmployee:
  37344. m.ResetEmployee()
  37345. return nil
  37346. }
  37347. return fmt.Errorf("unknown WorkExperience edge %s", name)
  37348. }
  37349. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  37350. type WpChatroomMutation struct {
  37351. config
  37352. op Op
  37353. typ string
  37354. id *uint64
  37355. created_at *time.Time
  37356. updated_at *time.Time
  37357. status *uint8
  37358. addstatus *int8
  37359. wx_wxid *string
  37360. chatroom_id *string
  37361. nickname *string
  37362. owner *string
  37363. avatar *string
  37364. member_list *[]string
  37365. appendmember_list []string
  37366. clearedFields map[string]struct{}
  37367. done bool
  37368. oldValue func(context.Context) (*WpChatroom, error)
  37369. predicates []predicate.WpChatroom
  37370. }
  37371. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  37372. // wpchatroomOption allows management of the mutation configuration using functional options.
  37373. type wpchatroomOption func(*WpChatroomMutation)
  37374. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  37375. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  37376. m := &WpChatroomMutation{
  37377. config: c,
  37378. op: op,
  37379. typ: TypeWpChatroom,
  37380. clearedFields: make(map[string]struct{}),
  37381. }
  37382. for _, opt := range opts {
  37383. opt(m)
  37384. }
  37385. return m
  37386. }
  37387. // withWpChatroomID sets the ID field of the mutation.
  37388. func withWpChatroomID(id uint64) wpchatroomOption {
  37389. return func(m *WpChatroomMutation) {
  37390. var (
  37391. err error
  37392. once sync.Once
  37393. value *WpChatroom
  37394. )
  37395. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  37396. once.Do(func() {
  37397. if m.done {
  37398. err = errors.New("querying old values post mutation is not allowed")
  37399. } else {
  37400. value, err = m.Client().WpChatroom.Get(ctx, id)
  37401. }
  37402. })
  37403. return value, err
  37404. }
  37405. m.id = &id
  37406. }
  37407. }
  37408. // withWpChatroom sets the old WpChatroom of the mutation.
  37409. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  37410. return func(m *WpChatroomMutation) {
  37411. m.oldValue = func(context.Context) (*WpChatroom, error) {
  37412. return node, nil
  37413. }
  37414. m.id = &node.ID
  37415. }
  37416. }
  37417. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37418. // executed in a transaction (ent.Tx), a transactional client is returned.
  37419. func (m WpChatroomMutation) Client() *Client {
  37420. client := &Client{config: m.config}
  37421. client.init()
  37422. return client
  37423. }
  37424. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37425. // it returns an error otherwise.
  37426. func (m WpChatroomMutation) Tx() (*Tx, error) {
  37427. if _, ok := m.driver.(*txDriver); !ok {
  37428. return nil, errors.New("ent: mutation is not running in a transaction")
  37429. }
  37430. tx := &Tx{config: m.config}
  37431. tx.init()
  37432. return tx, nil
  37433. }
  37434. // SetID sets the value of the id field. Note that this
  37435. // operation is only accepted on creation of WpChatroom entities.
  37436. func (m *WpChatroomMutation) SetID(id uint64) {
  37437. m.id = &id
  37438. }
  37439. // ID returns the ID value in the mutation. Note that the ID is only available
  37440. // if it was provided to the builder or after it was returned from the database.
  37441. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  37442. if m.id == nil {
  37443. return
  37444. }
  37445. return *m.id, true
  37446. }
  37447. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37448. // That means, if the mutation is applied within a transaction with an isolation level such
  37449. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37450. // or updated by the mutation.
  37451. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  37452. switch {
  37453. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37454. id, exists := m.ID()
  37455. if exists {
  37456. return []uint64{id}, nil
  37457. }
  37458. fallthrough
  37459. case m.op.Is(OpUpdate | OpDelete):
  37460. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  37461. default:
  37462. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37463. }
  37464. }
  37465. // SetCreatedAt sets the "created_at" field.
  37466. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  37467. m.created_at = &t
  37468. }
  37469. // CreatedAt returns the value of the "created_at" field in the mutation.
  37470. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  37471. v := m.created_at
  37472. if v == nil {
  37473. return
  37474. }
  37475. return *v, true
  37476. }
  37477. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  37478. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37480. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37481. if !m.op.Is(OpUpdateOne) {
  37482. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37483. }
  37484. if m.id == nil || m.oldValue == nil {
  37485. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37486. }
  37487. oldValue, err := m.oldValue(ctx)
  37488. if err != nil {
  37489. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37490. }
  37491. return oldValue.CreatedAt, nil
  37492. }
  37493. // ResetCreatedAt resets all changes to the "created_at" field.
  37494. func (m *WpChatroomMutation) ResetCreatedAt() {
  37495. m.created_at = nil
  37496. }
  37497. // SetUpdatedAt sets the "updated_at" field.
  37498. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  37499. m.updated_at = &t
  37500. }
  37501. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37502. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  37503. v := m.updated_at
  37504. if v == nil {
  37505. return
  37506. }
  37507. return *v, true
  37508. }
  37509. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  37510. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37512. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37513. if !m.op.Is(OpUpdateOne) {
  37514. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37515. }
  37516. if m.id == nil || m.oldValue == nil {
  37517. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37518. }
  37519. oldValue, err := m.oldValue(ctx)
  37520. if err != nil {
  37521. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37522. }
  37523. return oldValue.UpdatedAt, nil
  37524. }
  37525. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37526. func (m *WpChatroomMutation) ResetUpdatedAt() {
  37527. m.updated_at = nil
  37528. }
  37529. // SetStatus sets the "status" field.
  37530. func (m *WpChatroomMutation) SetStatus(u uint8) {
  37531. m.status = &u
  37532. m.addstatus = nil
  37533. }
  37534. // Status returns the value of the "status" field in the mutation.
  37535. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  37536. v := m.status
  37537. if v == nil {
  37538. return
  37539. }
  37540. return *v, true
  37541. }
  37542. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  37543. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37545. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37546. if !m.op.Is(OpUpdateOne) {
  37547. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37548. }
  37549. if m.id == nil || m.oldValue == nil {
  37550. return v, errors.New("OldStatus requires an ID field in the mutation")
  37551. }
  37552. oldValue, err := m.oldValue(ctx)
  37553. if err != nil {
  37554. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37555. }
  37556. return oldValue.Status, nil
  37557. }
  37558. // AddStatus adds u to the "status" field.
  37559. func (m *WpChatroomMutation) AddStatus(u int8) {
  37560. if m.addstatus != nil {
  37561. *m.addstatus += u
  37562. } else {
  37563. m.addstatus = &u
  37564. }
  37565. }
  37566. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37567. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  37568. v := m.addstatus
  37569. if v == nil {
  37570. return
  37571. }
  37572. return *v, true
  37573. }
  37574. // ClearStatus clears the value of the "status" field.
  37575. func (m *WpChatroomMutation) ClearStatus() {
  37576. m.status = nil
  37577. m.addstatus = nil
  37578. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  37579. }
  37580. // StatusCleared returns if the "status" field was cleared in this mutation.
  37581. func (m *WpChatroomMutation) StatusCleared() bool {
  37582. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  37583. return ok
  37584. }
  37585. // ResetStatus resets all changes to the "status" field.
  37586. func (m *WpChatroomMutation) ResetStatus() {
  37587. m.status = nil
  37588. m.addstatus = nil
  37589. delete(m.clearedFields, wpchatroom.FieldStatus)
  37590. }
  37591. // SetWxWxid sets the "wx_wxid" field.
  37592. func (m *WpChatroomMutation) SetWxWxid(s string) {
  37593. m.wx_wxid = &s
  37594. }
  37595. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  37596. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  37597. v := m.wx_wxid
  37598. if v == nil {
  37599. return
  37600. }
  37601. return *v, true
  37602. }
  37603. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  37604. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37606. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  37607. if !m.op.Is(OpUpdateOne) {
  37608. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  37609. }
  37610. if m.id == nil || m.oldValue == nil {
  37611. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  37612. }
  37613. oldValue, err := m.oldValue(ctx)
  37614. if err != nil {
  37615. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  37616. }
  37617. return oldValue.WxWxid, nil
  37618. }
  37619. // ResetWxWxid resets all changes to the "wx_wxid" field.
  37620. func (m *WpChatroomMutation) ResetWxWxid() {
  37621. m.wx_wxid = nil
  37622. }
  37623. // SetChatroomID sets the "chatroom_id" field.
  37624. func (m *WpChatroomMutation) SetChatroomID(s string) {
  37625. m.chatroom_id = &s
  37626. }
  37627. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  37628. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  37629. v := m.chatroom_id
  37630. if v == nil {
  37631. return
  37632. }
  37633. return *v, true
  37634. }
  37635. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  37636. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37638. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  37639. if !m.op.Is(OpUpdateOne) {
  37640. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  37641. }
  37642. if m.id == nil || m.oldValue == nil {
  37643. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  37644. }
  37645. oldValue, err := m.oldValue(ctx)
  37646. if err != nil {
  37647. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  37648. }
  37649. return oldValue.ChatroomID, nil
  37650. }
  37651. // ResetChatroomID resets all changes to the "chatroom_id" field.
  37652. func (m *WpChatroomMutation) ResetChatroomID() {
  37653. m.chatroom_id = nil
  37654. }
  37655. // SetNickname sets the "nickname" field.
  37656. func (m *WpChatroomMutation) SetNickname(s string) {
  37657. m.nickname = &s
  37658. }
  37659. // Nickname returns the value of the "nickname" field in the mutation.
  37660. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  37661. v := m.nickname
  37662. if v == nil {
  37663. return
  37664. }
  37665. return *v, true
  37666. }
  37667. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  37668. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37670. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  37671. if !m.op.Is(OpUpdateOne) {
  37672. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37673. }
  37674. if m.id == nil || m.oldValue == nil {
  37675. return v, errors.New("OldNickname requires an ID field in the mutation")
  37676. }
  37677. oldValue, err := m.oldValue(ctx)
  37678. if err != nil {
  37679. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37680. }
  37681. return oldValue.Nickname, nil
  37682. }
  37683. // ResetNickname resets all changes to the "nickname" field.
  37684. func (m *WpChatroomMutation) ResetNickname() {
  37685. m.nickname = nil
  37686. }
  37687. // SetOwner sets the "owner" field.
  37688. func (m *WpChatroomMutation) SetOwner(s string) {
  37689. m.owner = &s
  37690. }
  37691. // Owner returns the value of the "owner" field in the mutation.
  37692. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  37693. v := m.owner
  37694. if v == nil {
  37695. return
  37696. }
  37697. return *v, true
  37698. }
  37699. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  37700. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37702. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  37703. if !m.op.Is(OpUpdateOne) {
  37704. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  37705. }
  37706. if m.id == nil || m.oldValue == nil {
  37707. return v, errors.New("OldOwner requires an ID field in the mutation")
  37708. }
  37709. oldValue, err := m.oldValue(ctx)
  37710. if err != nil {
  37711. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  37712. }
  37713. return oldValue.Owner, nil
  37714. }
  37715. // ResetOwner resets all changes to the "owner" field.
  37716. func (m *WpChatroomMutation) ResetOwner() {
  37717. m.owner = nil
  37718. }
  37719. // SetAvatar sets the "avatar" field.
  37720. func (m *WpChatroomMutation) SetAvatar(s string) {
  37721. m.avatar = &s
  37722. }
  37723. // Avatar returns the value of the "avatar" field in the mutation.
  37724. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  37725. v := m.avatar
  37726. if v == nil {
  37727. return
  37728. }
  37729. return *v, true
  37730. }
  37731. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  37732. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37734. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37735. if !m.op.Is(OpUpdateOne) {
  37736. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37737. }
  37738. if m.id == nil || m.oldValue == nil {
  37739. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37740. }
  37741. oldValue, err := m.oldValue(ctx)
  37742. if err != nil {
  37743. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37744. }
  37745. return oldValue.Avatar, nil
  37746. }
  37747. // ResetAvatar resets all changes to the "avatar" field.
  37748. func (m *WpChatroomMutation) ResetAvatar() {
  37749. m.avatar = nil
  37750. }
  37751. // SetMemberList sets the "member_list" field.
  37752. func (m *WpChatroomMutation) SetMemberList(s []string) {
  37753. m.member_list = &s
  37754. m.appendmember_list = nil
  37755. }
  37756. // MemberList returns the value of the "member_list" field in the mutation.
  37757. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  37758. v := m.member_list
  37759. if v == nil {
  37760. return
  37761. }
  37762. return *v, true
  37763. }
  37764. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  37765. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37767. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  37768. if !m.op.Is(OpUpdateOne) {
  37769. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  37770. }
  37771. if m.id == nil || m.oldValue == nil {
  37772. return v, errors.New("OldMemberList requires an ID field in the mutation")
  37773. }
  37774. oldValue, err := m.oldValue(ctx)
  37775. if err != nil {
  37776. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  37777. }
  37778. return oldValue.MemberList, nil
  37779. }
  37780. // AppendMemberList adds s to the "member_list" field.
  37781. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  37782. m.appendmember_list = append(m.appendmember_list, s...)
  37783. }
  37784. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  37785. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  37786. if len(m.appendmember_list) == 0 {
  37787. return nil, false
  37788. }
  37789. return m.appendmember_list, true
  37790. }
  37791. // ResetMemberList resets all changes to the "member_list" field.
  37792. func (m *WpChatroomMutation) ResetMemberList() {
  37793. m.member_list = nil
  37794. m.appendmember_list = nil
  37795. }
  37796. // Where appends a list predicates to the WpChatroomMutation builder.
  37797. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  37798. m.predicates = append(m.predicates, ps...)
  37799. }
  37800. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  37801. // users can use type-assertion to append predicates that do not depend on any generated package.
  37802. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  37803. p := make([]predicate.WpChatroom, len(ps))
  37804. for i := range ps {
  37805. p[i] = ps[i]
  37806. }
  37807. m.Where(p...)
  37808. }
  37809. // Op returns the operation name.
  37810. func (m *WpChatroomMutation) Op() Op {
  37811. return m.op
  37812. }
  37813. // SetOp allows setting the mutation operation.
  37814. func (m *WpChatroomMutation) SetOp(op Op) {
  37815. m.op = op
  37816. }
  37817. // Type returns the node type of this mutation (WpChatroom).
  37818. func (m *WpChatroomMutation) Type() string {
  37819. return m.typ
  37820. }
  37821. // Fields returns all fields that were changed during this mutation. Note that in
  37822. // order to get all numeric fields that were incremented/decremented, call
  37823. // AddedFields().
  37824. func (m *WpChatroomMutation) Fields() []string {
  37825. fields := make([]string, 0, 9)
  37826. if m.created_at != nil {
  37827. fields = append(fields, wpchatroom.FieldCreatedAt)
  37828. }
  37829. if m.updated_at != nil {
  37830. fields = append(fields, wpchatroom.FieldUpdatedAt)
  37831. }
  37832. if m.status != nil {
  37833. fields = append(fields, wpchatroom.FieldStatus)
  37834. }
  37835. if m.wx_wxid != nil {
  37836. fields = append(fields, wpchatroom.FieldWxWxid)
  37837. }
  37838. if m.chatroom_id != nil {
  37839. fields = append(fields, wpchatroom.FieldChatroomID)
  37840. }
  37841. if m.nickname != nil {
  37842. fields = append(fields, wpchatroom.FieldNickname)
  37843. }
  37844. if m.owner != nil {
  37845. fields = append(fields, wpchatroom.FieldOwner)
  37846. }
  37847. if m.avatar != nil {
  37848. fields = append(fields, wpchatroom.FieldAvatar)
  37849. }
  37850. if m.member_list != nil {
  37851. fields = append(fields, wpchatroom.FieldMemberList)
  37852. }
  37853. return fields
  37854. }
  37855. // Field returns the value of a field with the given name. The second boolean
  37856. // return value indicates that this field was not set, or was not defined in the
  37857. // schema.
  37858. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  37859. switch name {
  37860. case wpchatroom.FieldCreatedAt:
  37861. return m.CreatedAt()
  37862. case wpchatroom.FieldUpdatedAt:
  37863. return m.UpdatedAt()
  37864. case wpchatroom.FieldStatus:
  37865. return m.Status()
  37866. case wpchatroom.FieldWxWxid:
  37867. return m.WxWxid()
  37868. case wpchatroom.FieldChatroomID:
  37869. return m.ChatroomID()
  37870. case wpchatroom.FieldNickname:
  37871. return m.Nickname()
  37872. case wpchatroom.FieldOwner:
  37873. return m.Owner()
  37874. case wpchatroom.FieldAvatar:
  37875. return m.Avatar()
  37876. case wpchatroom.FieldMemberList:
  37877. return m.MemberList()
  37878. }
  37879. return nil, false
  37880. }
  37881. // OldField returns the old value of the field from the database. An error is
  37882. // returned if the mutation operation is not UpdateOne, or the query to the
  37883. // database failed.
  37884. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37885. switch name {
  37886. case wpchatroom.FieldCreatedAt:
  37887. return m.OldCreatedAt(ctx)
  37888. case wpchatroom.FieldUpdatedAt:
  37889. return m.OldUpdatedAt(ctx)
  37890. case wpchatroom.FieldStatus:
  37891. return m.OldStatus(ctx)
  37892. case wpchatroom.FieldWxWxid:
  37893. return m.OldWxWxid(ctx)
  37894. case wpchatroom.FieldChatroomID:
  37895. return m.OldChatroomID(ctx)
  37896. case wpchatroom.FieldNickname:
  37897. return m.OldNickname(ctx)
  37898. case wpchatroom.FieldOwner:
  37899. return m.OldOwner(ctx)
  37900. case wpchatroom.FieldAvatar:
  37901. return m.OldAvatar(ctx)
  37902. case wpchatroom.FieldMemberList:
  37903. return m.OldMemberList(ctx)
  37904. }
  37905. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  37906. }
  37907. // SetField sets the value of a field with the given name. It returns an error if
  37908. // the field is not defined in the schema, or if the type mismatched the field
  37909. // type.
  37910. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  37911. switch name {
  37912. case wpchatroom.FieldCreatedAt:
  37913. v, ok := value.(time.Time)
  37914. if !ok {
  37915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37916. }
  37917. m.SetCreatedAt(v)
  37918. return nil
  37919. case wpchatroom.FieldUpdatedAt:
  37920. v, ok := value.(time.Time)
  37921. if !ok {
  37922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37923. }
  37924. m.SetUpdatedAt(v)
  37925. return nil
  37926. case wpchatroom.FieldStatus:
  37927. v, ok := value.(uint8)
  37928. if !ok {
  37929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37930. }
  37931. m.SetStatus(v)
  37932. return nil
  37933. case wpchatroom.FieldWxWxid:
  37934. v, ok := value.(string)
  37935. if !ok {
  37936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37937. }
  37938. m.SetWxWxid(v)
  37939. return nil
  37940. case wpchatroom.FieldChatroomID:
  37941. v, ok := value.(string)
  37942. if !ok {
  37943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37944. }
  37945. m.SetChatroomID(v)
  37946. return nil
  37947. case wpchatroom.FieldNickname:
  37948. v, ok := value.(string)
  37949. if !ok {
  37950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37951. }
  37952. m.SetNickname(v)
  37953. return nil
  37954. case wpchatroom.FieldOwner:
  37955. v, ok := value.(string)
  37956. if !ok {
  37957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37958. }
  37959. m.SetOwner(v)
  37960. return nil
  37961. case wpchatroom.FieldAvatar:
  37962. v, ok := value.(string)
  37963. if !ok {
  37964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37965. }
  37966. m.SetAvatar(v)
  37967. return nil
  37968. case wpchatroom.FieldMemberList:
  37969. v, ok := value.([]string)
  37970. if !ok {
  37971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37972. }
  37973. m.SetMemberList(v)
  37974. return nil
  37975. }
  37976. return fmt.Errorf("unknown WpChatroom field %s", name)
  37977. }
  37978. // AddedFields returns all numeric fields that were incremented/decremented during
  37979. // this mutation.
  37980. func (m *WpChatroomMutation) AddedFields() []string {
  37981. var fields []string
  37982. if m.addstatus != nil {
  37983. fields = append(fields, wpchatroom.FieldStatus)
  37984. }
  37985. return fields
  37986. }
  37987. // AddedField returns the numeric value that was incremented/decremented on a field
  37988. // with the given name. The second boolean return value indicates that this field
  37989. // was not set, or was not defined in the schema.
  37990. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  37991. switch name {
  37992. case wpchatroom.FieldStatus:
  37993. return m.AddedStatus()
  37994. }
  37995. return nil, false
  37996. }
  37997. // AddField adds the value to the field with the given name. It returns an error if
  37998. // the field is not defined in the schema, or if the type mismatched the field
  37999. // type.
  38000. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  38001. switch name {
  38002. case wpchatroom.FieldStatus:
  38003. v, ok := value.(int8)
  38004. if !ok {
  38005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38006. }
  38007. m.AddStatus(v)
  38008. return nil
  38009. }
  38010. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  38011. }
  38012. // ClearedFields returns all nullable fields that were cleared during this
  38013. // mutation.
  38014. func (m *WpChatroomMutation) ClearedFields() []string {
  38015. var fields []string
  38016. if m.FieldCleared(wpchatroom.FieldStatus) {
  38017. fields = append(fields, wpchatroom.FieldStatus)
  38018. }
  38019. return fields
  38020. }
  38021. // FieldCleared returns a boolean indicating if a field with the given name was
  38022. // cleared in this mutation.
  38023. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  38024. _, ok := m.clearedFields[name]
  38025. return ok
  38026. }
  38027. // ClearField clears the value of the field with the given name. It returns an
  38028. // error if the field is not defined in the schema.
  38029. func (m *WpChatroomMutation) ClearField(name string) error {
  38030. switch name {
  38031. case wpchatroom.FieldStatus:
  38032. m.ClearStatus()
  38033. return nil
  38034. }
  38035. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  38036. }
  38037. // ResetField resets all changes in the mutation for the field with the given name.
  38038. // It returns an error if the field is not defined in the schema.
  38039. func (m *WpChatroomMutation) ResetField(name string) error {
  38040. switch name {
  38041. case wpchatroom.FieldCreatedAt:
  38042. m.ResetCreatedAt()
  38043. return nil
  38044. case wpchatroom.FieldUpdatedAt:
  38045. m.ResetUpdatedAt()
  38046. return nil
  38047. case wpchatroom.FieldStatus:
  38048. m.ResetStatus()
  38049. return nil
  38050. case wpchatroom.FieldWxWxid:
  38051. m.ResetWxWxid()
  38052. return nil
  38053. case wpchatroom.FieldChatroomID:
  38054. m.ResetChatroomID()
  38055. return nil
  38056. case wpchatroom.FieldNickname:
  38057. m.ResetNickname()
  38058. return nil
  38059. case wpchatroom.FieldOwner:
  38060. m.ResetOwner()
  38061. return nil
  38062. case wpchatroom.FieldAvatar:
  38063. m.ResetAvatar()
  38064. return nil
  38065. case wpchatroom.FieldMemberList:
  38066. m.ResetMemberList()
  38067. return nil
  38068. }
  38069. return fmt.Errorf("unknown WpChatroom field %s", name)
  38070. }
  38071. // AddedEdges returns all edge names that were set/added in this mutation.
  38072. func (m *WpChatroomMutation) AddedEdges() []string {
  38073. edges := make([]string, 0, 0)
  38074. return edges
  38075. }
  38076. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38077. // name in this mutation.
  38078. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  38079. return nil
  38080. }
  38081. // RemovedEdges returns all edge names that were removed in this mutation.
  38082. func (m *WpChatroomMutation) RemovedEdges() []string {
  38083. edges := make([]string, 0, 0)
  38084. return edges
  38085. }
  38086. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38087. // the given name in this mutation.
  38088. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  38089. return nil
  38090. }
  38091. // ClearedEdges returns all edge names that were cleared in this mutation.
  38092. func (m *WpChatroomMutation) ClearedEdges() []string {
  38093. edges := make([]string, 0, 0)
  38094. return edges
  38095. }
  38096. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38097. // was cleared in this mutation.
  38098. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  38099. return false
  38100. }
  38101. // ClearEdge clears the value of the edge with the given name. It returns an error
  38102. // if that edge is not defined in the schema.
  38103. func (m *WpChatroomMutation) ClearEdge(name string) error {
  38104. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  38105. }
  38106. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38107. // It returns an error if the edge is not defined in the schema.
  38108. func (m *WpChatroomMutation) ResetEdge(name string) error {
  38109. return fmt.Errorf("unknown WpChatroom edge %s", name)
  38110. }
  38111. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  38112. type WpChatroomMemberMutation struct {
  38113. config
  38114. op Op
  38115. typ string
  38116. id *uint64
  38117. created_at *time.Time
  38118. updated_at *time.Time
  38119. status *uint8
  38120. addstatus *int8
  38121. wx_wxid *string
  38122. wxid *string
  38123. nickname *string
  38124. avatar *string
  38125. clearedFields map[string]struct{}
  38126. done bool
  38127. oldValue func(context.Context) (*WpChatroomMember, error)
  38128. predicates []predicate.WpChatroomMember
  38129. }
  38130. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  38131. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  38132. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  38133. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  38134. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  38135. m := &WpChatroomMemberMutation{
  38136. config: c,
  38137. op: op,
  38138. typ: TypeWpChatroomMember,
  38139. clearedFields: make(map[string]struct{}),
  38140. }
  38141. for _, opt := range opts {
  38142. opt(m)
  38143. }
  38144. return m
  38145. }
  38146. // withWpChatroomMemberID sets the ID field of the mutation.
  38147. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  38148. return func(m *WpChatroomMemberMutation) {
  38149. var (
  38150. err error
  38151. once sync.Once
  38152. value *WpChatroomMember
  38153. )
  38154. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  38155. once.Do(func() {
  38156. if m.done {
  38157. err = errors.New("querying old values post mutation is not allowed")
  38158. } else {
  38159. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  38160. }
  38161. })
  38162. return value, err
  38163. }
  38164. m.id = &id
  38165. }
  38166. }
  38167. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  38168. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  38169. return func(m *WpChatroomMemberMutation) {
  38170. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  38171. return node, nil
  38172. }
  38173. m.id = &node.ID
  38174. }
  38175. }
  38176. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38177. // executed in a transaction (ent.Tx), a transactional client is returned.
  38178. func (m WpChatroomMemberMutation) Client() *Client {
  38179. client := &Client{config: m.config}
  38180. client.init()
  38181. return client
  38182. }
  38183. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38184. // it returns an error otherwise.
  38185. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  38186. if _, ok := m.driver.(*txDriver); !ok {
  38187. return nil, errors.New("ent: mutation is not running in a transaction")
  38188. }
  38189. tx := &Tx{config: m.config}
  38190. tx.init()
  38191. return tx, nil
  38192. }
  38193. // SetID sets the value of the id field. Note that this
  38194. // operation is only accepted on creation of WpChatroomMember entities.
  38195. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  38196. m.id = &id
  38197. }
  38198. // ID returns the ID value in the mutation. Note that the ID is only available
  38199. // if it was provided to the builder or after it was returned from the database.
  38200. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  38201. if m.id == nil {
  38202. return
  38203. }
  38204. return *m.id, true
  38205. }
  38206. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38207. // That means, if the mutation is applied within a transaction with an isolation level such
  38208. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38209. // or updated by the mutation.
  38210. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  38211. switch {
  38212. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38213. id, exists := m.ID()
  38214. if exists {
  38215. return []uint64{id}, nil
  38216. }
  38217. fallthrough
  38218. case m.op.Is(OpUpdate | OpDelete):
  38219. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  38220. default:
  38221. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38222. }
  38223. }
  38224. // SetCreatedAt sets the "created_at" field.
  38225. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  38226. m.created_at = &t
  38227. }
  38228. // CreatedAt returns the value of the "created_at" field in the mutation.
  38229. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  38230. v := m.created_at
  38231. if v == nil {
  38232. return
  38233. }
  38234. return *v, true
  38235. }
  38236. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  38237. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38239. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38240. if !m.op.Is(OpUpdateOne) {
  38241. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38242. }
  38243. if m.id == nil || m.oldValue == nil {
  38244. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38245. }
  38246. oldValue, err := m.oldValue(ctx)
  38247. if err != nil {
  38248. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38249. }
  38250. return oldValue.CreatedAt, nil
  38251. }
  38252. // ResetCreatedAt resets all changes to the "created_at" field.
  38253. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  38254. m.created_at = nil
  38255. }
  38256. // SetUpdatedAt sets the "updated_at" field.
  38257. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  38258. m.updated_at = &t
  38259. }
  38260. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38261. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  38262. v := m.updated_at
  38263. if v == nil {
  38264. return
  38265. }
  38266. return *v, true
  38267. }
  38268. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  38269. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38271. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38272. if !m.op.Is(OpUpdateOne) {
  38273. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38274. }
  38275. if m.id == nil || m.oldValue == nil {
  38276. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38277. }
  38278. oldValue, err := m.oldValue(ctx)
  38279. if err != nil {
  38280. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38281. }
  38282. return oldValue.UpdatedAt, nil
  38283. }
  38284. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38285. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  38286. m.updated_at = nil
  38287. }
  38288. // SetStatus sets the "status" field.
  38289. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  38290. m.status = &u
  38291. m.addstatus = nil
  38292. }
  38293. // Status returns the value of the "status" field in the mutation.
  38294. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  38295. v := m.status
  38296. if v == nil {
  38297. return
  38298. }
  38299. return *v, true
  38300. }
  38301. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  38302. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38304. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38305. if !m.op.Is(OpUpdateOne) {
  38306. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38307. }
  38308. if m.id == nil || m.oldValue == nil {
  38309. return v, errors.New("OldStatus requires an ID field in the mutation")
  38310. }
  38311. oldValue, err := m.oldValue(ctx)
  38312. if err != nil {
  38313. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38314. }
  38315. return oldValue.Status, nil
  38316. }
  38317. // AddStatus adds u to the "status" field.
  38318. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  38319. if m.addstatus != nil {
  38320. *m.addstatus += u
  38321. } else {
  38322. m.addstatus = &u
  38323. }
  38324. }
  38325. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38326. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  38327. v := m.addstatus
  38328. if v == nil {
  38329. return
  38330. }
  38331. return *v, true
  38332. }
  38333. // ClearStatus clears the value of the "status" field.
  38334. func (m *WpChatroomMemberMutation) ClearStatus() {
  38335. m.status = nil
  38336. m.addstatus = nil
  38337. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  38338. }
  38339. // StatusCleared returns if the "status" field was cleared in this mutation.
  38340. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  38341. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  38342. return ok
  38343. }
  38344. // ResetStatus resets all changes to the "status" field.
  38345. func (m *WpChatroomMemberMutation) ResetStatus() {
  38346. m.status = nil
  38347. m.addstatus = nil
  38348. delete(m.clearedFields, wpchatroommember.FieldStatus)
  38349. }
  38350. // SetWxWxid sets the "wx_wxid" field.
  38351. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  38352. m.wx_wxid = &s
  38353. }
  38354. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38355. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  38356. v := m.wx_wxid
  38357. if v == nil {
  38358. return
  38359. }
  38360. return *v, true
  38361. }
  38362. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  38363. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38365. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38366. if !m.op.Is(OpUpdateOne) {
  38367. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38368. }
  38369. if m.id == nil || m.oldValue == nil {
  38370. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38371. }
  38372. oldValue, err := m.oldValue(ctx)
  38373. if err != nil {
  38374. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38375. }
  38376. return oldValue.WxWxid, nil
  38377. }
  38378. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38379. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  38380. m.wx_wxid = nil
  38381. }
  38382. // SetWxid sets the "wxid" field.
  38383. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  38384. m.wxid = &s
  38385. }
  38386. // Wxid returns the value of the "wxid" field in the mutation.
  38387. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  38388. v := m.wxid
  38389. if v == nil {
  38390. return
  38391. }
  38392. return *v, true
  38393. }
  38394. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  38395. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38397. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  38398. if !m.op.Is(OpUpdateOne) {
  38399. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  38400. }
  38401. if m.id == nil || m.oldValue == nil {
  38402. return v, errors.New("OldWxid requires an ID field in the mutation")
  38403. }
  38404. oldValue, err := m.oldValue(ctx)
  38405. if err != nil {
  38406. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  38407. }
  38408. return oldValue.Wxid, nil
  38409. }
  38410. // ResetWxid resets all changes to the "wxid" field.
  38411. func (m *WpChatroomMemberMutation) ResetWxid() {
  38412. m.wxid = nil
  38413. }
  38414. // SetNickname sets the "nickname" field.
  38415. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  38416. m.nickname = &s
  38417. }
  38418. // Nickname returns the value of the "nickname" field in the mutation.
  38419. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  38420. v := m.nickname
  38421. if v == nil {
  38422. return
  38423. }
  38424. return *v, true
  38425. }
  38426. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  38427. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38429. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  38430. if !m.op.Is(OpUpdateOne) {
  38431. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38432. }
  38433. if m.id == nil || m.oldValue == nil {
  38434. return v, errors.New("OldNickname requires an ID field in the mutation")
  38435. }
  38436. oldValue, err := m.oldValue(ctx)
  38437. if err != nil {
  38438. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38439. }
  38440. return oldValue.Nickname, nil
  38441. }
  38442. // ResetNickname resets all changes to the "nickname" field.
  38443. func (m *WpChatroomMemberMutation) ResetNickname() {
  38444. m.nickname = nil
  38445. }
  38446. // SetAvatar sets the "avatar" field.
  38447. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  38448. m.avatar = &s
  38449. }
  38450. // Avatar returns the value of the "avatar" field in the mutation.
  38451. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  38452. v := m.avatar
  38453. if v == nil {
  38454. return
  38455. }
  38456. return *v, true
  38457. }
  38458. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  38459. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38461. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38462. if !m.op.Is(OpUpdateOne) {
  38463. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38464. }
  38465. if m.id == nil || m.oldValue == nil {
  38466. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38467. }
  38468. oldValue, err := m.oldValue(ctx)
  38469. if err != nil {
  38470. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38471. }
  38472. return oldValue.Avatar, nil
  38473. }
  38474. // ResetAvatar resets all changes to the "avatar" field.
  38475. func (m *WpChatroomMemberMutation) ResetAvatar() {
  38476. m.avatar = nil
  38477. }
  38478. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  38479. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  38480. m.predicates = append(m.predicates, ps...)
  38481. }
  38482. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  38483. // users can use type-assertion to append predicates that do not depend on any generated package.
  38484. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  38485. p := make([]predicate.WpChatroomMember, len(ps))
  38486. for i := range ps {
  38487. p[i] = ps[i]
  38488. }
  38489. m.Where(p...)
  38490. }
  38491. // Op returns the operation name.
  38492. func (m *WpChatroomMemberMutation) Op() Op {
  38493. return m.op
  38494. }
  38495. // SetOp allows setting the mutation operation.
  38496. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  38497. m.op = op
  38498. }
  38499. // Type returns the node type of this mutation (WpChatroomMember).
  38500. func (m *WpChatroomMemberMutation) Type() string {
  38501. return m.typ
  38502. }
  38503. // Fields returns all fields that were changed during this mutation. Note that in
  38504. // order to get all numeric fields that were incremented/decremented, call
  38505. // AddedFields().
  38506. func (m *WpChatroomMemberMutation) Fields() []string {
  38507. fields := make([]string, 0, 7)
  38508. if m.created_at != nil {
  38509. fields = append(fields, wpchatroommember.FieldCreatedAt)
  38510. }
  38511. if m.updated_at != nil {
  38512. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  38513. }
  38514. if m.status != nil {
  38515. fields = append(fields, wpchatroommember.FieldStatus)
  38516. }
  38517. if m.wx_wxid != nil {
  38518. fields = append(fields, wpchatroommember.FieldWxWxid)
  38519. }
  38520. if m.wxid != nil {
  38521. fields = append(fields, wpchatroommember.FieldWxid)
  38522. }
  38523. if m.nickname != nil {
  38524. fields = append(fields, wpchatroommember.FieldNickname)
  38525. }
  38526. if m.avatar != nil {
  38527. fields = append(fields, wpchatroommember.FieldAvatar)
  38528. }
  38529. return fields
  38530. }
  38531. // Field returns the value of a field with the given name. The second boolean
  38532. // return value indicates that this field was not set, or was not defined in the
  38533. // schema.
  38534. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  38535. switch name {
  38536. case wpchatroommember.FieldCreatedAt:
  38537. return m.CreatedAt()
  38538. case wpchatroommember.FieldUpdatedAt:
  38539. return m.UpdatedAt()
  38540. case wpchatroommember.FieldStatus:
  38541. return m.Status()
  38542. case wpchatroommember.FieldWxWxid:
  38543. return m.WxWxid()
  38544. case wpchatroommember.FieldWxid:
  38545. return m.Wxid()
  38546. case wpchatroommember.FieldNickname:
  38547. return m.Nickname()
  38548. case wpchatroommember.FieldAvatar:
  38549. return m.Avatar()
  38550. }
  38551. return nil, false
  38552. }
  38553. // OldField returns the old value of the field from the database. An error is
  38554. // returned if the mutation operation is not UpdateOne, or the query to the
  38555. // database failed.
  38556. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38557. switch name {
  38558. case wpchatroommember.FieldCreatedAt:
  38559. return m.OldCreatedAt(ctx)
  38560. case wpchatroommember.FieldUpdatedAt:
  38561. return m.OldUpdatedAt(ctx)
  38562. case wpchatroommember.FieldStatus:
  38563. return m.OldStatus(ctx)
  38564. case wpchatroommember.FieldWxWxid:
  38565. return m.OldWxWxid(ctx)
  38566. case wpchatroommember.FieldWxid:
  38567. return m.OldWxid(ctx)
  38568. case wpchatroommember.FieldNickname:
  38569. return m.OldNickname(ctx)
  38570. case wpchatroommember.FieldAvatar:
  38571. return m.OldAvatar(ctx)
  38572. }
  38573. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  38574. }
  38575. // SetField sets the value of a field with the given name. It returns an error if
  38576. // the field is not defined in the schema, or if the type mismatched the field
  38577. // type.
  38578. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  38579. switch name {
  38580. case wpchatroommember.FieldCreatedAt:
  38581. v, ok := value.(time.Time)
  38582. if !ok {
  38583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38584. }
  38585. m.SetCreatedAt(v)
  38586. return nil
  38587. case wpchatroommember.FieldUpdatedAt:
  38588. v, ok := value.(time.Time)
  38589. if !ok {
  38590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38591. }
  38592. m.SetUpdatedAt(v)
  38593. return nil
  38594. case wpchatroommember.FieldStatus:
  38595. v, ok := value.(uint8)
  38596. if !ok {
  38597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38598. }
  38599. m.SetStatus(v)
  38600. return nil
  38601. case wpchatroommember.FieldWxWxid:
  38602. v, ok := value.(string)
  38603. if !ok {
  38604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38605. }
  38606. m.SetWxWxid(v)
  38607. return nil
  38608. case wpchatroommember.FieldWxid:
  38609. v, ok := value.(string)
  38610. if !ok {
  38611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38612. }
  38613. m.SetWxid(v)
  38614. return nil
  38615. case wpchatroommember.FieldNickname:
  38616. v, ok := value.(string)
  38617. if !ok {
  38618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38619. }
  38620. m.SetNickname(v)
  38621. return nil
  38622. case wpchatroommember.FieldAvatar:
  38623. v, ok := value.(string)
  38624. if !ok {
  38625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38626. }
  38627. m.SetAvatar(v)
  38628. return nil
  38629. }
  38630. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38631. }
  38632. // AddedFields returns all numeric fields that were incremented/decremented during
  38633. // this mutation.
  38634. func (m *WpChatroomMemberMutation) AddedFields() []string {
  38635. var fields []string
  38636. if m.addstatus != nil {
  38637. fields = append(fields, wpchatroommember.FieldStatus)
  38638. }
  38639. return fields
  38640. }
  38641. // AddedField returns the numeric value that was incremented/decremented on a field
  38642. // with the given name. The second boolean return value indicates that this field
  38643. // was not set, or was not defined in the schema.
  38644. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  38645. switch name {
  38646. case wpchatroommember.FieldStatus:
  38647. return m.AddedStatus()
  38648. }
  38649. return nil, false
  38650. }
  38651. // AddField adds the value to the field with the given name. It returns an error if
  38652. // the field is not defined in the schema, or if the type mismatched the field
  38653. // type.
  38654. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  38655. switch name {
  38656. case wpchatroommember.FieldStatus:
  38657. v, ok := value.(int8)
  38658. if !ok {
  38659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38660. }
  38661. m.AddStatus(v)
  38662. return nil
  38663. }
  38664. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  38665. }
  38666. // ClearedFields returns all nullable fields that were cleared during this
  38667. // mutation.
  38668. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  38669. var fields []string
  38670. if m.FieldCleared(wpchatroommember.FieldStatus) {
  38671. fields = append(fields, wpchatroommember.FieldStatus)
  38672. }
  38673. return fields
  38674. }
  38675. // FieldCleared returns a boolean indicating if a field with the given name was
  38676. // cleared in this mutation.
  38677. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  38678. _, ok := m.clearedFields[name]
  38679. return ok
  38680. }
  38681. // ClearField clears the value of the field with the given name. It returns an
  38682. // error if the field is not defined in the schema.
  38683. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  38684. switch name {
  38685. case wpchatroommember.FieldStatus:
  38686. m.ClearStatus()
  38687. return nil
  38688. }
  38689. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  38690. }
  38691. // ResetField resets all changes in the mutation for the field with the given name.
  38692. // It returns an error if the field is not defined in the schema.
  38693. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  38694. switch name {
  38695. case wpchatroommember.FieldCreatedAt:
  38696. m.ResetCreatedAt()
  38697. return nil
  38698. case wpchatroommember.FieldUpdatedAt:
  38699. m.ResetUpdatedAt()
  38700. return nil
  38701. case wpchatroommember.FieldStatus:
  38702. m.ResetStatus()
  38703. return nil
  38704. case wpchatroommember.FieldWxWxid:
  38705. m.ResetWxWxid()
  38706. return nil
  38707. case wpchatroommember.FieldWxid:
  38708. m.ResetWxid()
  38709. return nil
  38710. case wpchatroommember.FieldNickname:
  38711. m.ResetNickname()
  38712. return nil
  38713. case wpchatroommember.FieldAvatar:
  38714. m.ResetAvatar()
  38715. return nil
  38716. }
  38717. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38718. }
  38719. // AddedEdges returns all edge names that were set/added in this mutation.
  38720. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  38721. edges := make([]string, 0, 0)
  38722. return edges
  38723. }
  38724. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38725. // name in this mutation.
  38726. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  38727. return nil
  38728. }
  38729. // RemovedEdges returns all edge names that were removed in this mutation.
  38730. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  38731. edges := make([]string, 0, 0)
  38732. return edges
  38733. }
  38734. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38735. // the given name in this mutation.
  38736. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  38737. return nil
  38738. }
  38739. // ClearedEdges returns all edge names that were cleared in this mutation.
  38740. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  38741. edges := make([]string, 0, 0)
  38742. return edges
  38743. }
  38744. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38745. // was cleared in this mutation.
  38746. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  38747. return false
  38748. }
  38749. // ClearEdge clears the value of the edge with the given name. It returns an error
  38750. // if that edge is not defined in the schema.
  38751. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  38752. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  38753. }
  38754. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38755. // It returns an error if the edge is not defined in the schema.
  38756. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  38757. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  38758. }
  38759. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  38760. type WxMutation struct {
  38761. config
  38762. op Op
  38763. typ string
  38764. id *uint64
  38765. created_at *time.Time
  38766. updated_at *time.Time
  38767. status *uint8
  38768. addstatus *int8
  38769. deleted_at *time.Time
  38770. port *string
  38771. process_id *string
  38772. callback *string
  38773. wxid *string
  38774. account *string
  38775. nickname *string
  38776. tel *string
  38777. head_big *string
  38778. organization_id *uint64
  38779. addorganization_id *int64
  38780. api_base *string
  38781. api_key *string
  38782. allow_list *[]string
  38783. appendallow_list []string
  38784. group_allow_list *[]string
  38785. appendgroup_allow_list []string
  38786. block_list *[]string
  38787. appendblock_list []string
  38788. group_block_list *[]string
  38789. appendgroup_block_list []string
  38790. clearedFields map[string]struct{}
  38791. server *uint64
  38792. clearedserver bool
  38793. agent *uint64
  38794. clearedagent bool
  38795. done bool
  38796. oldValue func(context.Context) (*Wx, error)
  38797. predicates []predicate.Wx
  38798. }
  38799. var _ ent.Mutation = (*WxMutation)(nil)
  38800. // wxOption allows management of the mutation configuration using functional options.
  38801. type wxOption func(*WxMutation)
  38802. // newWxMutation creates new mutation for the Wx entity.
  38803. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  38804. m := &WxMutation{
  38805. config: c,
  38806. op: op,
  38807. typ: TypeWx,
  38808. clearedFields: make(map[string]struct{}),
  38809. }
  38810. for _, opt := range opts {
  38811. opt(m)
  38812. }
  38813. return m
  38814. }
  38815. // withWxID sets the ID field of the mutation.
  38816. func withWxID(id uint64) wxOption {
  38817. return func(m *WxMutation) {
  38818. var (
  38819. err error
  38820. once sync.Once
  38821. value *Wx
  38822. )
  38823. m.oldValue = func(ctx context.Context) (*Wx, error) {
  38824. once.Do(func() {
  38825. if m.done {
  38826. err = errors.New("querying old values post mutation is not allowed")
  38827. } else {
  38828. value, err = m.Client().Wx.Get(ctx, id)
  38829. }
  38830. })
  38831. return value, err
  38832. }
  38833. m.id = &id
  38834. }
  38835. }
  38836. // withWx sets the old Wx of the mutation.
  38837. func withWx(node *Wx) wxOption {
  38838. return func(m *WxMutation) {
  38839. m.oldValue = func(context.Context) (*Wx, error) {
  38840. return node, nil
  38841. }
  38842. m.id = &node.ID
  38843. }
  38844. }
  38845. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38846. // executed in a transaction (ent.Tx), a transactional client is returned.
  38847. func (m WxMutation) Client() *Client {
  38848. client := &Client{config: m.config}
  38849. client.init()
  38850. return client
  38851. }
  38852. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38853. // it returns an error otherwise.
  38854. func (m WxMutation) Tx() (*Tx, error) {
  38855. if _, ok := m.driver.(*txDriver); !ok {
  38856. return nil, errors.New("ent: mutation is not running in a transaction")
  38857. }
  38858. tx := &Tx{config: m.config}
  38859. tx.init()
  38860. return tx, nil
  38861. }
  38862. // SetID sets the value of the id field. Note that this
  38863. // operation is only accepted on creation of Wx entities.
  38864. func (m *WxMutation) SetID(id uint64) {
  38865. m.id = &id
  38866. }
  38867. // ID returns the ID value in the mutation. Note that the ID is only available
  38868. // if it was provided to the builder or after it was returned from the database.
  38869. func (m *WxMutation) ID() (id uint64, exists bool) {
  38870. if m.id == nil {
  38871. return
  38872. }
  38873. return *m.id, true
  38874. }
  38875. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38876. // That means, if the mutation is applied within a transaction with an isolation level such
  38877. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38878. // or updated by the mutation.
  38879. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  38880. switch {
  38881. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38882. id, exists := m.ID()
  38883. if exists {
  38884. return []uint64{id}, nil
  38885. }
  38886. fallthrough
  38887. case m.op.Is(OpUpdate | OpDelete):
  38888. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  38889. default:
  38890. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38891. }
  38892. }
  38893. // SetCreatedAt sets the "created_at" field.
  38894. func (m *WxMutation) SetCreatedAt(t time.Time) {
  38895. m.created_at = &t
  38896. }
  38897. // CreatedAt returns the value of the "created_at" field in the mutation.
  38898. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  38899. v := m.created_at
  38900. if v == nil {
  38901. return
  38902. }
  38903. return *v, true
  38904. }
  38905. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  38906. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38908. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38909. if !m.op.Is(OpUpdateOne) {
  38910. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38911. }
  38912. if m.id == nil || m.oldValue == nil {
  38913. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38914. }
  38915. oldValue, err := m.oldValue(ctx)
  38916. if err != nil {
  38917. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38918. }
  38919. return oldValue.CreatedAt, nil
  38920. }
  38921. // ResetCreatedAt resets all changes to the "created_at" field.
  38922. func (m *WxMutation) ResetCreatedAt() {
  38923. m.created_at = nil
  38924. }
  38925. // SetUpdatedAt sets the "updated_at" field.
  38926. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  38927. m.updated_at = &t
  38928. }
  38929. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38930. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  38931. v := m.updated_at
  38932. if v == nil {
  38933. return
  38934. }
  38935. return *v, true
  38936. }
  38937. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  38938. // If the Wx 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 *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38941. if !m.op.Is(OpUpdateOne) {
  38942. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38943. }
  38944. if m.id == nil || m.oldValue == nil {
  38945. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  38950. }
  38951. return oldValue.UpdatedAt, nil
  38952. }
  38953. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38954. func (m *WxMutation) ResetUpdatedAt() {
  38955. m.updated_at = nil
  38956. }
  38957. // SetStatus sets the "status" field.
  38958. func (m *WxMutation) SetStatus(u uint8) {
  38959. m.status = &u
  38960. m.addstatus = nil
  38961. }
  38962. // Status returns the value of the "status" field in the mutation.
  38963. func (m *WxMutation) Status() (r uint8, exists bool) {
  38964. v := m.status
  38965. if v == nil {
  38966. return
  38967. }
  38968. return *v, true
  38969. }
  38970. // OldStatus returns the old "status" field's value of the Wx entity.
  38971. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38973. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38974. if !m.op.Is(OpUpdateOne) {
  38975. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38976. }
  38977. if m.id == nil || m.oldValue == nil {
  38978. return v, errors.New("OldStatus requires an ID field in the mutation")
  38979. }
  38980. oldValue, err := m.oldValue(ctx)
  38981. if err != nil {
  38982. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38983. }
  38984. return oldValue.Status, nil
  38985. }
  38986. // AddStatus adds u to the "status" field.
  38987. func (m *WxMutation) AddStatus(u int8) {
  38988. if m.addstatus != nil {
  38989. *m.addstatus += u
  38990. } else {
  38991. m.addstatus = &u
  38992. }
  38993. }
  38994. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38995. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  38996. v := m.addstatus
  38997. if v == nil {
  38998. return
  38999. }
  39000. return *v, true
  39001. }
  39002. // ClearStatus clears the value of the "status" field.
  39003. func (m *WxMutation) ClearStatus() {
  39004. m.status = nil
  39005. m.addstatus = nil
  39006. m.clearedFields[wx.FieldStatus] = struct{}{}
  39007. }
  39008. // StatusCleared returns if the "status" field was cleared in this mutation.
  39009. func (m *WxMutation) StatusCleared() bool {
  39010. _, ok := m.clearedFields[wx.FieldStatus]
  39011. return ok
  39012. }
  39013. // ResetStatus resets all changes to the "status" field.
  39014. func (m *WxMutation) ResetStatus() {
  39015. m.status = nil
  39016. m.addstatus = nil
  39017. delete(m.clearedFields, wx.FieldStatus)
  39018. }
  39019. // SetDeletedAt sets the "deleted_at" field.
  39020. func (m *WxMutation) SetDeletedAt(t time.Time) {
  39021. m.deleted_at = &t
  39022. }
  39023. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39024. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  39025. v := m.deleted_at
  39026. if v == nil {
  39027. return
  39028. }
  39029. return *v, true
  39030. }
  39031. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  39032. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39034. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39035. if !m.op.Is(OpUpdateOne) {
  39036. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39037. }
  39038. if m.id == nil || m.oldValue == nil {
  39039. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39040. }
  39041. oldValue, err := m.oldValue(ctx)
  39042. if err != nil {
  39043. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39044. }
  39045. return oldValue.DeletedAt, nil
  39046. }
  39047. // ClearDeletedAt clears the value of the "deleted_at" field.
  39048. func (m *WxMutation) ClearDeletedAt() {
  39049. m.deleted_at = nil
  39050. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  39051. }
  39052. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39053. func (m *WxMutation) DeletedAtCleared() bool {
  39054. _, ok := m.clearedFields[wx.FieldDeletedAt]
  39055. return ok
  39056. }
  39057. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39058. func (m *WxMutation) ResetDeletedAt() {
  39059. m.deleted_at = nil
  39060. delete(m.clearedFields, wx.FieldDeletedAt)
  39061. }
  39062. // SetServerID sets the "server_id" field.
  39063. func (m *WxMutation) SetServerID(u uint64) {
  39064. m.server = &u
  39065. }
  39066. // ServerID returns the value of the "server_id" field in the mutation.
  39067. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  39068. v := m.server
  39069. if v == nil {
  39070. return
  39071. }
  39072. return *v, true
  39073. }
  39074. // OldServerID returns the old "server_id" field's value of the Wx entity.
  39075. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39077. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  39078. if !m.op.Is(OpUpdateOne) {
  39079. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  39080. }
  39081. if m.id == nil || m.oldValue == nil {
  39082. return v, errors.New("OldServerID requires an ID field in the mutation")
  39083. }
  39084. oldValue, err := m.oldValue(ctx)
  39085. if err != nil {
  39086. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  39087. }
  39088. return oldValue.ServerID, nil
  39089. }
  39090. // ClearServerID clears the value of the "server_id" field.
  39091. func (m *WxMutation) ClearServerID() {
  39092. m.server = nil
  39093. m.clearedFields[wx.FieldServerID] = struct{}{}
  39094. }
  39095. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  39096. func (m *WxMutation) ServerIDCleared() bool {
  39097. _, ok := m.clearedFields[wx.FieldServerID]
  39098. return ok
  39099. }
  39100. // ResetServerID resets all changes to the "server_id" field.
  39101. func (m *WxMutation) ResetServerID() {
  39102. m.server = nil
  39103. delete(m.clearedFields, wx.FieldServerID)
  39104. }
  39105. // SetPort sets the "port" field.
  39106. func (m *WxMutation) SetPort(s string) {
  39107. m.port = &s
  39108. }
  39109. // Port returns the value of the "port" field in the mutation.
  39110. func (m *WxMutation) Port() (r string, exists bool) {
  39111. v := m.port
  39112. if v == nil {
  39113. return
  39114. }
  39115. return *v, true
  39116. }
  39117. // OldPort returns the old "port" field's value of the Wx entity.
  39118. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39120. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  39121. if !m.op.Is(OpUpdateOne) {
  39122. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  39123. }
  39124. if m.id == nil || m.oldValue == nil {
  39125. return v, errors.New("OldPort requires an ID field in the mutation")
  39126. }
  39127. oldValue, err := m.oldValue(ctx)
  39128. if err != nil {
  39129. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  39130. }
  39131. return oldValue.Port, nil
  39132. }
  39133. // ResetPort resets all changes to the "port" field.
  39134. func (m *WxMutation) ResetPort() {
  39135. m.port = nil
  39136. }
  39137. // SetProcessID sets the "process_id" field.
  39138. func (m *WxMutation) SetProcessID(s string) {
  39139. m.process_id = &s
  39140. }
  39141. // ProcessID returns the value of the "process_id" field in the mutation.
  39142. func (m *WxMutation) ProcessID() (r string, exists bool) {
  39143. v := m.process_id
  39144. if v == nil {
  39145. return
  39146. }
  39147. return *v, true
  39148. }
  39149. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  39150. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39152. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  39153. if !m.op.Is(OpUpdateOne) {
  39154. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  39155. }
  39156. if m.id == nil || m.oldValue == nil {
  39157. return v, errors.New("OldProcessID requires an ID field in the mutation")
  39158. }
  39159. oldValue, err := m.oldValue(ctx)
  39160. if err != nil {
  39161. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  39162. }
  39163. return oldValue.ProcessID, nil
  39164. }
  39165. // ResetProcessID resets all changes to the "process_id" field.
  39166. func (m *WxMutation) ResetProcessID() {
  39167. m.process_id = nil
  39168. }
  39169. // SetCallback sets the "callback" field.
  39170. func (m *WxMutation) SetCallback(s string) {
  39171. m.callback = &s
  39172. }
  39173. // Callback returns the value of the "callback" field in the mutation.
  39174. func (m *WxMutation) Callback() (r string, exists bool) {
  39175. v := m.callback
  39176. if v == nil {
  39177. return
  39178. }
  39179. return *v, true
  39180. }
  39181. // OldCallback returns the old "callback" field's value of the Wx entity.
  39182. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39184. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  39185. if !m.op.Is(OpUpdateOne) {
  39186. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  39187. }
  39188. if m.id == nil || m.oldValue == nil {
  39189. return v, errors.New("OldCallback requires an ID field in the mutation")
  39190. }
  39191. oldValue, err := m.oldValue(ctx)
  39192. if err != nil {
  39193. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  39194. }
  39195. return oldValue.Callback, nil
  39196. }
  39197. // ResetCallback resets all changes to the "callback" field.
  39198. func (m *WxMutation) ResetCallback() {
  39199. m.callback = nil
  39200. }
  39201. // SetWxid sets the "wxid" field.
  39202. func (m *WxMutation) SetWxid(s string) {
  39203. m.wxid = &s
  39204. }
  39205. // Wxid returns the value of the "wxid" field in the mutation.
  39206. func (m *WxMutation) Wxid() (r string, exists bool) {
  39207. v := m.wxid
  39208. if v == nil {
  39209. return
  39210. }
  39211. return *v, true
  39212. }
  39213. // OldWxid returns the old "wxid" field's value of the Wx entity.
  39214. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39216. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  39217. if !m.op.Is(OpUpdateOne) {
  39218. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39219. }
  39220. if m.id == nil || m.oldValue == nil {
  39221. return v, errors.New("OldWxid requires an ID field in the mutation")
  39222. }
  39223. oldValue, err := m.oldValue(ctx)
  39224. if err != nil {
  39225. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39226. }
  39227. return oldValue.Wxid, nil
  39228. }
  39229. // ResetWxid resets all changes to the "wxid" field.
  39230. func (m *WxMutation) ResetWxid() {
  39231. m.wxid = nil
  39232. }
  39233. // SetAccount sets the "account" field.
  39234. func (m *WxMutation) SetAccount(s string) {
  39235. m.account = &s
  39236. }
  39237. // Account returns the value of the "account" field in the mutation.
  39238. func (m *WxMutation) Account() (r string, exists bool) {
  39239. v := m.account
  39240. if v == nil {
  39241. return
  39242. }
  39243. return *v, true
  39244. }
  39245. // OldAccount returns the old "account" field's value of the Wx entity.
  39246. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39248. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  39249. if !m.op.Is(OpUpdateOne) {
  39250. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39251. }
  39252. if m.id == nil || m.oldValue == nil {
  39253. return v, errors.New("OldAccount requires an ID field in the mutation")
  39254. }
  39255. oldValue, err := m.oldValue(ctx)
  39256. if err != nil {
  39257. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39258. }
  39259. return oldValue.Account, nil
  39260. }
  39261. // ResetAccount resets all changes to the "account" field.
  39262. func (m *WxMutation) ResetAccount() {
  39263. m.account = nil
  39264. }
  39265. // SetNickname sets the "nickname" field.
  39266. func (m *WxMutation) SetNickname(s string) {
  39267. m.nickname = &s
  39268. }
  39269. // Nickname returns the value of the "nickname" field in the mutation.
  39270. func (m *WxMutation) Nickname() (r string, exists bool) {
  39271. v := m.nickname
  39272. if v == nil {
  39273. return
  39274. }
  39275. return *v, true
  39276. }
  39277. // OldNickname returns the old "nickname" field's value of the Wx entity.
  39278. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39280. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  39281. if !m.op.Is(OpUpdateOne) {
  39282. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39283. }
  39284. if m.id == nil || m.oldValue == nil {
  39285. return v, errors.New("OldNickname requires an ID field in the mutation")
  39286. }
  39287. oldValue, err := m.oldValue(ctx)
  39288. if err != nil {
  39289. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39290. }
  39291. return oldValue.Nickname, nil
  39292. }
  39293. // ResetNickname resets all changes to the "nickname" field.
  39294. func (m *WxMutation) ResetNickname() {
  39295. m.nickname = nil
  39296. }
  39297. // SetTel sets the "tel" field.
  39298. func (m *WxMutation) SetTel(s string) {
  39299. m.tel = &s
  39300. }
  39301. // Tel returns the value of the "tel" field in the mutation.
  39302. func (m *WxMutation) Tel() (r string, exists bool) {
  39303. v := m.tel
  39304. if v == nil {
  39305. return
  39306. }
  39307. return *v, true
  39308. }
  39309. // OldTel returns the old "tel" field's value of the Wx entity.
  39310. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39312. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  39313. if !m.op.Is(OpUpdateOne) {
  39314. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  39315. }
  39316. if m.id == nil || m.oldValue == nil {
  39317. return v, errors.New("OldTel requires an ID field in the mutation")
  39318. }
  39319. oldValue, err := m.oldValue(ctx)
  39320. if err != nil {
  39321. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  39322. }
  39323. return oldValue.Tel, nil
  39324. }
  39325. // ResetTel resets all changes to the "tel" field.
  39326. func (m *WxMutation) ResetTel() {
  39327. m.tel = nil
  39328. }
  39329. // SetHeadBig sets the "head_big" field.
  39330. func (m *WxMutation) SetHeadBig(s string) {
  39331. m.head_big = &s
  39332. }
  39333. // HeadBig returns the value of the "head_big" field in the mutation.
  39334. func (m *WxMutation) HeadBig() (r string, exists bool) {
  39335. v := m.head_big
  39336. if v == nil {
  39337. return
  39338. }
  39339. return *v, true
  39340. }
  39341. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  39342. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39344. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  39345. if !m.op.Is(OpUpdateOne) {
  39346. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  39347. }
  39348. if m.id == nil || m.oldValue == nil {
  39349. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  39350. }
  39351. oldValue, err := m.oldValue(ctx)
  39352. if err != nil {
  39353. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  39354. }
  39355. return oldValue.HeadBig, nil
  39356. }
  39357. // ResetHeadBig resets all changes to the "head_big" field.
  39358. func (m *WxMutation) ResetHeadBig() {
  39359. m.head_big = nil
  39360. }
  39361. // SetOrganizationID sets the "organization_id" field.
  39362. func (m *WxMutation) SetOrganizationID(u uint64) {
  39363. m.organization_id = &u
  39364. m.addorganization_id = nil
  39365. }
  39366. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39367. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  39368. v := m.organization_id
  39369. if v == nil {
  39370. return
  39371. }
  39372. return *v, true
  39373. }
  39374. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  39375. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39377. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39378. if !m.op.Is(OpUpdateOne) {
  39379. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39380. }
  39381. if m.id == nil || m.oldValue == nil {
  39382. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39383. }
  39384. oldValue, err := m.oldValue(ctx)
  39385. if err != nil {
  39386. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39387. }
  39388. return oldValue.OrganizationID, nil
  39389. }
  39390. // AddOrganizationID adds u to the "organization_id" field.
  39391. func (m *WxMutation) AddOrganizationID(u int64) {
  39392. if m.addorganization_id != nil {
  39393. *m.addorganization_id += u
  39394. } else {
  39395. m.addorganization_id = &u
  39396. }
  39397. }
  39398. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39399. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  39400. v := m.addorganization_id
  39401. if v == nil {
  39402. return
  39403. }
  39404. return *v, true
  39405. }
  39406. // ClearOrganizationID clears the value of the "organization_id" field.
  39407. func (m *WxMutation) ClearOrganizationID() {
  39408. m.organization_id = nil
  39409. m.addorganization_id = nil
  39410. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  39411. }
  39412. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39413. func (m *WxMutation) OrganizationIDCleared() bool {
  39414. _, ok := m.clearedFields[wx.FieldOrganizationID]
  39415. return ok
  39416. }
  39417. // ResetOrganizationID resets all changes to the "organization_id" field.
  39418. func (m *WxMutation) ResetOrganizationID() {
  39419. m.organization_id = nil
  39420. m.addorganization_id = nil
  39421. delete(m.clearedFields, wx.FieldOrganizationID)
  39422. }
  39423. // SetAgentID sets the "agent_id" field.
  39424. func (m *WxMutation) SetAgentID(u uint64) {
  39425. m.agent = &u
  39426. }
  39427. // AgentID returns the value of the "agent_id" field in the mutation.
  39428. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  39429. v := m.agent
  39430. if v == nil {
  39431. return
  39432. }
  39433. return *v, true
  39434. }
  39435. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  39436. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39438. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  39439. if !m.op.Is(OpUpdateOne) {
  39440. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  39441. }
  39442. if m.id == nil || m.oldValue == nil {
  39443. return v, errors.New("OldAgentID requires an ID field in the mutation")
  39444. }
  39445. oldValue, err := m.oldValue(ctx)
  39446. if err != nil {
  39447. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  39448. }
  39449. return oldValue.AgentID, nil
  39450. }
  39451. // ResetAgentID resets all changes to the "agent_id" field.
  39452. func (m *WxMutation) ResetAgentID() {
  39453. m.agent = nil
  39454. }
  39455. // SetAPIBase sets the "api_base" field.
  39456. func (m *WxMutation) SetAPIBase(s string) {
  39457. m.api_base = &s
  39458. }
  39459. // APIBase returns the value of the "api_base" field in the mutation.
  39460. func (m *WxMutation) APIBase() (r string, exists bool) {
  39461. v := m.api_base
  39462. if v == nil {
  39463. return
  39464. }
  39465. return *v, true
  39466. }
  39467. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  39468. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39470. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39471. if !m.op.Is(OpUpdateOne) {
  39472. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39473. }
  39474. if m.id == nil || m.oldValue == nil {
  39475. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39476. }
  39477. oldValue, err := m.oldValue(ctx)
  39478. if err != nil {
  39479. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39480. }
  39481. return oldValue.APIBase, nil
  39482. }
  39483. // ClearAPIBase clears the value of the "api_base" field.
  39484. func (m *WxMutation) ClearAPIBase() {
  39485. m.api_base = nil
  39486. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  39487. }
  39488. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39489. func (m *WxMutation) APIBaseCleared() bool {
  39490. _, ok := m.clearedFields[wx.FieldAPIBase]
  39491. return ok
  39492. }
  39493. // ResetAPIBase resets all changes to the "api_base" field.
  39494. func (m *WxMutation) ResetAPIBase() {
  39495. m.api_base = nil
  39496. delete(m.clearedFields, wx.FieldAPIBase)
  39497. }
  39498. // SetAPIKey sets the "api_key" field.
  39499. func (m *WxMutation) SetAPIKey(s string) {
  39500. m.api_key = &s
  39501. }
  39502. // APIKey returns the value of the "api_key" field in the mutation.
  39503. func (m *WxMutation) APIKey() (r string, exists bool) {
  39504. v := m.api_key
  39505. if v == nil {
  39506. return
  39507. }
  39508. return *v, true
  39509. }
  39510. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  39511. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39513. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39514. if !m.op.Is(OpUpdateOne) {
  39515. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39516. }
  39517. if m.id == nil || m.oldValue == nil {
  39518. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39519. }
  39520. oldValue, err := m.oldValue(ctx)
  39521. if err != nil {
  39522. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39523. }
  39524. return oldValue.APIKey, nil
  39525. }
  39526. // ClearAPIKey clears the value of the "api_key" field.
  39527. func (m *WxMutation) ClearAPIKey() {
  39528. m.api_key = nil
  39529. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  39530. }
  39531. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39532. func (m *WxMutation) APIKeyCleared() bool {
  39533. _, ok := m.clearedFields[wx.FieldAPIKey]
  39534. return ok
  39535. }
  39536. // ResetAPIKey resets all changes to the "api_key" field.
  39537. func (m *WxMutation) ResetAPIKey() {
  39538. m.api_key = nil
  39539. delete(m.clearedFields, wx.FieldAPIKey)
  39540. }
  39541. // SetAllowList sets the "allow_list" field.
  39542. func (m *WxMutation) SetAllowList(s []string) {
  39543. m.allow_list = &s
  39544. m.appendallow_list = nil
  39545. }
  39546. // AllowList returns the value of the "allow_list" field in the mutation.
  39547. func (m *WxMutation) AllowList() (r []string, exists bool) {
  39548. v := m.allow_list
  39549. if v == nil {
  39550. return
  39551. }
  39552. return *v, true
  39553. }
  39554. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  39555. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39557. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  39558. if !m.op.Is(OpUpdateOne) {
  39559. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  39560. }
  39561. if m.id == nil || m.oldValue == nil {
  39562. return v, errors.New("OldAllowList requires an ID field in the mutation")
  39563. }
  39564. oldValue, err := m.oldValue(ctx)
  39565. if err != nil {
  39566. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  39567. }
  39568. return oldValue.AllowList, nil
  39569. }
  39570. // AppendAllowList adds s to the "allow_list" field.
  39571. func (m *WxMutation) AppendAllowList(s []string) {
  39572. m.appendallow_list = append(m.appendallow_list, s...)
  39573. }
  39574. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  39575. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  39576. if len(m.appendallow_list) == 0 {
  39577. return nil, false
  39578. }
  39579. return m.appendallow_list, true
  39580. }
  39581. // ResetAllowList resets all changes to the "allow_list" field.
  39582. func (m *WxMutation) ResetAllowList() {
  39583. m.allow_list = nil
  39584. m.appendallow_list = nil
  39585. }
  39586. // SetGroupAllowList sets the "group_allow_list" field.
  39587. func (m *WxMutation) SetGroupAllowList(s []string) {
  39588. m.group_allow_list = &s
  39589. m.appendgroup_allow_list = nil
  39590. }
  39591. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  39592. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  39593. v := m.group_allow_list
  39594. if v == nil {
  39595. return
  39596. }
  39597. return *v, true
  39598. }
  39599. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  39600. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39602. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  39603. if !m.op.Is(OpUpdateOne) {
  39604. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  39605. }
  39606. if m.id == nil || m.oldValue == nil {
  39607. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  39608. }
  39609. oldValue, err := m.oldValue(ctx)
  39610. if err != nil {
  39611. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  39612. }
  39613. return oldValue.GroupAllowList, nil
  39614. }
  39615. // AppendGroupAllowList adds s to the "group_allow_list" field.
  39616. func (m *WxMutation) AppendGroupAllowList(s []string) {
  39617. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  39618. }
  39619. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  39620. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  39621. if len(m.appendgroup_allow_list) == 0 {
  39622. return nil, false
  39623. }
  39624. return m.appendgroup_allow_list, true
  39625. }
  39626. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  39627. func (m *WxMutation) ResetGroupAllowList() {
  39628. m.group_allow_list = nil
  39629. m.appendgroup_allow_list = nil
  39630. }
  39631. // SetBlockList sets the "block_list" field.
  39632. func (m *WxMutation) SetBlockList(s []string) {
  39633. m.block_list = &s
  39634. m.appendblock_list = nil
  39635. }
  39636. // BlockList returns the value of the "block_list" field in the mutation.
  39637. func (m *WxMutation) BlockList() (r []string, exists bool) {
  39638. v := m.block_list
  39639. if v == nil {
  39640. return
  39641. }
  39642. return *v, true
  39643. }
  39644. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  39645. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39647. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  39648. if !m.op.Is(OpUpdateOne) {
  39649. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  39650. }
  39651. if m.id == nil || m.oldValue == nil {
  39652. return v, errors.New("OldBlockList requires an ID field in the mutation")
  39653. }
  39654. oldValue, err := m.oldValue(ctx)
  39655. if err != nil {
  39656. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  39657. }
  39658. return oldValue.BlockList, nil
  39659. }
  39660. // AppendBlockList adds s to the "block_list" field.
  39661. func (m *WxMutation) AppendBlockList(s []string) {
  39662. m.appendblock_list = append(m.appendblock_list, s...)
  39663. }
  39664. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  39665. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  39666. if len(m.appendblock_list) == 0 {
  39667. return nil, false
  39668. }
  39669. return m.appendblock_list, true
  39670. }
  39671. // ResetBlockList resets all changes to the "block_list" field.
  39672. func (m *WxMutation) ResetBlockList() {
  39673. m.block_list = nil
  39674. m.appendblock_list = nil
  39675. }
  39676. // SetGroupBlockList sets the "group_block_list" field.
  39677. func (m *WxMutation) SetGroupBlockList(s []string) {
  39678. m.group_block_list = &s
  39679. m.appendgroup_block_list = nil
  39680. }
  39681. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  39682. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  39683. v := m.group_block_list
  39684. if v == nil {
  39685. return
  39686. }
  39687. return *v, true
  39688. }
  39689. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  39690. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39692. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  39693. if !m.op.Is(OpUpdateOne) {
  39694. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  39695. }
  39696. if m.id == nil || m.oldValue == nil {
  39697. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  39698. }
  39699. oldValue, err := m.oldValue(ctx)
  39700. if err != nil {
  39701. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  39702. }
  39703. return oldValue.GroupBlockList, nil
  39704. }
  39705. // AppendGroupBlockList adds s to the "group_block_list" field.
  39706. func (m *WxMutation) AppendGroupBlockList(s []string) {
  39707. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  39708. }
  39709. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  39710. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  39711. if len(m.appendgroup_block_list) == 0 {
  39712. return nil, false
  39713. }
  39714. return m.appendgroup_block_list, true
  39715. }
  39716. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  39717. func (m *WxMutation) ResetGroupBlockList() {
  39718. m.group_block_list = nil
  39719. m.appendgroup_block_list = nil
  39720. }
  39721. // ClearServer clears the "server" edge to the Server entity.
  39722. func (m *WxMutation) ClearServer() {
  39723. m.clearedserver = true
  39724. m.clearedFields[wx.FieldServerID] = struct{}{}
  39725. }
  39726. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  39727. func (m *WxMutation) ServerCleared() bool {
  39728. return m.ServerIDCleared() || m.clearedserver
  39729. }
  39730. // ServerIDs returns the "server" edge IDs in the mutation.
  39731. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39732. // ServerID instead. It exists only for internal usage by the builders.
  39733. func (m *WxMutation) ServerIDs() (ids []uint64) {
  39734. if id := m.server; id != nil {
  39735. ids = append(ids, *id)
  39736. }
  39737. return
  39738. }
  39739. // ResetServer resets all changes to the "server" edge.
  39740. func (m *WxMutation) ResetServer() {
  39741. m.server = nil
  39742. m.clearedserver = false
  39743. }
  39744. // ClearAgent clears the "agent" edge to the Agent entity.
  39745. func (m *WxMutation) ClearAgent() {
  39746. m.clearedagent = true
  39747. m.clearedFields[wx.FieldAgentID] = struct{}{}
  39748. }
  39749. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  39750. func (m *WxMutation) AgentCleared() bool {
  39751. return m.clearedagent
  39752. }
  39753. // AgentIDs returns the "agent" edge IDs in the mutation.
  39754. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39755. // AgentID instead. It exists only for internal usage by the builders.
  39756. func (m *WxMutation) AgentIDs() (ids []uint64) {
  39757. if id := m.agent; id != nil {
  39758. ids = append(ids, *id)
  39759. }
  39760. return
  39761. }
  39762. // ResetAgent resets all changes to the "agent" edge.
  39763. func (m *WxMutation) ResetAgent() {
  39764. m.agent = nil
  39765. m.clearedagent = false
  39766. }
  39767. // Where appends a list predicates to the WxMutation builder.
  39768. func (m *WxMutation) Where(ps ...predicate.Wx) {
  39769. m.predicates = append(m.predicates, ps...)
  39770. }
  39771. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  39772. // users can use type-assertion to append predicates that do not depend on any generated package.
  39773. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  39774. p := make([]predicate.Wx, len(ps))
  39775. for i := range ps {
  39776. p[i] = ps[i]
  39777. }
  39778. m.Where(p...)
  39779. }
  39780. // Op returns the operation name.
  39781. func (m *WxMutation) Op() Op {
  39782. return m.op
  39783. }
  39784. // SetOp allows setting the mutation operation.
  39785. func (m *WxMutation) SetOp(op Op) {
  39786. m.op = op
  39787. }
  39788. // Type returns the node type of this mutation (Wx).
  39789. func (m *WxMutation) Type() string {
  39790. return m.typ
  39791. }
  39792. // Fields returns all fields that were changed during this mutation. Note that in
  39793. // order to get all numeric fields that were incremented/decremented, call
  39794. // AddedFields().
  39795. func (m *WxMutation) Fields() []string {
  39796. fields := make([]string, 0, 21)
  39797. if m.created_at != nil {
  39798. fields = append(fields, wx.FieldCreatedAt)
  39799. }
  39800. if m.updated_at != nil {
  39801. fields = append(fields, wx.FieldUpdatedAt)
  39802. }
  39803. if m.status != nil {
  39804. fields = append(fields, wx.FieldStatus)
  39805. }
  39806. if m.deleted_at != nil {
  39807. fields = append(fields, wx.FieldDeletedAt)
  39808. }
  39809. if m.server != nil {
  39810. fields = append(fields, wx.FieldServerID)
  39811. }
  39812. if m.port != nil {
  39813. fields = append(fields, wx.FieldPort)
  39814. }
  39815. if m.process_id != nil {
  39816. fields = append(fields, wx.FieldProcessID)
  39817. }
  39818. if m.callback != nil {
  39819. fields = append(fields, wx.FieldCallback)
  39820. }
  39821. if m.wxid != nil {
  39822. fields = append(fields, wx.FieldWxid)
  39823. }
  39824. if m.account != nil {
  39825. fields = append(fields, wx.FieldAccount)
  39826. }
  39827. if m.nickname != nil {
  39828. fields = append(fields, wx.FieldNickname)
  39829. }
  39830. if m.tel != nil {
  39831. fields = append(fields, wx.FieldTel)
  39832. }
  39833. if m.head_big != nil {
  39834. fields = append(fields, wx.FieldHeadBig)
  39835. }
  39836. if m.organization_id != nil {
  39837. fields = append(fields, wx.FieldOrganizationID)
  39838. }
  39839. if m.agent != nil {
  39840. fields = append(fields, wx.FieldAgentID)
  39841. }
  39842. if m.api_base != nil {
  39843. fields = append(fields, wx.FieldAPIBase)
  39844. }
  39845. if m.api_key != nil {
  39846. fields = append(fields, wx.FieldAPIKey)
  39847. }
  39848. if m.allow_list != nil {
  39849. fields = append(fields, wx.FieldAllowList)
  39850. }
  39851. if m.group_allow_list != nil {
  39852. fields = append(fields, wx.FieldGroupAllowList)
  39853. }
  39854. if m.block_list != nil {
  39855. fields = append(fields, wx.FieldBlockList)
  39856. }
  39857. if m.group_block_list != nil {
  39858. fields = append(fields, wx.FieldGroupBlockList)
  39859. }
  39860. return fields
  39861. }
  39862. // Field returns the value of a field with the given name. The second boolean
  39863. // return value indicates that this field was not set, or was not defined in the
  39864. // schema.
  39865. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  39866. switch name {
  39867. case wx.FieldCreatedAt:
  39868. return m.CreatedAt()
  39869. case wx.FieldUpdatedAt:
  39870. return m.UpdatedAt()
  39871. case wx.FieldStatus:
  39872. return m.Status()
  39873. case wx.FieldDeletedAt:
  39874. return m.DeletedAt()
  39875. case wx.FieldServerID:
  39876. return m.ServerID()
  39877. case wx.FieldPort:
  39878. return m.Port()
  39879. case wx.FieldProcessID:
  39880. return m.ProcessID()
  39881. case wx.FieldCallback:
  39882. return m.Callback()
  39883. case wx.FieldWxid:
  39884. return m.Wxid()
  39885. case wx.FieldAccount:
  39886. return m.Account()
  39887. case wx.FieldNickname:
  39888. return m.Nickname()
  39889. case wx.FieldTel:
  39890. return m.Tel()
  39891. case wx.FieldHeadBig:
  39892. return m.HeadBig()
  39893. case wx.FieldOrganizationID:
  39894. return m.OrganizationID()
  39895. case wx.FieldAgentID:
  39896. return m.AgentID()
  39897. case wx.FieldAPIBase:
  39898. return m.APIBase()
  39899. case wx.FieldAPIKey:
  39900. return m.APIKey()
  39901. case wx.FieldAllowList:
  39902. return m.AllowList()
  39903. case wx.FieldGroupAllowList:
  39904. return m.GroupAllowList()
  39905. case wx.FieldBlockList:
  39906. return m.BlockList()
  39907. case wx.FieldGroupBlockList:
  39908. return m.GroupBlockList()
  39909. }
  39910. return nil, false
  39911. }
  39912. // OldField returns the old value of the field from the database. An error is
  39913. // returned if the mutation operation is not UpdateOne, or the query to the
  39914. // database failed.
  39915. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39916. switch name {
  39917. case wx.FieldCreatedAt:
  39918. return m.OldCreatedAt(ctx)
  39919. case wx.FieldUpdatedAt:
  39920. return m.OldUpdatedAt(ctx)
  39921. case wx.FieldStatus:
  39922. return m.OldStatus(ctx)
  39923. case wx.FieldDeletedAt:
  39924. return m.OldDeletedAt(ctx)
  39925. case wx.FieldServerID:
  39926. return m.OldServerID(ctx)
  39927. case wx.FieldPort:
  39928. return m.OldPort(ctx)
  39929. case wx.FieldProcessID:
  39930. return m.OldProcessID(ctx)
  39931. case wx.FieldCallback:
  39932. return m.OldCallback(ctx)
  39933. case wx.FieldWxid:
  39934. return m.OldWxid(ctx)
  39935. case wx.FieldAccount:
  39936. return m.OldAccount(ctx)
  39937. case wx.FieldNickname:
  39938. return m.OldNickname(ctx)
  39939. case wx.FieldTel:
  39940. return m.OldTel(ctx)
  39941. case wx.FieldHeadBig:
  39942. return m.OldHeadBig(ctx)
  39943. case wx.FieldOrganizationID:
  39944. return m.OldOrganizationID(ctx)
  39945. case wx.FieldAgentID:
  39946. return m.OldAgentID(ctx)
  39947. case wx.FieldAPIBase:
  39948. return m.OldAPIBase(ctx)
  39949. case wx.FieldAPIKey:
  39950. return m.OldAPIKey(ctx)
  39951. case wx.FieldAllowList:
  39952. return m.OldAllowList(ctx)
  39953. case wx.FieldGroupAllowList:
  39954. return m.OldGroupAllowList(ctx)
  39955. case wx.FieldBlockList:
  39956. return m.OldBlockList(ctx)
  39957. case wx.FieldGroupBlockList:
  39958. return m.OldGroupBlockList(ctx)
  39959. }
  39960. return nil, fmt.Errorf("unknown Wx field %s", name)
  39961. }
  39962. // SetField sets the value of a field with the given name. It returns an error if
  39963. // the field is not defined in the schema, or if the type mismatched the field
  39964. // type.
  39965. func (m *WxMutation) SetField(name string, value ent.Value) error {
  39966. switch name {
  39967. case wx.FieldCreatedAt:
  39968. v, ok := value.(time.Time)
  39969. if !ok {
  39970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39971. }
  39972. m.SetCreatedAt(v)
  39973. return nil
  39974. case wx.FieldUpdatedAt:
  39975. v, ok := value.(time.Time)
  39976. if !ok {
  39977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39978. }
  39979. m.SetUpdatedAt(v)
  39980. return nil
  39981. case wx.FieldStatus:
  39982. v, ok := value.(uint8)
  39983. if !ok {
  39984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39985. }
  39986. m.SetStatus(v)
  39987. return nil
  39988. case wx.FieldDeletedAt:
  39989. v, ok := value.(time.Time)
  39990. if !ok {
  39991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39992. }
  39993. m.SetDeletedAt(v)
  39994. return nil
  39995. case wx.FieldServerID:
  39996. v, ok := value.(uint64)
  39997. if !ok {
  39998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39999. }
  40000. m.SetServerID(v)
  40001. return nil
  40002. case wx.FieldPort:
  40003. v, ok := value.(string)
  40004. if !ok {
  40005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40006. }
  40007. m.SetPort(v)
  40008. return nil
  40009. case wx.FieldProcessID:
  40010. v, ok := value.(string)
  40011. if !ok {
  40012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40013. }
  40014. m.SetProcessID(v)
  40015. return nil
  40016. case wx.FieldCallback:
  40017. v, ok := value.(string)
  40018. if !ok {
  40019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40020. }
  40021. m.SetCallback(v)
  40022. return nil
  40023. case wx.FieldWxid:
  40024. v, ok := value.(string)
  40025. if !ok {
  40026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40027. }
  40028. m.SetWxid(v)
  40029. return nil
  40030. case wx.FieldAccount:
  40031. v, ok := value.(string)
  40032. if !ok {
  40033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40034. }
  40035. m.SetAccount(v)
  40036. return nil
  40037. case wx.FieldNickname:
  40038. v, ok := value.(string)
  40039. if !ok {
  40040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40041. }
  40042. m.SetNickname(v)
  40043. return nil
  40044. case wx.FieldTel:
  40045. v, ok := value.(string)
  40046. if !ok {
  40047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40048. }
  40049. m.SetTel(v)
  40050. return nil
  40051. case wx.FieldHeadBig:
  40052. v, ok := value.(string)
  40053. if !ok {
  40054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40055. }
  40056. m.SetHeadBig(v)
  40057. return nil
  40058. case wx.FieldOrganizationID:
  40059. v, ok := value.(uint64)
  40060. if !ok {
  40061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40062. }
  40063. m.SetOrganizationID(v)
  40064. return nil
  40065. case wx.FieldAgentID:
  40066. v, ok := value.(uint64)
  40067. if !ok {
  40068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40069. }
  40070. m.SetAgentID(v)
  40071. return nil
  40072. case wx.FieldAPIBase:
  40073. v, ok := value.(string)
  40074. if !ok {
  40075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40076. }
  40077. m.SetAPIBase(v)
  40078. return nil
  40079. case wx.FieldAPIKey:
  40080. v, ok := value.(string)
  40081. if !ok {
  40082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40083. }
  40084. m.SetAPIKey(v)
  40085. return nil
  40086. case wx.FieldAllowList:
  40087. v, ok := value.([]string)
  40088. if !ok {
  40089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40090. }
  40091. m.SetAllowList(v)
  40092. return nil
  40093. case wx.FieldGroupAllowList:
  40094. v, ok := value.([]string)
  40095. if !ok {
  40096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40097. }
  40098. m.SetGroupAllowList(v)
  40099. return nil
  40100. case wx.FieldBlockList:
  40101. v, ok := value.([]string)
  40102. if !ok {
  40103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40104. }
  40105. m.SetBlockList(v)
  40106. return nil
  40107. case wx.FieldGroupBlockList:
  40108. v, ok := value.([]string)
  40109. if !ok {
  40110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40111. }
  40112. m.SetGroupBlockList(v)
  40113. return nil
  40114. }
  40115. return fmt.Errorf("unknown Wx field %s", name)
  40116. }
  40117. // AddedFields returns all numeric fields that were incremented/decremented during
  40118. // this mutation.
  40119. func (m *WxMutation) AddedFields() []string {
  40120. var fields []string
  40121. if m.addstatus != nil {
  40122. fields = append(fields, wx.FieldStatus)
  40123. }
  40124. if m.addorganization_id != nil {
  40125. fields = append(fields, wx.FieldOrganizationID)
  40126. }
  40127. return fields
  40128. }
  40129. // AddedField returns the numeric value that was incremented/decremented on a field
  40130. // with the given name. The second boolean return value indicates that this field
  40131. // was not set, or was not defined in the schema.
  40132. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  40133. switch name {
  40134. case wx.FieldStatus:
  40135. return m.AddedStatus()
  40136. case wx.FieldOrganizationID:
  40137. return m.AddedOrganizationID()
  40138. }
  40139. return nil, false
  40140. }
  40141. // AddField adds the value to the field with the given name. It returns an error if
  40142. // the field is not defined in the schema, or if the type mismatched the field
  40143. // type.
  40144. func (m *WxMutation) AddField(name string, value ent.Value) error {
  40145. switch name {
  40146. case wx.FieldStatus:
  40147. v, ok := value.(int8)
  40148. if !ok {
  40149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40150. }
  40151. m.AddStatus(v)
  40152. return nil
  40153. case wx.FieldOrganizationID:
  40154. v, ok := value.(int64)
  40155. if !ok {
  40156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40157. }
  40158. m.AddOrganizationID(v)
  40159. return nil
  40160. }
  40161. return fmt.Errorf("unknown Wx numeric field %s", name)
  40162. }
  40163. // ClearedFields returns all nullable fields that were cleared during this
  40164. // mutation.
  40165. func (m *WxMutation) ClearedFields() []string {
  40166. var fields []string
  40167. if m.FieldCleared(wx.FieldStatus) {
  40168. fields = append(fields, wx.FieldStatus)
  40169. }
  40170. if m.FieldCleared(wx.FieldDeletedAt) {
  40171. fields = append(fields, wx.FieldDeletedAt)
  40172. }
  40173. if m.FieldCleared(wx.FieldServerID) {
  40174. fields = append(fields, wx.FieldServerID)
  40175. }
  40176. if m.FieldCleared(wx.FieldOrganizationID) {
  40177. fields = append(fields, wx.FieldOrganizationID)
  40178. }
  40179. if m.FieldCleared(wx.FieldAPIBase) {
  40180. fields = append(fields, wx.FieldAPIBase)
  40181. }
  40182. if m.FieldCleared(wx.FieldAPIKey) {
  40183. fields = append(fields, wx.FieldAPIKey)
  40184. }
  40185. return fields
  40186. }
  40187. // FieldCleared returns a boolean indicating if a field with the given name was
  40188. // cleared in this mutation.
  40189. func (m *WxMutation) FieldCleared(name string) bool {
  40190. _, ok := m.clearedFields[name]
  40191. return ok
  40192. }
  40193. // ClearField clears the value of the field with the given name. It returns an
  40194. // error if the field is not defined in the schema.
  40195. func (m *WxMutation) ClearField(name string) error {
  40196. switch name {
  40197. case wx.FieldStatus:
  40198. m.ClearStatus()
  40199. return nil
  40200. case wx.FieldDeletedAt:
  40201. m.ClearDeletedAt()
  40202. return nil
  40203. case wx.FieldServerID:
  40204. m.ClearServerID()
  40205. return nil
  40206. case wx.FieldOrganizationID:
  40207. m.ClearOrganizationID()
  40208. return nil
  40209. case wx.FieldAPIBase:
  40210. m.ClearAPIBase()
  40211. return nil
  40212. case wx.FieldAPIKey:
  40213. m.ClearAPIKey()
  40214. return nil
  40215. }
  40216. return fmt.Errorf("unknown Wx nullable field %s", name)
  40217. }
  40218. // ResetField resets all changes in the mutation for the field with the given name.
  40219. // It returns an error if the field is not defined in the schema.
  40220. func (m *WxMutation) ResetField(name string) error {
  40221. switch name {
  40222. case wx.FieldCreatedAt:
  40223. m.ResetCreatedAt()
  40224. return nil
  40225. case wx.FieldUpdatedAt:
  40226. m.ResetUpdatedAt()
  40227. return nil
  40228. case wx.FieldStatus:
  40229. m.ResetStatus()
  40230. return nil
  40231. case wx.FieldDeletedAt:
  40232. m.ResetDeletedAt()
  40233. return nil
  40234. case wx.FieldServerID:
  40235. m.ResetServerID()
  40236. return nil
  40237. case wx.FieldPort:
  40238. m.ResetPort()
  40239. return nil
  40240. case wx.FieldProcessID:
  40241. m.ResetProcessID()
  40242. return nil
  40243. case wx.FieldCallback:
  40244. m.ResetCallback()
  40245. return nil
  40246. case wx.FieldWxid:
  40247. m.ResetWxid()
  40248. return nil
  40249. case wx.FieldAccount:
  40250. m.ResetAccount()
  40251. return nil
  40252. case wx.FieldNickname:
  40253. m.ResetNickname()
  40254. return nil
  40255. case wx.FieldTel:
  40256. m.ResetTel()
  40257. return nil
  40258. case wx.FieldHeadBig:
  40259. m.ResetHeadBig()
  40260. return nil
  40261. case wx.FieldOrganizationID:
  40262. m.ResetOrganizationID()
  40263. return nil
  40264. case wx.FieldAgentID:
  40265. m.ResetAgentID()
  40266. return nil
  40267. case wx.FieldAPIBase:
  40268. m.ResetAPIBase()
  40269. return nil
  40270. case wx.FieldAPIKey:
  40271. m.ResetAPIKey()
  40272. return nil
  40273. case wx.FieldAllowList:
  40274. m.ResetAllowList()
  40275. return nil
  40276. case wx.FieldGroupAllowList:
  40277. m.ResetGroupAllowList()
  40278. return nil
  40279. case wx.FieldBlockList:
  40280. m.ResetBlockList()
  40281. return nil
  40282. case wx.FieldGroupBlockList:
  40283. m.ResetGroupBlockList()
  40284. return nil
  40285. }
  40286. return fmt.Errorf("unknown Wx field %s", name)
  40287. }
  40288. // AddedEdges returns all edge names that were set/added in this mutation.
  40289. func (m *WxMutation) AddedEdges() []string {
  40290. edges := make([]string, 0, 2)
  40291. if m.server != nil {
  40292. edges = append(edges, wx.EdgeServer)
  40293. }
  40294. if m.agent != nil {
  40295. edges = append(edges, wx.EdgeAgent)
  40296. }
  40297. return edges
  40298. }
  40299. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40300. // name in this mutation.
  40301. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  40302. switch name {
  40303. case wx.EdgeServer:
  40304. if id := m.server; id != nil {
  40305. return []ent.Value{*id}
  40306. }
  40307. case wx.EdgeAgent:
  40308. if id := m.agent; id != nil {
  40309. return []ent.Value{*id}
  40310. }
  40311. }
  40312. return nil
  40313. }
  40314. // RemovedEdges returns all edge names that were removed in this mutation.
  40315. func (m *WxMutation) RemovedEdges() []string {
  40316. edges := make([]string, 0, 2)
  40317. return edges
  40318. }
  40319. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40320. // the given name in this mutation.
  40321. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  40322. return nil
  40323. }
  40324. // ClearedEdges returns all edge names that were cleared in this mutation.
  40325. func (m *WxMutation) ClearedEdges() []string {
  40326. edges := make([]string, 0, 2)
  40327. if m.clearedserver {
  40328. edges = append(edges, wx.EdgeServer)
  40329. }
  40330. if m.clearedagent {
  40331. edges = append(edges, wx.EdgeAgent)
  40332. }
  40333. return edges
  40334. }
  40335. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40336. // was cleared in this mutation.
  40337. func (m *WxMutation) EdgeCleared(name string) bool {
  40338. switch name {
  40339. case wx.EdgeServer:
  40340. return m.clearedserver
  40341. case wx.EdgeAgent:
  40342. return m.clearedagent
  40343. }
  40344. return false
  40345. }
  40346. // ClearEdge clears the value of the edge with the given name. It returns an error
  40347. // if that edge is not defined in the schema.
  40348. func (m *WxMutation) ClearEdge(name string) error {
  40349. switch name {
  40350. case wx.EdgeServer:
  40351. m.ClearServer()
  40352. return nil
  40353. case wx.EdgeAgent:
  40354. m.ClearAgent()
  40355. return nil
  40356. }
  40357. return fmt.Errorf("unknown Wx unique edge %s", name)
  40358. }
  40359. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40360. // It returns an error if the edge is not defined in the schema.
  40361. func (m *WxMutation) ResetEdge(name string) error {
  40362. switch name {
  40363. case wx.EdgeServer:
  40364. m.ResetServer()
  40365. return nil
  40366. case wx.EdgeAgent:
  40367. m.ResetAgent()
  40368. return nil
  40369. }
  40370. return fmt.Errorf("unknown Wx edge %s", name)
  40371. }
  40372. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  40373. type WxCardMutation struct {
  40374. config
  40375. op Op
  40376. typ string
  40377. id *uint64
  40378. created_at *time.Time
  40379. updated_at *time.Time
  40380. deleted_at *time.Time
  40381. user_id *uint64
  40382. adduser_id *int64
  40383. wx_user_id *uint64
  40384. addwx_user_id *int64
  40385. avatar *string
  40386. logo *string
  40387. name *string
  40388. company *string
  40389. address *string
  40390. phone *string
  40391. official_account *string
  40392. wechat_account *string
  40393. email *string
  40394. api_base *string
  40395. api_key *string
  40396. ai_info *string
  40397. intro *string
  40398. clearedFields map[string]struct{}
  40399. done bool
  40400. oldValue func(context.Context) (*WxCard, error)
  40401. predicates []predicate.WxCard
  40402. }
  40403. var _ ent.Mutation = (*WxCardMutation)(nil)
  40404. // wxcardOption allows management of the mutation configuration using functional options.
  40405. type wxcardOption func(*WxCardMutation)
  40406. // newWxCardMutation creates new mutation for the WxCard entity.
  40407. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  40408. m := &WxCardMutation{
  40409. config: c,
  40410. op: op,
  40411. typ: TypeWxCard,
  40412. clearedFields: make(map[string]struct{}),
  40413. }
  40414. for _, opt := range opts {
  40415. opt(m)
  40416. }
  40417. return m
  40418. }
  40419. // withWxCardID sets the ID field of the mutation.
  40420. func withWxCardID(id uint64) wxcardOption {
  40421. return func(m *WxCardMutation) {
  40422. var (
  40423. err error
  40424. once sync.Once
  40425. value *WxCard
  40426. )
  40427. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  40428. once.Do(func() {
  40429. if m.done {
  40430. err = errors.New("querying old values post mutation is not allowed")
  40431. } else {
  40432. value, err = m.Client().WxCard.Get(ctx, id)
  40433. }
  40434. })
  40435. return value, err
  40436. }
  40437. m.id = &id
  40438. }
  40439. }
  40440. // withWxCard sets the old WxCard of the mutation.
  40441. func withWxCard(node *WxCard) wxcardOption {
  40442. return func(m *WxCardMutation) {
  40443. m.oldValue = func(context.Context) (*WxCard, error) {
  40444. return node, nil
  40445. }
  40446. m.id = &node.ID
  40447. }
  40448. }
  40449. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40450. // executed in a transaction (ent.Tx), a transactional client is returned.
  40451. func (m WxCardMutation) Client() *Client {
  40452. client := &Client{config: m.config}
  40453. client.init()
  40454. return client
  40455. }
  40456. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40457. // it returns an error otherwise.
  40458. func (m WxCardMutation) Tx() (*Tx, error) {
  40459. if _, ok := m.driver.(*txDriver); !ok {
  40460. return nil, errors.New("ent: mutation is not running in a transaction")
  40461. }
  40462. tx := &Tx{config: m.config}
  40463. tx.init()
  40464. return tx, nil
  40465. }
  40466. // SetID sets the value of the id field. Note that this
  40467. // operation is only accepted on creation of WxCard entities.
  40468. func (m *WxCardMutation) SetID(id uint64) {
  40469. m.id = &id
  40470. }
  40471. // ID returns the ID value in the mutation. Note that the ID is only available
  40472. // if it was provided to the builder or after it was returned from the database.
  40473. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  40474. if m.id == nil {
  40475. return
  40476. }
  40477. return *m.id, true
  40478. }
  40479. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40480. // That means, if the mutation is applied within a transaction with an isolation level such
  40481. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40482. // or updated by the mutation.
  40483. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  40484. switch {
  40485. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40486. id, exists := m.ID()
  40487. if exists {
  40488. return []uint64{id}, nil
  40489. }
  40490. fallthrough
  40491. case m.op.Is(OpUpdate | OpDelete):
  40492. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  40493. default:
  40494. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40495. }
  40496. }
  40497. // SetCreatedAt sets the "created_at" field.
  40498. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  40499. m.created_at = &t
  40500. }
  40501. // CreatedAt returns the value of the "created_at" field in the mutation.
  40502. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  40503. v := m.created_at
  40504. if v == nil {
  40505. return
  40506. }
  40507. return *v, true
  40508. }
  40509. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  40510. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40512. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40513. if !m.op.Is(OpUpdateOne) {
  40514. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40515. }
  40516. if m.id == nil || m.oldValue == nil {
  40517. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40518. }
  40519. oldValue, err := m.oldValue(ctx)
  40520. if err != nil {
  40521. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40522. }
  40523. return oldValue.CreatedAt, nil
  40524. }
  40525. // ResetCreatedAt resets all changes to the "created_at" field.
  40526. func (m *WxCardMutation) ResetCreatedAt() {
  40527. m.created_at = nil
  40528. }
  40529. // SetUpdatedAt sets the "updated_at" field.
  40530. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  40531. m.updated_at = &t
  40532. }
  40533. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40534. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  40535. v := m.updated_at
  40536. if v == nil {
  40537. return
  40538. }
  40539. return *v, true
  40540. }
  40541. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  40542. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40544. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40545. if !m.op.Is(OpUpdateOne) {
  40546. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40547. }
  40548. if m.id == nil || m.oldValue == nil {
  40549. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40550. }
  40551. oldValue, err := m.oldValue(ctx)
  40552. if err != nil {
  40553. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40554. }
  40555. return oldValue.UpdatedAt, nil
  40556. }
  40557. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40558. func (m *WxCardMutation) ResetUpdatedAt() {
  40559. m.updated_at = nil
  40560. }
  40561. // SetDeletedAt sets the "deleted_at" field.
  40562. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  40563. m.deleted_at = &t
  40564. }
  40565. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40566. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  40567. v := m.deleted_at
  40568. if v == nil {
  40569. return
  40570. }
  40571. return *v, true
  40572. }
  40573. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  40574. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40576. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40577. if !m.op.Is(OpUpdateOne) {
  40578. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40579. }
  40580. if m.id == nil || m.oldValue == nil {
  40581. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40582. }
  40583. oldValue, err := m.oldValue(ctx)
  40584. if err != nil {
  40585. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40586. }
  40587. return oldValue.DeletedAt, nil
  40588. }
  40589. // ClearDeletedAt clears the value of the "deleted_at" field.
  40590. func (m *WxCardMutation) ClearDeletedAt() {
  40591. m.deleted_at = nil
  40592. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  40593. }
  40594. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40595. func (m *WxCardMutation) DeletedAtCleared() bool {
  40596. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  40597. return ok
  40598. }
  40599. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40600. func (m *WxCardMutation) ResetDeletedAt() {
  40601. m.deleted_at = nil
  40602. delete(m.clearedFields, wxcard.FieldDeletedAt)
  40603. }
  40604. // SetUserID sets the "user_id" field.
  40605. func (m *WxCardMutation) SetUserID(u uint64) {
  40606. m.user_id = &u
  40607. m.adduser_id = nil
  40608. }
  40609. // UserID returns the value of the "user_id" field in the mutation.
  40610. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  40611. v := m.user_id
  40612. if v == nil {
  40613. return
  40614. }
  40615. return *v, true
  40616. }
  40617. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  40618. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40620. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  40621. if !m.op.Is(OpUpdateOne) {
  40622. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  40623. }
  40624. if m.id == nil || m.oldValue == nil {
  40625. return v, errors.New("OldUserID requires an ID field in the mutation")
  40626. }
  40627. oldValue, err := m.oldValue(ctx)
  40628. if err != nil {
  40629. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  40630. }
  40631. return oldValue.UserID, nil
  40632. }
  40633. // AddUserID adds u to the "user_id" field.
  40634. func (m *WxCardMutation) AddUserID(u int64) {
  40635. if m.adduser_id != nil {
  40636. *m.adduser_id += u
  40637. } else {
  40638. m.adduser_id = &u
  40639. }
  40640. }
  40641. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  40642. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  40643. v := m.adduser_id
  40644. if v == nil {
  40645. return
  40646. }
  40647. return *v, true
  40648. }
  40649. // ClearUserID clears the value of the "user_id" field.
  40650. func (m *WxCardMutation) ClearUserID() {
  40651. m.user_id = nil
  40652. m.adduser_id = nil
  40653. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  40654. }
  40655. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  40656. func (m *WxCardMutation) UserIDCleared() bool {
  40657. _, ok := m.clearedFields[wxcard.FieldUserID]
  40658. return ok
  40659. }
  40660. // ResetUserID resets all changes to the "user_id" field.
  40661. func (m *WxCardMutation) ResetUserID() {
  40662. m.user_id = nil
  40663. m.adduser_id = nil
  40664. delete(m.clearedFields, wxcard.FieldUserID)
  40665. }
  40666. // SetWxUserID sets the "wx_user_id" field.
  40667. func (m *WxCardMutation) SetWxUserID(u uint64) {
  40668. m.wx_user_id = &u
  40669. m.addwx_user_id = nil
  40670. }
  40671. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  40672. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  40673. v := m.wx_user_id
  40674. if v == nil {
  40675. return
  40676. }
  40677. return *v, true
  40678. }
  40679. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  40680. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40682. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  40683. if !m.op.Is(OpUpdateOne) {
  40684. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  40685. }
  40686. if m.id == nil || m.oldValue == nil {
  40687. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  40688. }
  40689. oldValue, err := m.oldValue(ctx)
  40690. if err != nil {
  40691. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  40692. }
  40693. return oldValue.WxUserID, nil
  40694. }
  40695. // AddWxUserID adds u to the "wx_user_id" field.
  40696. func (m *WxCardMutation) AddWxUserID(u int64) {
  40697. if m.addwx_user_id != nil {
  40698. *m.addwx_user_id += u
  40699. } else {
  40700. m.addwx_user_id = &u
  40701. }
  40702. }
  40703. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  40704. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  40705. v := m.addwx_user_id
  40706. if v == nil {
  40707. return
  40708. }
  40709. return *v, true
  40710. }
  40711. // ClearWxUserID clears the value of the "wx_user_id" field.
  40712. func (m *WxCardMutation) ClearWxUserID() {
  40713. m.wx_user_id = nil
  40714. m.addwx_user_id = nil
  40715. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  40716. }
  40717. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  40718. func (m *WxCardMutation) WxUserIDCleared() bool {
  40719. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  40720. return ok
  40721. }
  40722. // ResetWxUserID resets all changes to the "wx_user_id" field.
  40723. func (m *WxCardMutation) ResetWxUserID() {
  40724. m.wx_user_id = nil
  40725. m.addwx_user_id = nil
  40726. delete(m.clearedFields, wxcard.FieldWxUserID)
  40727. }
  40728. // SetAvatar sets the "avatar" field.
  40729. func (m *WxCardMutation) SetAvatar(s string) {
  40730. m.avatar = &s
  40731. }
  40732. // Avatar returns the value of the "avatar" field in the mutation.
  40733. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  40734. v := m.avatar
  40735. if v == nil {
  40736. return
  40737. }
  40738. return *v, true
  40739. }
  40740. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  40741. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40743. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40744. if !m.op.Is(OpUpdateOne) {
  40745. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40746. }
  40747. if m.id == nil || m.oldValue == nil {
  40748. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40749. }
  40750. oldValue, err := m.oldValue(ctx)
  40751. if err != nil {
  40752. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40753. }
  40754. return oldValue.Avatar, nil
  40755. }
  40756. // ResetAvatar resets all changes to the "avatar" field.
  40757. func (m *WxCardMutation) ResetAvatar() {
  40758. m.avatar = nil
  40759. }
  40760. // SetLogo sets the "logo" field.
  40761. func (m *WxCardMutation) SetLogo(s string) {
  40762. m.logo = &s
  40763. }
  40764. // Logo returns the value of the "logo" field in the mutation.
  40765. func (m *WxCardMutation) Logo() (r string, exists bool) {
  40766. v := m.logo
  40767. if v == nil {
  40768. return
  40769. }
  40770. return *v, true
  40771. }
  40772. // OldLogo returns the old "logo" field's value of the WxCard entity.
  40773. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40775. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  40776. if !m.op.Is(OpUpdateOne) {
  40777. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  40778. }
  40779. if m.id == nil || m.oldValue == nil {
  40780. return v, errors.New("OldLogo requires an ID field in the mutation")
  40781. }
  40782. oldValue, err := m.oldValue(ctx)
  40783. if err != nil {
  40784. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  40785. }
  40786. return oldValue.Logo, nil
  40787. }
  40788. // ResetLogo resets all changes to the "logo" field.
  40789. func (m *WxCardMutation) ResetLogo() {
  40790. m.logo = nil
  40791. }
  40792. // SetName sets the "name" field.
  40793. func (m *WxCardMutation) SetName(s string) {
  40794. m.name = &s
  40795. }
  40796. // Name returns the value of the "name" field in the mutation.
  40797. func (m *WxCardMutation) Name() (r string, exists bool) {
  40798. v := m.name
  40799. if v == nil {
  40800. return
  40801. }
  40802. return *v, true
  40803. }
  40804. // OldName returns the old "name" field's value of the WxCard entity.
  40805. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40807. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  40808. if !m.op.Is(OpUpdateOne) {
  40809. return v, errors.New("OldName is only allowed on UpdateOne operations")
  40810. }
  40811. if m.id == nil || m.oldValue == nil {
  40812. return v, errors.New("OldName requires an ID field in the mutation")
  40813. }
  40814. oldValue, err := m.oldValue(ctx)
  40815. if err != nil {
  40816. return v, fmt.Errorf("querying old value for OldName: %w", err)
  40817. }
  40818. return oldValue.Name, nil
  40819. }
  40820. // ResetName resets all changes to the "name" field.
  40821. func (m *WxCardMutation) ResetName() {
  40822. m.name = nil
  40823. }
  40824. // SetCompany sets the "company" field.
  40825. func (m *WxCardMutation) SetCompany(s string) {
  40826. m.company = &s
  40827. }
  40828. // Company returns the value of the "company" field in the mutation.
  40829. func (m *WxCardMutation) Company() (r string, exists bool) {
  40830. v := m.company
  40831. if v == nil {
  40832. return
  40833. }
  40834. return *v, true
  40835. }
  40836. // OldCompany returns the old "company" field's value of the WxCard entity.
  40837. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40839. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  40840. if !m.op.Is(OpUpdateOne) {
  40841. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40842. }
  40843. if m.id == nil || m.oldValue == nil {
  40844. return v, errors.New("OldCompany requires an ID field in the mutation")
  40845. }
  40846. oldValue, err := m.oldValue(ctx)
  40847. if err != nil {
  40848. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40849. }
  40850. return oldValue.Company, nil
  40851. }
  40852. // ResetCompany resets all changes to the "company" field.
  40853. func (m *WxCardMutation) ResetCompany() {
  40854. m.company = nil
  40855. }
  40856. // SetAddress sets the "address" field.
  40857. func (m *WxCardMutation) SetAddress(s string) {
  40858. m.address = &s
  40859. }
  40860. // Address returns the value of the "address" field in the mutation.
  40861. func (m *WxCardMutation) Address() (r string, exists bool) {
  40862. v := m.address
  40863. if v == nil {
  40864. return
  40865. }
  40866. return *v, true
  40867. }
  40868. // OldAddress returns the old "address" field's value of the WxCard entity.
  40869. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40871. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  40872. if !m.op.Is(OpUpdateOne) {
  40873. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  40874. }
  40875. if m.id == nil || m.oldValue == nil {
  40876. return v, errors.New("OldAddress requires an ID field in the mutation")
  40877. }
  40878. oldValue, err := m.oldValue(ctx)
  40879. if err != nil {
  40880. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  40881. }
  40882. return oldValue.Address, nil
  40883. }
  40884. // ResetAddress resets all changes to the "address" field.
  40885. func (m *WxCardMutation) ResetAddress() {
  40886. m.address = nil
  40887. }
  40888. // SetPhone sets the "phone" field.
  40889. func (m *WxCardMutation) SetPhone(s string) {
  40890. m.phone = &s
  40891. }
  40892. // Phone returns the value of the "phone" field in the mutation.
  40893. func (m *WxCardMutation) Phone() (r string, exists bool) {
  40894. v := m.phone
  40895. if v == nil {
  40896. return
  40897. }
  40898. return *v, true
  40899. }
  40900. // OldPhone returns the old "phone" field's value of the WxCard entity.
  40901. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40903. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  40904. if !m.op.Is(OpUpdateOne) {
  40905. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40906. }
  40907. if m.id == nil || m.oldValue == nil {
  40908. return v, errors.New("OldPhone requires an ID field in the mutation")
  40909. }
  40910. oldValue, err := m.oldValue(ctx)
  40911. if err != nil {
  40912. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40913. }
  40914. return oldValue.Phone, nil
  40915. }
  40916. // ResetPhone resets all changes to the "phone" field.
  40917. func (m *WxCardMutation) ResetPhone() {
  40918. m.phone = nil
  40919. }
  40920. // SetOfficialAccount sets the "official_account" field.
  40921. func (m *WxCardMutation) SetOfficialAccount(s string) {
  40922. m.official_account = &s
  40923. }
  40924. // OfficialAccount returns the value of the "official_account" field in the mutation.
  40925. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  40926. v := m.official_account
  40927. if v == nil {
  40928. return
  40929. }
  40930. return *v, true
  40931. }
  40932. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  40933. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40935. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  40936. if !m.op.Is(OpUpdateOne) {
  40937. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  40938. }
  40939. if m.id == nil || m.oldValue == nil {
  40940. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  40941. }
  40942. oldValue, err := m.oldValue(ctx)
  40943. if err != nil {
  40944. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  40945. }
  40946. return oldValue.OfficialAccount, nil
  40947. }
  40948. // ResetOfficialAccount resets all changes to the "official_account" field.
  40949. func (m *WxCardMutation) ResetOfficialAccount() {
  40950. m.official_account = nil
  40951. }
  40952. // SetWechatAccount sets the "wechat_account" field.
  40953. func (m *WxCardMutation) SetWechatAccount(s string) {
  40954. m.wechat_account = &s
  40955. }
  40956. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  40957. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  40958. v := m.wechat_account
  40959. if v == nil {
  40960. return
  40961. }
  40962. return *v, true
  40963. }
  40964. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  40965. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40967. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  40968. if !m.op.Is(OpUpdateOne) {
  40969. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  40970. }
  40971. if m.id == nil || m.oldValue == nil {
  40972. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  40973. }
  40974. oldValue, err := m.oldValue(ctx)
  40975. if err != nil {
  40976. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  40977. }
  40978. return oldValue.WechatAccount, nil
  40979. }
  40980. // ResetWechatAccount resets all changes to the "wechat_account" field.
  40981. func (m *WxCardMutation) ResetWechatAccount() {
  40982. m.wechat_account = nil
  40983. }
  40984. // SetEmail sets the "email" field.
  40985. func (m *WxCardMutation) SetEmail(s string) {
  40986. m.email = &s
  40987. }
  40988. // Email returns the value of the "email" field in the mutation.
  40989. func (m *WxCardMutation) Email() (r string, exists bool) {
  40990. v := m.email
  40991. if v == nil {
  40992. return
  40993. }
  40994. return *v, true
  40995. }
  40996. // OldEmail returns the old "email" field's value of the WxCard entity.
  40997. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40999. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  41000. if !m.op.Is(OpUpdateOne) {
  41001. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  41002. }
  41003. if m.id == nil || m.oldValue == nil {
  41004. return v, errors.New("OldEmail requires an ID field in the mutation")
  41005. }
  41006. oldValue, err := m.oldValue(ctx)
  41007. if err != nil {
  41008. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  41009. }
  41010. return oldValue.Email, nil
  41011. }
  41012. // ClearEmail clears the value of the "email" field.
  41013. func (m *WxCardMutation) ClearEmail() {
  41014. m.email = nil
  41015. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  41016. }
  41017. // EmailCleared returns if the "email" field was cleared in this mutation.
  41018. func (m *WxCardMutation) EmailCleared() bool {
  41019. _, ok := m.clearedFields[wxcard.FieldEmail]
  41020. return ok
  41021. }
  41022. // ResetEmail resets all changes to the "email" field.
  41023. func (m *WxCardMutation) ResetEmail() {
  41024. m.email = nil
  41025. delete(m.clearedFields, wxcard.FieldEmail)
  41026. }
  41027. // SetAPIBase sets the "api_base" field.
  41028. func (m *WxCardMutation) SetAPIBase(s string) {
  41029. m.api_base = &s
  41030. }
  41031. // APIBase returns the value of the "api_base" field in the mutation.
  41032. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  41033. v := m.api_base
  41034. if v == nil {
  41035. return
  41036. }
  41037. return *v, true
  41038. }
  41039. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  41040. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41042. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41043. if !m.op.Is(OpUpdateOne) {
  41044. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41045. }
  41046. if m.id == nil || m.oldValue == nil {
  41047. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41048. }
  41049. oldValue, err := m.oldValue(ctx)
  41050. if err != nil {
  41051. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41052. }
  41053. return oldValue.APIBase, nil
  41054. }
  41055. // ClearAPIBase clears the value of the "api_base" field.
  41056. func (m *WxCardMutation) ClearAPIBase() {
  41057. m.api_base = nil
  41058. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  41059. }
  41060. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41061. func (m *WxCardMutation) APIBaseCleared() bool {
  41062. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  41063. return ok
  41064. }
  41065. // ResetAPIBase resets all changes to the "api_base" field.
  41066. func (m *WxCardMutation) ResetAPIBase() {
  41067. m.api_base = nil
  41068. delete(m.clearedFields, wxcard.FieldAPIBase)
  41069. }
  41070. // SetAPIKey sets the "api_key" field.
  41071. func (m *WxCardMutation) SetAPIKey(s string) {
  41072. m.api_key = &s
  41073. }
  41074. // APIKey returns the value of the "api_key" field in the mutation.
  41075. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  41076. v := m.api_key
  41077. if v == nil {
  41078. return
  41079. }
  41080. return *v, true
  41081. }
  41082. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  41083. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41085. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41086. if !m.op.Is(OpUpdateOne) {
  41087. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41088. }
  41089. if m.id == nil || m.oldValue == nil {
  41090. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41091. }
  41092. oldValue, err := m.oldValue(ctx)
  41093. if err != nil {
  41094. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41095. }
  41096. return oldValue.APIKey, nil
  41097. }
  41098. // ClearAPIKey clears the value of the "api_key" field.
  41099. func (m *WxCardMutation) ClearAPIKey() {
  41100. m.api_key = nil
  41101. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  41102. }
  41103. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41104. func (m *WxCardMutation) APIKeyCleared() bool {
  41105. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  41106. return ok
  41107. }
  41108. // ResetAPIKey resets all changes to the "api_key" field.
  41109. func (m *WxCardMutation) ResetAPIKey() {
  41110. m.api_key = nil
  41111. delete(m.clearedFields, wxcard.FieldAPIKey)
  41112. }
  41113. // SetAiInfo sets the "ai_info" field.
  41114. func (m *WxCardMutation) SetAiInfo(s string) {
  41115. m.ai_info = &s
  41116. }
  41117. // AiInfo returns the value of the "ai_info" field in the mutation.
  41118. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  41119. v := m.ai_info
  41120. if v == nil {
  41121. return
  41122. }
  41123. return *v, true
  41124. }
  41125. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  41126. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41128. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  41129. if !m.op.Is(OpUpdateOne) {
  41130. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  41131. }
  41132. if m.id == nil || m.oldValue == nil {
  41133. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  41134. }
  41135. oldValue, err := m.oldValue(ctx)
  41136. if err != nil {
  41137. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  41138. }
  41139. return oldValue.AiInfo, nil
  41140. }
  41141. // ClearAiInfo clears the value of the "ai_info" field.
  41142. func (m *WxCardMutation) ClearAiInfo() {
  41143. m.ai_info = nil
  41144. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  41145. }
  41146. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  41147. func (m *WxCardMutation) AiInfoCleared() bool {
  41148. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  41149. return ok
  41150. }
  41151. // ResetAiInfo resets all changes to the "ai_info" field.
  41152. func (m *WxCardMutation) ResetAiInfo() {
  41153. m.ai_info = nil
  41154. delete(m.clearedFields, wxcard.FieldAiInfo)
  41155. }
  41156. // SetIntro sets the "intro" field.
  41157. func (m *WxCardMutation) SetIntro(s string) {
  41158. m.intro = &s
  41159. }
  41160. // Intro returns the value of the "intro" field in the mutation.
  41161. func (m *WxCardMutation) Intro() (r string, exists bool) {
  41162. v := m.intro
  41163. if v == nil {
  41164. return
  41165. }
  41166. return *v, true
  41167. }
  41168. // OldIntro returns the old "intro" field's value of the WxCard entity.
  41169. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41171. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  41172. if !m.op.Is(OpUpdateOne) {
  41173. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  41174. }
  41175. if m.id == nil || m.oldValue == nil {
  41176. return v, errors.New("OldIntro requires an ID field in the mutation")
  41177. }
  41178. oldValue, err := m.oldValue(ctx)
  41179. if err != nil {
  41180. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  41181. }
  41182. return oldValue.Intro, nil
  41183. }
  41184. // ClearIntro clears the value of the "intro" field.
  41185. func (m *WxCardMutation) ClearIntro() {
  41186. m.intro = nil
  41187. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  41188. }
  41189. // IntroCleared returns if the "intro" field was cleared in this mutation.
  41190. func (m *WxCardMutation) IntroCleared() bool {
  41191. _, ok := m.clearedFields[wxcard.FieldIntro]
  41192. return ok
  41193. }
  41194. // ResetIntro resets all changes to the "intro" field.
  41195. func (m *WxCardMutation) ResetIntro() {
  41196. m.intro = nil
  41197. delete(m.clearedFields, wxcard.FieldIntro)
  41198. }
  41199. // Where appends a list predicates to the WxCardMutation builder.
  41200. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  41201. m.predicates = append(m.predicates, ps...)
  41202. }
  41203. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  41204. // users can use type-assertion to append predicates that do not depend on any generated package.
  41205. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  41206. p := make([]predicate.WxCard, len(ps))
  41207. for i := range ps {
  41208. p[i] = ps[i]
  41209. }
  41210. m.Where(p...)
  41211. }
  41212. // Op returns the operation name.
  41213. func (m *WxCardMutation) Op() Op {
  41214. return m.op
  41215. }
  41216. // SetOp allows setting the mutation operation.
  41217. func (m *WxCardMutation) SetOp(op Op) {
  41218. m.op = op
  41219. }
  41220. // Type returns the node type of this mutation (WxCard).
  41221. func (m *WxCardMutation) Type() string {
  41222. return m.typ
  41223. }
  41224. // Fields returns all fields that were changed during this mutation. Note that in
  41225. // order to get all numeric fields that were incremented/decremented, call
  41226. // AddedFields().
  41227. func (m *WxCardMutation) Fields() []string {
  41228. fields := make([]string, 0, 18)
  41229. if m.created_at != nil {
  41230. fields = append(fields, wxcard.FieldCreatedAt)
  41231. }
  41232. if m.updated_at != nil {
  41233. fields = append(fields, wxcard.FieldUpdatedAt)
  41234. }
  41235. if m.deleted_at != nil {
  41236. fields = append(fields, wxcard.FieldDeletedAt)
  41237. }
  41238. if m.user_id != nil {
  41239. fields = append(fields, wxcard.FieldUserID)
  41240. }
  41241. if m.wx_user_id != nil {
  41242. fields = append(fields, wxcard.FieldWxUserID)
  41243. }
  41244. if m.avatar != nil {
  41245. fields = append(fields, wxcard.FieldAvatar)
  41246. }
  41247. if m.logo != nil {
  41248. fields = append(fields, wxcard.FieldLogo)
  41249. }
  41250. if m.name != nil {
  41251. fields = append(fields, wxcard.FieldName)
  41252. }
  41253. if m.company != nil {
  41254. fields = append(fields, wxcard.FieldCompany)
  41255. }
  41256. if m.address != nil {
  41257. fields = append(fields, wxcard.FieldAddress)
  41258. }
  41259. if m.phone != nil {
  41260. fields = append(fields, wxcard.FieldPhone)
  41261. }
  41262. if m.official_account != nil {
  41263. fields = append(fields, wxcard.FieldOfficialAccount)
  41264. }
  41265. if m.wechat_account != nil {
  41266. fields = append(fields, wxcard.FieldWechatAccount)
  41267. }
  41268. if m.email != nil {
  41269. fields = append(fields, wxcard.FieldEmail)
  41270. }
  41271. if m.api_base != nil {
  41272. fields = append(fields, wxcard.FieldAPIBase)
  41273. }
  41274. if m.api_key != nil {
  41275. fields = append(fields, wxcard.FieldAPIKey)
  41276. }
  41277. if m.ai_info != nil {
  41278. fields = append(fields, wxcard.FieldAiInfo)
  41279. }
  41280. if m.intro != nil {
  41281. fields = append(fields, wxcard.FieldIntro)
  41282. }
  41283. return fields
  41284. }
  41285. // Field returns the value of a field with the given name. The second boolean
  41286. // return value indicates that this field was not set, or was not defined in the
  41287. // schema.
  41288. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  41289. switch name {
  41290. case wxcard.FieldCreatedAt:
  41291. return m.CreatedAt()
  41292. case wxcard.FieldUpdatedAt:
  41293. return m.UpdatedAt()
  41294. case wxcard.FieldDeletedAt:
  41295. return m.DeletedAt()
  41296. case wxcard.FieldUserID:
  41297. return m.UserID()
  41298. case wxcard.FieldWxUserID:
  41299. return m.WxUserID()
  41300. case wxcard.FieldAvatar:
  41301. return m.Avatar()
  41302. case wxcard.FieldLogo:
  41303. return m.Logo()
  41304. case wxcard.FieldName:
  41305. return m.Name()
  41306. case wxcard.FieldCompany:
  41307. return m.Company()
  41308. case wxcard.FieldAddress:
  41309. return m.Address()
  41310. case wxcard.FieldPhone:
  41311. return m.Phone()
  41312. case wxcard.FieldOfficialAccount:
  41313. return m.OfficialAccount()
  41314. case wxcard.FieldWechatAccount:
  41315. return m.WechatAccount()
  41316. case wxcard.FieldEmail:
  41317. return m.Email()
  41318. case wxcard.FieldAPIBase:
  41319. return m.APIBase()
  41320. case wxcard.FieldAPIKey:
  41321. return m.APIKey()
  41322. case wxcard.FieldAiInfo:
  41323. return m.AiInfo()
  41324. case wxcard.FieldIntro:
  41325. return m.Intro()
  41326. }
  41327. return nil, false
  41328. }
  41329. // OldField returns the old value of the field from the database. An error is
  41330. // returned if the mutation operation is not UpdateOne, or the query to the
  41331. // database failed.
  41332. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41333. switch name {
  41334. case wxcard.FieldCreatedAt:
  41335. return m.OldCreatedAt(ctx)
  41336. case wxcard.FieldUpdatedAt:
  41337. return m.OldUpdatedAt(ctx)
  41338. case wxcard.FieldDeletedAt:
  41339. return m.OldDeletedAt(ctx)
  41340. case wxcard.FieldUserID:
  41341. return m.OldUserID(ctx)
  41342. case wxcard.FieldWxUserID:
  41343. return m.OldWxUserID(ctx)
  41344. case wxcard.FieldAvatar:
  41345. return m.OldAvatar(ctx)
  41346. case wxcard.FieldLogo:
  41347. return m.OldLogo(ctx)
  41348. case wxcard.FieldName:
  41349. return m.OldName(ctx)
  41350. case wxcard.FieldCompany:
  41351. return m.OldCompany(ctx)
  41352. case wxcard.FieldAddress:
  41353. return m.OldAddress(ctx)
  41354. case wxcard.FieldPhone:
  41355. return m.OldPhone(ctx)
  41356. case wxcard.FieldOfficialAccount:
  41357. return m.OldOfficialAccount(ctx)
  41358. case wxcard.FieldWechatAccount:
  41359. return m.OldWechatAccount(ctx)
  41360. case wxcard.FieldEmail:
  41361. return m.OldEmail(ctx)
  41362. case wxcard.FieldAPIBase:
  41363. return m.OldAPIBase(ctx)
  41364. case wxcard.FieldAPIKey:
  41365. return m.OldAPIKey(ctx)
  41366. case wxcard.FieldAiInfo:
  41367. return m.OldAiInfo(ctx)
  41368. case wxcard.FieldIntro:
  41369. return m.OldIntro(ctx)
  41370. }
  41371. return nil, fmt.Errorf("unknown WxCard field %s", name)
  41372. }
  41373. // SetField sets the value of a field with the given name. It returns an error if
  41374. // the field is not defined in the schema, or if the type mismatched the field
  41375. // type.
  41376. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  41377. switch name {
  41378. case wxcard.FieldCreatedAt:
  41379. v, ok := value.(time.Time)
  41380. if !ok {
  41381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41382. }
  41383. m.SetCreatedAt(v)
  41384. return nil
  41385. case wxcard.FieldUpdatedAt:
  41386. v, ok := value.(time.Time)
  41387. if !ok {
  41388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41389. }
  41390. m.SetUpdatedAt(v)
  41391. return nil
  41392. case wxcard.FieldDeletedAt:
  41393. v, ok := value.(time.Time)
  41394. if !ok {
  41395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41396. }
  41397. m.SetDeletedAt(v)
  41398. return nil
  41399. case wxcard.FieldUserID:
  41400. v, ok := value.(uint64)
  41401. if !ok {
  41402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41403. }
  41404. m.SetUserID(v)
  41405. return nil
  41406. case wxcard.FieldWxUserID:
  41407. v, ok := value.(uint64)
  41408. if !ok {
  41409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41410. }
  41411. m.SetWxUserID(v)
  41412. return nil
  41413. case wxcard.FieldAvatar:
  41414. v, ok := value.(string)
  41415. if !ok {
  41416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41417. }
  41418. m.SetAvatar(v)
  41419. return nil
  41420. case wxcard.FieldLogo:
  41421. v, ok := value.(string)
  41422. if !ok {
  41423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41424. }
  41425. m.SetLogo(v)
  41426. return nil
  41427. case wxcard.FieldName:
  41428. v, ok := value.(string)
  41429. if !ok {
  41430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41431. }
  41432. m.SetName(v)
  41433. return nil
  41434. case wxcard.FieldCompany:
  41435. v, ok := value.(string)
  41436. if !ok {
  41437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41438. }
  41439. m.SetCompany(v)
  41440. return nil
  41441. case wxcard.FieldAddress:
  41442. v, ok := value.(string)
  41443. if !ok {
  41444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41445. }
  41446. m.SetAddress(v)
  41447. return nil
  41448. case wxcard.FieldPhone:
  41449. v, ok := value.(string)
  41450. if !ok {
  41451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41452. }
  41453. m.SetPhone(v)
  41454. return nil
  41455. case wxcard.FieldOfficialAccount:
  41456. v, ok := value.(string)
  41457. if !ok {
  41458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41459. }
  41460. m.SetOfficialAccount(v)
  41461. return nil
  41462. case wxcard.FieldWechatAccount:
  41463. v, ok := value.(string)
  41464. if !ok {
  41465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41466. }
  41467. m.SetWechatAccount(v)
  41468. return nil
  41469. case wxcard.FieldEmail:
  41470. v, ok := value.(string)
  41471. if !ok {
  41472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41473. }
  41474. m.SetEmail(v)
  41475. return nil
  41476. case wxcard.FieldAPIBase:
  41477. v, ok := value.(string)
  41478. if !ok {
  41479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41480. }
  41481. m.SetAPIBase(v)
  41482. return nil
  41483. case wxcard.FieldAPIKey:
  41484. v, ok := value.(string)
  41485. if !ok {
  41486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41487. }
  41488. m.SetAPIKey(v)
  41489. return nil
  41490. case wxcard.FieldAiInfo:
  41491. v, ok := value.(string)
  41492. if !ok {
  41493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41494. }
  41495. m.SetAiInfo(v)
  41496. return nil
  41497. case wxcard.FieldIntro:
  41498. v, ok := value.(string)
  41499. if !ok {
  41500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41501. }
  41502. m.SetIntro(v)
  41503. return nil
  41504. }
  41505. return fmt.Errorf("unknown WxCard field %s", name)
  41506. }
  41507. // AddedFields returns all numeric fields that were incremented/decremented during
  41508. // this mutation.
  41509. func (m *WxCardMutation) AddedFields() []string {
  41510. var fields []string
  41511. if m.adduser_id != nil {
  41512. fields = append(fields, wxcard.FieldUserID)
  41513. }
  41514. if m.addwx_user_id != nil {
  41515. fields = append(fields, wxcard.FieldWxUserID)
  41516. }
  41517. return fields
  41518. }
  41519. // AddedField returns the numeric value that was incremented/decremented on a field
  41520. // with the given name. The second boolean return value indicates that this field
  41521. // was not set, or was not defined in the schema.
  41522. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  41523. switch name {
  41524. case wxcard.FieldUserID:
  41525. return m.AddedUserID()
  41526. case wxcard.FieldWxUserID:
  41527. return m.AddedWxUserID()
  41528. }
  41529. return nil, false
  41530. }
  41531. // AddField adds the value to the field with the given name. It returns an error if
  41532. // the field is not defined in the schema, or if the type mismatched the field
  41533. // type.
  41534. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  41535. switch name {
  41536. case wxcard.FieldUserID:
  41537. v, ok := value.(int64)
  41538. if !ok {
  41539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41540. }
  41541. m.AddUserID(v)
  41542. return nil
  41543. case wxcard.FieldWxUserID:
  41544. v, ok := value.(int64)
  41545. if !ok {
  41546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41547. }
  41548. m.AddWxUserID(v)
  41549. return nil
  41550. }
  41551. return fmt.Errorf("unknown WxCard numeric field %s", name)
  41552. }
  41553. // ClearedFields returns all nullable fields that were cleared during this
  41554. // mutation.
  41555. func (m *WxCardMutation) ClearedFields() []string {
  41556. var fields []string
  41557. if m.FieldCleared(wxcard.FieldDeletedAt) {
  41558. fields = append(fields, wxcard.FieldDeletedAt)
  41559. }
  41560. if m.FieldCleared(wxcard.FieldUserID) {
  41561. fields = append(fields, wxcard.FieldUserID)
  41562. }
  41563. if m.FieldCleared(wxcard.FieldWxUserID) {
  41564. fields = append(fields, wxcard.FieldWxUserID)
  41565. }
  41566. if m.FieldCleared(wxcard.FieldEmail) {
  41567. fields = append(fields, wxcard.FieldEmail)
  41568. }
  41569. if m.FieldCleared(wxcard.FieldAPIBase) {
  41570. fields = append(fields, wxcard.FieldAPIBase)
  41571. }
  41572. if m.FieldCleared(wxcard.FieldAPIKey) {
  41573. fields = append(fields, wxcard.FieldAPIKey)
  41574. }
  41575. if m.FieldCleared(wxcard.FieldAiInfo) {
  41576. fields = append(fields, wxcard.FieldAiInfo)
  41577. }
  41578. if m.FieldCleared(wxcard.FieldIntro) {
  41579. fields = append(fields, wxcard.FieldIntro)
  41580. }
  41581. return fields
  41582. }
  41583. // FieldCleared returns a boolean indicating if a field with the given name was
  41584. // cleared in this mutation.
  41585. func (m *WxCardMutation) FieldCleared(name string) bool {
  41586. _, ok := m.clearedFields[name]
  41587. return ok
  41588. }
  41589. // ClearField clears the value of the field with the given name. It returns an
  41590. // error if the field is not defined in the schema.
  41591. func (m *WxCardMutation) ClearField(name string) error {
  41592. switch name {
  41593. case wxcard.FieldDeletedAt:
  41594. m.ClearDeletedAt()
  41595. return nil
  41596. case wxcard.FieldUserID:
  41597. m.ClearUserID()
  41598. return nil
  41599. case wxcard.FieldWxUserID:
  41600. m.ClearWxUserID()
  41601. return nil
  41602. case wxcard.FieldEmail:
  41603. m.ClearEmail()
  41604. return nil
  41605. case wxcard.FieldAPIBase:
  41606. m.ClearAPIBase()
  41607. return nil
  41608. case wxcard.FieldAPIKey:
  41609. m.ClearAPIKey()
  41610. return nil
  41611. case wxcard.FieldAiInfo:
  41612. m.ClearAiInfo()
  41613. return nil
  41614. case wxcard.FieldIntro:
  41615. m.ClearIntro()
  41616. return nil
  41617. }
  41618. return fmt.Errorf("unknown WxCard nullable field %s", name)
  41619. }
  41620. // ResetField resets all changes in the mutation for the field with the given name.
  41621. // It returns an error if the field is not defined in the schema.
  41622. func (m *WxCardMutation) ResetField(name string) error {
  41623. switch name {
  41624. case wxcard.FieldCreatedAt:
  41625. m.ResetCreatedAt()
  41626. return nil
  41627. case wxcard.FieldUpdatedAt:
  41628. m.ResetUpdatedAt()
  41629. return nil
  41630. case wxcard.FieldDeletedAt:
  41631. m.ResetDeletedAt()
  41632. return nil
  41633. case wxcard.FieldUserID:
  41634. m.ResetUserID()
  41635. return nil
  41636. case wxcard.FieldWxUserID:
  41637. m.ResetWxUserID()
  41638. return nil
  41639. case wxcard.FieldAvatar:
  41640. m.ResetAvatar()
  41641. return nil
  41642. case wxcard.FieldLogo:
  41643. m.ResetLogo()
  41644. return nil
  41645. case wxcard.FieldName:
  41646. m.ResetName()
  41647. return nil
  41648. case wxcard.FieldCompany:
  41649. m.ResetCompany()
  41650. return nil
  41651. case wxcard.FieldAddress:
  41652. m.ResetAddress()
  41653. return nil
  41654. case wxcard.FieldPhone:
  41655. m.ResetPhone()
  41656. return nil
  41657. case wxcard.FieldOfficialAccount:
  41658. m.ResetOfficialAccount()
  41659. return nil
  41660. case wxcard.FieldWechatAccount:
  41661. m.ResetWechatAccount()
  41662. return nil
  41663. case wxcard.FieldEmail:
  41664. m.ResetEmail()
  41665. return nil
  41666. case wxcard.FieldAPIBase:
  41667. m.ResetAPIBase()
  41668. return nil
  41669. case wxcard.FieldAPIKey:
  41670. m.ResetAPIKey()
  41671. return nil
  41672. case wxcard.FieldAiInfo:
  41673. m.ResetAiInfo()
  41674. return nil
  41675. case wxcard.FieldIntro:
  41676. m.ResetIntro()
  41677. return nil
  41678. }
  41679. return fmt.Errorf("unknown WxCard field %s", name)
  41680. }
  41681. // AddedEdges returns all edge names that were set/added in this mutation.
  41682. func (m *WxCardMutation) AddedEdges() []string {
  41683. edges := make([]string, 0, 0)
  41684. return edges
  41685. }
  41686. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41687. // name in this mutation.
  41688. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  41689. return nil
  41690. }
  41691. // RemovedEdges returns all edge names that were removed in this mutation.
  41692. func (m *WxCardMutation) RemovedEdges() []string {
  41693. edges := make([]string, 0, 0)
  41694. return edges
  41695. }
  41696. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41697. // the given name in this mutation.
  41698. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  41699. return nil
  41700. }
  41701. // ClearedEdges returns all edge names that were cleared in this mutation.
  41702. func (m *WxCardMutation) ClearedEdges() []string {
  41703. edges := make([]string, 0, 0)
  41704. return edges
  41705. }
  41706. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41707. // was cleared in this mutation.
  41708. func (m *WxCardMutation) EdgeCleared(name string) bool {
  41709. return false
  41710. }
  41711. // ClearEdge clears the value of the edge with the given name. It returns an error
  41712. // if that edge is not defined in the schema.
  41713. func (m *WxCardMutation) ClearEdge(name string) error {
  41714. return fmt.Errorf("unknown WxCard unique edge %s", name)
  41715. }
  41716. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41717. // It returns an error if the edge is not defined in the schema.
  41718. func (m *WxCardMutation) ResetEdge(name string) error {
  41719. return fmt.Errorf("unknown WxCard edge %s", name)
  41720. }
  41721. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  41722. type WxCardUserMutation struct {
  41723. config
  41724. op Op
  41725. typ string
  41726. id *uint64
  41727. created_at *time.Time
  41728. updated_at *time.Time
  41729. deleted_at *time.Time
  41730. wxid *string
  41731. account *string
  41732. avatar *string
  41733. nickname *string
  41734. remark *string
  41735. phone *string
  41736. open_id *string
  41737. union_id *string
  41738. session_key *string
  41739. is_vip *int
  41740. addis_vip *int
  41741. clearedFields map[string]struct{}
  41742. done bool
  41743. oldValue func(context.Context) (*WxCardUser, error)
  41744. predicates []predicate.WxCardUser
  41745. }
  41746. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  41747. // wxcarduserOption allows management of the mutation configuration using functional options.
  41748. type wxcarduserOption func(*WxCardUserMutation)
  41749. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  41750. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  41751. m := &WxCardUserMutation{
  41752. config: c,
  41753. op: op,
  41754. typ: TypeWxCardUser,
  41755. clearedFields: make(map[string]struct{}),
  41756. }
  41757. for _, opt := range opts {
  41758. opt(m)
  41759. }
  41760. return m
  41761. }
  41762. // withWxCardUserID sets the ID field of the mutation.
  41763. func withWxCardUserID(id uint64) wxcarduserOption {
  41764. return func(m *WxCardUserMutation) {
  41765. var (
  41766. err error
  41767. once sync.Once
  41768. value *WxCardUser
  41769. )
  41770. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  41771. once.Do(func() {
  41772. if m.done {
  41773. err = errors.New("querying old values post mutation is not allowed")
  41774. } else {
  41775. value, err = m.Client().WxCardUser.Get(ctx, id)
  41776. }
  41777. })
  41778. return value, err
  41779. }
  41780. m.id = &id
  41781. }
  41782. }
  41783. // withWxCardUser sets the old WxCardUser of the mutation.
  41784. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  41785. return func(m *WxCardUserMutation) {
  41786. m.oldValue = func(context.Context) (*WxCardUser, error) {
  41787. return node, nil
  41788. }
  41789. m.id = &node.ID
  41790. }
  41791. }
  41792. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41793. // executed in a transaction (ent.Tx), a transactional client is returned.
  41794. func (m WxCardUserMutation) Client() *Client {
  41795. client := &Client{config: m.config}
  41796. client.init()
  41797. return client
  41798. }
  41799. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41800. // it returns an error otherwise.
  41801. func (m WxCardUserMutation) Tx() (*Tx, error) {
  41802. if _, ok := m.driver.(*txDriver); !ok {
  41803. return nil, errors.New("ent: mutation is not running in a transaction")
  41804. }
  41805. tx := &Tx{config: m.config}
  41806. tx.init()
  41807. return tx, nil
  41808. }
  41809. // SetID sets the value of the id field. Note that this
  41810. // operation is only accepted on creation of WxCardUser entities.
  41811. func (m *WxCardUserMutation) SetID(id uint64) {
  41812. m.id = &id
  41813. }
  41814. // ID returns the ID value in the mutation. Note that the ID is only available
  41815. // if it was provided to the builder or after it was returned from the database.
  41816. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  41817. if m.id == nil {
  41818. return
  41819. }
  41820. return *m.id, true
  41821. }
  41822. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41823. // That means, if the mutation is applied within a transaction with an isolation level such
  41824. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41825. // or updated by the mutation.
  41826. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  41827. switch {
  41828. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41829. id, exists := m.ID()
  41830. if exists {
  41831. return []uint64{id}, nil
  41832. }
  41833. fallthrough
  41834. case m.op.Is(OpUpdate | OpDelete):
  41835. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  41836. default:
  41837. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41838. }
  41839. }
  41840. // SetCreatedAt sets the "created_at" field.
  41841. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  41842. m.created_at = &t
  41843. }
  41844. // CreatedAt returns the value of the "created_at" field in the mutation.
  41845. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  41846. v := m.created_at
  41847. if v == nil {
  41848. return
  41849. }
  41850. return *v, true
  41851. }
  41852. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  41853. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41855. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41856. if !m.op.Is(OpUpdateOne) {
  41857. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41858. }
  41859. if m.id == nil || m.oldValue == nil {
  41860. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41861. }
  41862. oldValue, err := m.oldValue(ctx)
  41863. if err != nil {
  41864. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41865. }
  41866. return oldValue.CreatedAt, nil
  41867. }
  41868. // ResetCreatedAt resets all changes to the "created_at" field.
  41869. func (m *WxCardUserMutation) ResetCreatedAt() {
  41870. m.created_at = nil
  41871. }
  41872. // SetUpdatedAt sets the "updated_at" field.
  41873. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  41874. m.updated_at = &t
  41875. }
  41876. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41877. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  41878. v := m.updated_at
  41879. if v == nil {
  41880. return
  41881. }
  41882. return *v, true
  41883. }
  41884. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  41885. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41887. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41888. if !m.op.Is(OpUpdateOne) {
  41889. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41890. }
  41891. if m.id == nil || m.oldValue == nil {
  41892. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41893. }
  41894. oldValue, err := m.oldValue(ctx)
  41895. if err != nil {
  41896. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41897. }
  41898. return oldValue.UpdatedAt, nil
  41899. }
  41900. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41901. func (m *WxCardUserMutation) ResetUpdatedAt() {
  41902. m.updated_at = nil
  41903. }
  41904. // SetDeletedAt sets the "deleted_at" field.
  41905. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  41906. m.deleted_at = &t
  41907. }
  41908. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41909. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  41910. v := m.deleted_at
  41911. if v == nil {
  41912. return
  41913. }
  41914. return *v, true
  41915. }
  41916. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  41917. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41919. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41920. if !m.op.Is(OpUpdateOne) {
  41921. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41922. }
  41923. if m.id == nil || m.oldValue == nil {
  41924. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41925. }
  41926. oldValue, err := m.oldValue(ctx)
  41927. if err != nil {
  41928. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41929. }
  41930. return oldValue.DeletedAt, nil
  41931. }
  41932. // ClearDeletedAt clears the value of the "deleted_at" field.
  41933. func (m *WxCardUserMutation) ClearDeletedAt() {
  41934. m.deleted_at = nil
  41935. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  41936. }
  41937. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41938. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  41939. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  41940. return ok
  41941. }
  41942. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41943. func (m *WxCardUserMutation) ResetDeletedAt() {
  41944. m.deleted_at = nil
  41945. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  41946. }
  41947. // SetWxid sets the "wxid" field.
  41948. func (m *WxCardUserMutation) SetWxid(s string) {
  41949. m.wxid = &s
  41950. }
  41951. // Wxid returns the value of the "wxid" field in the mutation.
  41952. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  41953. v := m.wxid
  41954. if v == nil {
  41955. return
  41956. }
  41957. return *v, true
  41958. }
  41959. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  41960. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41962. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  41963. if !m.op.Is(OpUpdateOne) {
  41964. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41965. }
  41966. if m.id == nil || m.oldValue == nil {
  41967. return v, errors.New("OldWxid requires an ID field in the mutation")
  41968. }
  41969. oldValue, err := m.oldValue(ctx)
  41970. if err != nil {
  41971. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41972. }
  41973. return oldValue.Wxid, nil
  41974. }
  41975. // ResetWxid resets all changes to the "wxid" field.
  41976. func (m *WxCardUserMutation) ResetWxid() {
  41977. m.wxid = nil
  41978. }
  41979. // SetAccount sets the "account" field.
  41980. func (m *WxCardUserMutation) SetAccount(s string) {
  41981. m.account = &s
  41982. }
  41983. // Account returns the value of the "account" field in the mutation.
  41984. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  41985. v := m.account
  41986. if v == nil {
  41987. return
  41988. }
  41989. return *v, true
  41990. }
  41991. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  41992. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41994. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  41995. if !m.op.Is(OpUpdateOne) {
  41996. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41997. }
  41998. if m.id == nil || m.oldValue == nil {
  41999. return v, errors.New("OldAccount requires an ID field in the mutation")
  42000. }
  42001. oldValue, err := m.oldValue(ctx)
  42002. if err != nil {
  42003. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42004. }
  42005. return oldValue.Account, nil
  42006. }
  42007. // ResetAccount resets all changes to the "account" field.
  42008. func (m *WxCardUserMutation) ResetAccount() {
  42009. m.account = nil
  42010. }
  42011. // SetAvatar sets the "avatar" field.
  42012. func (m *WxCardUserMutation) SetAvatar(s string) {
  42013. m.avatar = &s
  42014. }
  42015. // Avatar returns the value of the "avatar" field in the mutation.
  42016. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  42017. v := m.avatar
  42018. if v == nil {
  42019. return
  42020. }
  42021. return *v, true
  42022. }
  42023. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  42024. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42026. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42027. if !m.op.Is(OpUpdateOne) {
  42028. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42029. }
  42030. if m.id == nil || m.oldValue == nil {
  42031. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42032. }
  42033. oldValue, err := m.oldValue(ctx)
  42034. if err != nil {
  42035. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42036. }
  42037. return oldValue.Avatar, nil
  42038. }
  42039. // ResetAvatar resets all changes to the "avatar" field.
  42040. func (m *WxCardUserMutation) ResetAvatar() {
  42041. m.avatar = nil
  42042. }
  42043. // SetNickname sets the "nickname" field.
  42044. func (m *WxCardUserMutation) SetNickname(s string) {
  42045. m.nickname = &s
  42046. }
  42047. // Nickname returns the value of the "nickname" field in the mutation.
  42048. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  42049. v := m.nickname
  42050. if v == nil {
  42051. return
  42052. }
  42053. return *v, true
  42054. }
  42055. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  42056. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42058. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  42059. if !m.op.Is(OpUpdateOne) {
  42060. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42061. }
  42062. if m.id == nil || m.oldValue == nil {
  42063. return v, errors.New("OldNickname requires an ID field in the mutation")
  42064. }
  42065. oldValue, err := m.oldValue(ctx)
  42066. if err != nil {
  42067. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42068. }
  42069. return oldValue.Nickname, nil
  42070. }
  42071. // ResetNickname resets all changes to the "nickname" field.
  42072. func (m *WxCardUserMutation) ResetNickname() {
  42073. m.nickname = nil
  42074. }
  42075. // SetRemark sets the "remark" field.
  42076. func (m *WxCardUserMutation) SetRemark(s string) {
  42077. m.remark = &s
  42078. }
  42079. // Remark returns the value of the "remark" field in the mutation.
  42080. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  42081. v := m.remark
  42082. if v == nil {
  42083. return
  42084. }
  42085. return *v, true
  42086. }
  42087. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  42088. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42090. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  42091. if !m.op.Is(OpUpdateOne) {
  42092. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  42093. }
  42094. if m.id == nil || m.oldValue == nil {
  42095. return v, errors.New("OldRemark requires an ID field in the mutation")
  42096. }
  42097. oldValue, err := m.oldValue(ctx)
  42098. if err != nil {
  42099. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  42100. }
  42101. return oldValue.Remark, nil
  42102. }
  42103. // ResetRemark resets all changes to the "remark" field.
  42104. func (m *WxCardUserMutation) ResetRemark() {
  42105. m.remark = nil
  42106. }
  42107. // SetPhone sets the "phone" field.
  42108. func (m *WxCardUserMutation) SetPhone(s string) {
  42109. m.phone = &s
  42110. }
  42111. // Phone returns the value of the "phone" field in the mutation.
  42112. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  42113. v := m.phone
  42114. if v == nil {
  42115. return
  42116. }
  42117. return *v, true
  42118. }
  42119. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  42120. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42122. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  42123. if !m.op.Is(OpUpdateOne) {
  42124. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42125. }
  42126. if m.id == nil || m.oldValue == nil {
  42127. return v, errors.New("OldPhone requires an ID field in the mutation")
  42128. }
  42129. oldValue, err := m.oldValue(ctx)
  42130. if err != nil {
  42131. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42132. }
  42133. return oldValue.Phone, nil
  42134. }
  42135. // ResetPhone resets all changes to the "phone" field.
  42136. func (m *WxCardUserMutation) ResetPhone() {
  42137. m.phone = nil
  42138. }
  42139. // SetOpenID sets the "open_id" field.
  42140. func (m *WxCardUserMutation) SetOpenID(s string) {
  42141. m.open_id = &s
  42142. }
  42143. // OpenID returns the value of the "open_id" field in the mutation.
  42144. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  42145. v := m.open_id
  42146. if v == nil {
  42147. return
  42148. }
  42149. return *v, true
  42150. }
  42151. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  42152. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42154. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  42155. if !m.op.Is(OpUpdateOne) {
  42156. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  42157. }
  42158. if m.id == nil || m.oldValue == nil {
  42159. return v, errors.New("OldOpenID requires an ID field in the mutation")
  42160. }
  42161. oldValue, err := m.oldValue(ctx)
  42162. if err != nil {
  42163. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  42164. }
  42165. return oldValue.OpenID, nil
  42166. }
  42167. // ResetOpenID resets all changes to the "open_id" field.
  42168. func (m *WxCardUserMutation) ResetOpenID() {
  42169. m.open_id = nil
  42170. }
  42171. // SetUnionID sets the "union_id" field.
  42172. func (m *WxCardUserMutation) SetUnionID(s string) {
  42173. m.union_id = &s
  42174. }
  42175. // UnionID returns the value of the "union_id" field in the mutation.
  42176. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  42177. v := m.union_id
  42178. if v == nil {
  42179. return
  42180. }
  42181. return *v, true
  42182. }
  42183. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  42184. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42186. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  42187. if !m.op.Is(OpUpdateOne) {
  42188. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  42189. }
  42190. if m.id == nil || m.oldValue == nil {
  42191. return v, errors.New("OldUnionID requires an ID field in the mutation")
  42192. }
  42193. oldValue, err := m.oldValue(ctx)
  42194. if err != nil {
  42195. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  42196. }
  42197. return oldValue.UnionID, nil
  42198. }
  42199. // ResetUnionID resets all changes to the "union_id" field.
  42200. func (m *WxCardUserMutation) ResetUnionID() {
  42201. m.union_id = nil
  42202. }
  42203. // SetSessionKey sets the "session_key" field.
  42204. func (m *WxCardUserMutation) SetSessionKey(s string) {
  42205. m.session_key = &s
  42206. }
  42207. // SessionKey returns the value of the "session_key" field in the mutation.
  42208. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  42209. v := m.session_key
  42210. if v == nil {
  42211. return
  42212. }
  42213. return *v, true
  42214. }
  42215. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  42216. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42218. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  42219. if !m.op.Is(OpUpdateOne) {
  42220. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  42221. }
  42222. if m.id == nil || m.oldValue == nil {
  42223. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  42224. }
  42225. oldValue, err := m.oldValue(ctx)
  42226. if err != nil {
  42227. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  42228. }
  42229. return oldValue.SessionKey, nil
  42230. }
  42231. // ResetSessionKey resets all changes to the "session_key" field.
  42232. func (m *WxCardUserMutation) ResetSessionKey() {
  42233. m.session_key = nil
  42234. }
  42235. // SetIsVip sets the "is_vip" field.
  42236. func (m *WxCardUserMutation) SetIsVip(i int) {
  42237. m.is_vip = &i
  42238. m.addis_vip = nil
  42239. }
  42240. // IsVip returns the value of the "is_vip" field in the mutation.
  42241. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  42242. v := m.is_vip
  42243. if v == nil {
  42244. return
  42245. }
  42246. return *v, true
  42247. }
  42248. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  42249. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42251. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  42252. if !m.op.Is(OpUpdateOne) {
  42253. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  42254. }
  42255. if m.id == nil || m.oldValue == nil {
  42256. return v, errors.New("OldIsVip requires an ID field in the mutation")
  42257. }
  42258. oldValue, err := m.oldValue(ctx)
  42259. if err != nil {
  42260. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  42261. }
  42262. return oldValue.IsVip, nil
  42263. }
  42264. // AddIsVip adds i to the "is_vip" field.
  42265. func (m *WxCardUserMutation) AddIsVip(i int) {
  42266. if m.addis_vip != nil {
  42267. *m.addis_vip += i
  42268. } else {
  42269. m.addis_vip = &i
  42270. }
  42271. }
  42272. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  42273. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  42274. v := m.addis_vip
  42275. if v == nil {
  42276. return
  42277. }
  42278. return *v, true
  42279. }
  42280. // ResetIsVip resets all changes to the "is_vip" field.
  42281. func (m *WxCardUserMutation) ResetIsVip() {
  42282. m.is_vip = nil
  42283. m.addis_vip = nil
  42284. }
  42285. // Where appends a list predicates to the WxCardUserMutation builder.
  42286. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  42287. m.predicates = append(m.predicates, ps...)
  42288. }
  42289. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  42290. // users can use type-assertion to append predicates that do not depend on any generated package.
  42291. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  42292. p := make([]predicate.WxCardUser, len(ps))
  42293. for i := range ps {
  42294. p[i] = ps[i]
  42295. }
  42296. m.Where(p...)
  42297. }
  42298. // Op returns the operation name.
  42299. func (m *WxCardUserMutation) Op() Op {
  42300. return m.op
  42301. }
  42302. // SetOp allows setting the mutation operation.
  42303. func (m *WxCardUserMutation) SetOp(op Op) {
  42304. m.op = op
  42305. }
  42306. // Type returns the node type of this mutation (WxCardUser).
  42307. func (m *WxCardUserMutation) Type() string {
  42308. return m.typ
  42309. }
  42310. // Fields returns all fields that were changed during this mutation. Note that in
  42311. // order to get all numeric fields that were incremented/decremented, call
  42312. // AddedFields().
  42313. func (m *WxCardUserMutation) Fields() []string {
  42314. fields := make([]string, 0, 13)
  42315. if m.created_at != nil {
  42316. fields = append(fields, wxcarduser.FieldCreatedAt)
  42317. }
  42318. if m.updated_at != nil {
  42319. fields = append(fields, wxcarduser.FieldUpdatedAt)
  42320. }
  42321. if m.deleted_at != nil {
  42322. fields = append(fields, wxcarduser.FieldDeletedAt)
  42323. }
  42324. if m.wxid != nil {
  42325. fields = append(fields, wxcarduser.FieldWxid)
  42326. }
  42327. if m.account != nil {
  42328. fields = append(fields, wxcarduser.FieldAccount)
  42329. }
  42330. if m.avatar != nil {
  42331. fields = append(fields, wxcarduser.FieldAvatar)
  42332. }
  42333. if m.nickname != nil {
  42334. fields = append(fields, wxcarduser.FieldNickname)
  42335. }
  42336. if m.remark != nil {
  42337. fields = append(fields, wxcarduser.FieldRemark)
  42338. }
  42339. if m.phone != nil {
  42340. fields = append(fields, wxcarduser.FieldPhone)
  42341. }
  42342. if m.open_id != nil {
  42343. fields = append(fields, wxcarduser.FieldOpenID)
  42344. }
  42345. if m.union_id != nil {
  42346. fields = append(fields, wxcarduser.FieldUnionID)
  42347. }
  42348. if m.session_key != nil {
  42349. fields = append(fields, wxcarduser.FieldSessionKey)
  42350. }
  42351. if m.is_vip != nil {
  42352. fields = append(fields, wxcarduser.FieldIsVip)
  42353. }
  42354. return fields
  42355. }
  42356. // Field returns the value of a field with the given name. The second boolean
  42357. // return value indicates that this field was not set, or was not defined in the
  42358. // schema.
  42359. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  42360. switch name {
  42361. case wxcarduser.FieldCreatedAt:
  42362. return m.CreatedAt()
  42363. case wxcarduser.FieldUpdatedAt:
  42364. return m.UpdatedAt()
  42365. case wxcarduser.FieldDeletedAt:
  42366. return m.DeletedAt()
  42367. case wxcarduser.FieldWxid:
  42368. return m.Wxid()
  42369. case wxcarduser.FieldAccount:
  42370. return m.Account()
  42371. case wxcarduser.FieldAvatar:
  42372. return m.Avatar()
  42373. case wxcarduser.FieldNickname:
  42374. return m.Nickname()
  42375. case wxcarduser.FieldRemark:
  42376. return m.Remark()
  42377. case wxcarduser.FieldPhone:
  42378. return m.Phone()
  42379. case wxcarduser.FieldOpenID:
  42380. return m.OpenID()
  42381. case wxcarduser.FieldUnionID:
  42382. return m.UnionID()
  42383. case wxcarduser.FieldSessionKey:
  42384. return m.SessionKey()
  42385. case wxcarduser.FieldIsVip:
  42386. return m.IsVip()
  42387. }
  42388. return nil, false
  42389. }
  42390. // OldField returns the old value of the field from the database. An error is
  42391. // returned if the mutation operation is not UpdateOne, or the query to the
  42392. // database failed.
  42393. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42394. switch name {
  42395. case wxcarduser.FieldCreatedAt:
  42396. return m.OldCreatedAt(ctx)
  42397. case wxcarduser.FieldUpdatedAt:
  42398. return m.OldUpdatedAt(ctx)
  42399. case wxcarduser.FieldDeletedAt:
  42400. return m.OldDeletedAt(ctx)
  42401. case wxcarduser.FieldWxid:
  42402. return m.OldWxid(ctx)
  42403. case wxcarduser.FieldAccount:
  42404. return m.OldAccount(ctx)
  42405. case wxcarduser.FieldAvatar:
  42406. return m.OldAvatar(ctx)
  42407. case wxcarduser.FieldNickname:
  42408. return m.OldNickname(ctx)
  42409. case wxcarduser.FieldRemark:
  42410. return m.OldRemark(ctx)
  42411. case wxcarduser.FieldPhone:
  42412. return m.OldPhone(ctx)
  42413. case wxcarduser.FieldOpenID:
  42414. return m.OldOpenID(ctx)
  42415. case wxcarduser.FieldUnionID:
  42416. return m.OldUnionID(ctx)
  42417. case wxcarduser.FieldSessionKey:
  42418. return m.OldSessionKey(ctx)
  42419. case wxcarduser.FieldIsVip:
  42420. return m.OldIsVip(ctx)
  42421. }
  42422. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  42423. }
  42424. // SetField sets the value of a field with the given name. It returns an error if
  42425. // the field is not defined in the schema, or if the type mismatched the field
  42426. // type.
  42427. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  42428. switch name {
  42429. case wxcarduser.FieldCreatedAt:
  42430. v, ok := value.(time.Time)
  42431. if !ok {
  42432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42433. }
  42434. m.SetCreatedAt(v)
  42435. return nil
  42436. case wxcarduser.FieldUpdatedAt:
  42437. v, ok := value.(time.Time)
  42438. if !ok {
  42439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42440. }
  42441. m.SetUpdatedAt(v)
  42442. return nil
  42443. case wxcarduser.FieldDeletedAt:
  42444. v, ok := value.(time.Time)
  42445. if !ok {
  42446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42447. }
  42448. m.SetDeletedAt(v)
  42449. return nil
  42450. case wxcarduser.FieldWxid:
  42451. v, ok := value.(string)
  42452. if !ok {
  42453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42454. }
  42455. m.SetWxid(v)
  42456. return nil
  42457. case wxcarduser.FieldAccount:
  42458. v, ok := value.(string)
  42459. if !ok {
  42460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42461. }
  42462. m.SetAccount(v)
  42463. return nil
  42464. case wxcarduser.FieldAvatar:
  42465. v, ok := value.(string)
  42466. if !ok {
  42467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42468. }
  42469. m.SetAvatar(v)
  42470. return nil
  42471. case wxcarduser.FieldNickname:
  42472. v, ok := value.(string)
  42473. if !ok {
  42474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42475. }
  42476. m.SetNickname(v)
  42477. return nil
  42478. case wxcarduser.FieldRemark:
  42479. v, ok := value.(string)
  42480. if !ok {
  42481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42482. }
  42483. m.SetRemark(v)
  42484. return nil
  42485. case wxcarduser.FieldPhone:
  42486. v, ok := value.(string)
  42487. if !ok {
  42488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42489. }
  42490. m.SetPhone(v)
  42491. return nil
  42492. case wxcarduser.FieldOpenID:
  42493. v, ok := value.(string)
  42494. if !ok {
  42495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42496. }
  42497. m.SetOpenID(v)
  42498. return nil
  42499. case wxcarduser.FieldUnionID:
  42500. v, ok := value.(string)
  42501. if !ok {
  42502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42503. }
  42504. m.SetUnionID(v)
  42505. return nil
  42506. case wxcarduser.FieldSessionKey:
  42507. v, ok := value.(string)
  42508. if !ok {
  42509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42510. }
  42511. m.SetSessionKey(v)
  42512. return nil
  42513. case wxcarduser.FieldIsVip:
  42514. v, ok := value.(int)
  42515. if !ok {
  42516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42517. }
  42518. m.SetIsVip(v)
  42519. return nil
  42520. }
  42521. return fmt.Errorf("unknown WxCardUser field %s", name)
  42522. }
  42523. // AddedFields returns all numeric fields that were incremented/decremented during
  42524. // this mutation.
  42525. func (m *WxCardUserMutation) AddedFields() []string {
  42526. var fields []string
  42527. if m.addis_vip != nil {
  42528. fields = append(fields, wxcarduser.FieldIsVip)
  42529. }
  42530. return fields
  42531. }
  42532. // AddedField returns the numeric value that was incremented/decremented on a field
  42533. // with the given name. The second boolean return value indicates that this field
  42534. // was not set, or was not defined in the schema.
  42535. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  42536. switch name {
  42537. case wxcarduser.FieldIsVip:
  42538. return m.AddedIsVip()
  42539. }
  42540. return nil, false
  42541. }
  42542. // AddField adds the value to the field with the given name. It returns an error if
  42543. // the field is not defined in the schema, or if the type mismatched the field
  42544. // type.
  42545. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  42546. switch name {
  42547. case wxcarduser.FieldIsVip:
  42548. v, ok := value.(int)
  42549. if !ok {
  42550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42551. }
  42552. m.AddIsVip(v)
  42553. return nil
  42554. }
  42555. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  42556. }
  42557. // ClearedFields returns all nullable fields that were cleared during this
  42558. // mutation.
  42559. func (m *WxCardUserMutation) ClearedFields() []string {
  42560. var fields []string
  42561. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  42562. fields = append(fields, wxcarduser.FieldDeletedAt)
  42563. }
  42564. return fields
  42565. }
  42566. // FieldCleared returns a boolean indicating if a field with the given name was
  42567. // cleared in this mutation.
  42568. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  42569. _, ok := m.clearedFields[name]
  42570. return ok
  42571. }
  42572. // ClearField clears the value of the field with the given name. It returns an
  42573. // error if the field is not defined in the schema.
  42574. func (m *WxCardUserMutation) ClearField(name string) error {
  42575. switch name {
  42576. case wxcarduser.FieldDeletedAt:
  42577. m.ClearDeletedAt()
  42578. return nil
  42579. }
  42580. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  42581. }
  42582. // ResetField resets all changes in the mutation for the field with the given name.
  42583. // It returns an error if the field is not defined in the schema.
  42584. func (m *WxCardUserMutation) ResetField(name string) error {
  42585. switch name {
  42586. case wxcarduser.FieldCreatedAt:
  42587. m.ResetCreatedAt()
  42588. return nil
  42589. case wxcarduser.FieldUpdatedAt:
  42590. m.ResetUpdatedAt()
  42591. return nil
  42592. case wxcarduser.FieldDeletedAt:
  42593. m.ResetDeletedAt()
  42594. return nil
  42595. case wxcarduser.FieldWxid:
  42596. m.ResetWxid()
  42597. return nil
  42598. case wxcarduser.FieldAccount:
  42599. m.ResetAccount()
  42600. return nil
  42601. case wxcarduser.FieldAvatar:
  42602. m.ResetAvatar()
  42603. return nil
  42604. case wxcarduser.FieldNickname:
  42605. m.ResetNickname()
  42606. return nil
  42607. case wxcarduser.FieldRemark:
  42608. m.ResetRemark()
  42609. return nil
  42610. case wxcarduser.FieldPhone:
  42611. m.ResetPhone()
  42612. return nil
  42613. case wxcarduser.FieldOpenID:
  42614. m.ResetOpenID()
  42615. return nil
  42616. case wxcarduser.FieldUnionID:
  42617. m.ResetUnionID()
  42618. return nil
  42619. case wxcarduser.FieldSessionKey:
  42620. m.ResetSessionKey()
  42621. return nil
  42622. case wxcarduser.FieldIsVip:
  42623. m.ResetIsVip()
  42624. return nil
  42625. }
  42626. return fmt.Errorf("unknown WxCardUser field %s", name)
  42627. }
  42628. // AddedEdges returns all edge names that were set/added in this mutation.
  42629. func (m *WxCardUserMutation) AddedEdges() []string {
  42630. edges := make([]string, 0, 0)
  42631. return edges
  42632. }
  42633. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42634. // name in this mutation.
  42635. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  42636. return nil
  42637. }
  42638. // RemovedEdges returns all edge names that were removed in this mutation.
  42639. func (m *WxCardUserMutation) RemovedEdges() []string {
  42640. edges := make([]string, 0, 0)
  42641. return edges
  42642. }
  42643. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42644. // the given name in this mutation.
  42645. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  42646. return nil
  42647. }
  42648. // ClearedEdges returns all edge names that were cleared in this mutation.
  42649. func (m *WxCardUserMutation) ClearedEdges() []string {
  42650. edges := make([]string, 0, 0)
  42651. return edges
  42652. }
  42653. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42654. // was cleared in this mutation.
  42655. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  42656. return false
  42657. }
  42658. // ClearEdge clears the value of the edge with the given name. It returns an error
  42659. // if that edge is not defined in the schema.
  42660. func (m *WxCardUserMutation) ClearEdge(name string) error {
  42661. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  42662. }
  42663. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42664. // It returns an error if the edge is not defined in the schema.
  42665. func (m *WxCardUserMutation) ResetEdge(name string) error {
  42666. return fmt.Errorf("unknown WxCardUser edge %s", name)
  42667. }
  42668. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  42669. type WxCardVisitMutation struct {
  42670. config
  42671. op Op
  42672. typ string
  42673. id *uint64
  42674. created_at *time.Time
  42675. updated_at *time.Time
  42676. deleted_at *time.Time
  42677. user_id *uint64
  42678. adduser_id *int64
  42679. bot_id *uint64
  42680. addbot_id *int64
  42681. bot_type *uint8
  42682. addbot_type *int8
  42683. clearedFields map[string]struct{}
  42684. done bool
  42685. oldValue func(context.Context) (*WxCardVisit, error)
  42686. predicates []predicate.WxCardVisit
  42687. }
  42688. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  42689. // wxcardvisitOption allows management of the mutation configuration using functional options.
  42690. type wxcardvisitOption func(*WxCardVisitMutation)
  42691. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  42692. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  42693. m := &WxCardVisitMutation{
  42694. config: c,
  42695. op: op,
  42696. typ: TypeWxCardVisit,
  42697. clearedFields: make(map[string]struct{}),
  42698. }
  42699. for _, opt := range opts {
  42700. opt(m)
  42701. }
  42702. return m
  42703. }
  42704. // withWxCardVisitID sets the ID field of the mutation.
  42705. func withWxCardVisitID(id uint64) wxcardvisitOption {
  42706. return func(m *WxCardVisitMutation) {
  42707. var (
  42708. err error
  42709. once sync.Once
  42710. value *WxCardVisit
  42711. )
  42712. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  42713. once.Do(func() {
  42714. if m.done {
  42715. err = errors.New("querying old values post mutation is not allowed")
  42716. } else {
  42717. value, err = m.Client().WxCardVisit.Get(ctx, id)
  42718. }
  42719. })
  42720. return value, err
  42721. }
  42722. m.id = &id
  42723. }
  42724. }
  42725. // withWxCardVisit sets the old WxCardVisit of the mutation.
  42726. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  42727. return func(m *WxCardVisitMutation) {
  42728. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  42729. return node, nil
  42730. }
  42731. m.id = &node.ID
  42732. }
  42733. }
  42734. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42735. // executed in a transaction (ent.Tx), a transactional client is returned.
  42736. func (m WxCardVisitMutation) Client() *Client {
  42737. client := &Client{config: m.config}
  42738. client.init()
  42739. return client
  42740. }
  42741. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42742. // it returns an error otherwise.
  42743. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  42744. if _, ok := m.driver.(*txDriver); !ok {
  42745. return nil, errors.New("ent: mutation is not running in a transaction")
  42746. }
  42747. tx := &Tx{config: m.config}
  42748. tx.init()
  42749. return tx, nil
  42750. }
  42751. // SetID sets the value of the id field. Note that this
  42752. // operation is only accepted on creation of WxCardVisit entities.
  42753. func (m *WxCardVisitMutation) SetID(id uint64) {
  42754. m.id = &id
  42755. }
  42756. // ID returns the ID value in the mutation. Note that the ID is only available
  42757. // if it was provided to the builder or after it was returned from the database.
  42758. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  42759. if m.id == nil {
  42760. return
  42761. }
  42762. return *m.id, true
  42763. }
  42764. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42765. // That means, if the mutation is applied within a transaction with an isolation level such
  42766. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42767. // or updated by the mutation.
  42768. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  42769. switch {
  42770. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42771. id, exists := m.ID()
  42772. if exists {
  42773. return []uint64{id}, nil
  42774. }
  42775. fallthrough
  42776. case m.op.Is(OpUpdate | OpDelete):
  42777. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  42778. default:
  42779. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42780. }
  42781. }
  42782. // SetCreatedAt sets the "created_at" field.
  42783. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  42784. m.created_at = &t
  42785. }
  42786. // CreatedAt returns the value of the "created_at" field in the mutation.
  42787. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  42788. v := m.created_at
  42789. if v == nil {
  42790. return
  42791. }
  42792. return *v, true
  42793. }
  42794. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  42795. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42797. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42798. if !m.op.Is(OpUpdateOne) {
  42799. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42800. }
  42801. if m.id == nil || m.oldValue == nil {
  42802. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42803. }
  42804. oldValue, err := m.oldValue(ctx)
  42805. if err != nil {
  42806. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42807. }
  42808. return oldValue.CreatedAt, nil
  42809. }
  42810. // ResetCreatedAt resets all changes to the "created_at" field.
  42811. func (m *WxCardVisitMutation) ResetCreatedAt() {
  42812. m.created_at = nil
  42813. }
  42814. // SetUpdatedAt sets the "updated_at" field.
  42815. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  42816. m.updated_at = &t
  42817. }
  42818. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42819. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  42820. v := m.updated_at
  42821. if v == nil {
  42822. return
  42823. }
  42824. return *v, true
  42825. }
  42826. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  42827. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42829. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42830. if !m.op.Is(OpUpdateOne) {
  42831. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42832. }
  42833. if m.id == nil || m.oldValue == nil {
  42834. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42835. }
  42836. oldValue, err := m.oldValue(ctx)
  42837. if err != nil {
  42838. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42839. }
  42840. return oldValue.UpdatedAt, nil
  42841. }
  42842. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42843. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  42844. m.updated_at = nil
  42845. }
  42846. // SetDeletedAt sets the "deleted_at" field.
  42847. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  42848. m.deleted_at = &t
  42849. }
  42850. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42851. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  42852. v := m.deleted_at
  42853. if v == nil {
  42854. return
  42855. }
  42856. return *v, true
  42857. }
  42858. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  42859. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42861. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42862. if !m.op.Is(OpUpdateOne) {
  42863. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42864. }
  42865. if m.id == nil || m.oldValue == nil {
  42866. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42867. }
  42868. oldValue, err := m.oldValue(ctx)
  42869. if err != nil {
  42870. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42871. }
  42872. return oldValue.DeletedAt, nil
  42873. }
  42874. // ClearDeletedAt clears the value of the "deleted_at" field.
  42875. func (m *WxCardVisitMutation) ClearDeletedAt() {
  42876. m.deleted_at = nil
  42877. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  42878. }
  42879. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42880. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  42881. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  42882. return ok
  42883. }
  42884. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42885. func (m *WxCardVisitMutation) ResetDeletedAt() {
  42886. m.deleted_at = nil
  42887. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  42888. }
  42889. // SetUserID sets the "user_id" field.
  42890. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  42891. m.user_id = &u
  42892. m.adduser_id = nil
  42893. }
  42894. // UserID returns the value of the "user_id" field in the mutation.
  42895. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  42896. v := m.user_id
  42897. if v == nil {
  42898. return
  42899. }
  42900. return *v, true
  42901. }
  42902. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  42903. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42905. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42906. if !m.op.Is(OpUpdateOne) {
  42907. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42908. }
  42909. if m.id == nil || m.oldValue == nil {
  42910. return v, errors.New("OldUserID requires an ID field in the mutation")
  42911. }
  42912. oldValue, err := m.oldValue(ctx)
  42913. if err != nil {
  42914. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42915. }
  42916. return oldValue.UserID, nil
  42917. }
  42918. // AddUserID adds u to the "user_id" field.
  42919. func (m *WxCardVisitMutation) AddUserID(u int64) {
  42920. if m.adduser_id != nil {
  42921. *m.adduser_id += u
  42922. } else {
  42923. m.adduser_id = &u
  42924. }
  42925. }
  42926. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42927. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  42928. v := m.adduser_id
  42929. if v == nil {
  42930. return
  42931. }
  42932. return *v, true
  42933. }
  42934. // ClearUserID clears the value of the "user_id" field.
  42935. func (m *WxCardVisitMutation) ClearUserID() {
  42936. m.user_id = nil
  42937. m.adduser_id = nil
  42938. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  42939. }
  42940. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42941. func (m *WxCardVisitMutation) UserIDCleared() bool {
  42942. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  42943. return ok
  42944. }
  42945. // ResetUserID resets all changes to the "user_id" field.
  42946. func (m *WxCardVisitMutation) ResetUserID() {
  42947. m.user_id = nil
  42948. m.adduser_id = nil
  42949. delete(m.clearedFields, wxcardvisit.FieldUserID)
  42950. }
  42951. // SetBotID sets the "bot_id" field.
  42952. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  42953. m.bot_id = &u
  42954. m.addbot_id = nil
  42955. }
  42956. // BotID returns the value of the "bot_id" field in the mutation.
  42957. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  42958. v := m.bot_id
  42959. if v == nil {
  42960. return
  42961. }
  42962. return *v, true
  42963. }
  42964. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  42965. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42967. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  42968. if !m.op.Is(OpUpdateOne) {
  42969. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  42970. }
  42971. if m.id == nil || m.oldValue == nil {
  42972. return v, errors.New("OldBotID requires an ID field in the mutation")
  42973. }
  42974. oldValue, err := m.oldValue(ctx)
  42975. if err != nil {
  42976. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  42977. }
  42978. return oldValue.BotID, nil
  42979. }
  42980. // AddBotID adds u to the "bot_id" field.
  42981. func (m *WxCardVisitMutation) AddBotID(u int64) {
  42982. if m.addbot_id != nil {
  42983. *m.addbot_id += u
  42984. } else {
  42985. m.addbot_id = &u
  42986. }
  42987. }
  42988. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  42989. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  42990. v := m.addbot_id
  42991. if v == nil {
  42992. return
  42993. }
  42994. return *v, true
  42995. }
  42996. // ResetBotID resets all changes to the "bot_id" field.
  42997. func (m *WxCardVisitMutation) ResetBotID() {
  42998. m.bot_id = nil
  42999. m.addbot_id = nil
  43000. }
  43001. // SetBotType sets the "bot_type" field.
  43002. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  43003. m.bot_type = &u
  43004. m.addbot_type = nil
  43005. }
  43006. // BotType returns the value of the "bot_type" field in the mutation.
  43007. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  43008. v := m.bot_type
  43009. if v == nil {
  43010. return
  43011. }
  43012. return *v, true
  43013. }
  43014. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  43015. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43017. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  43018. if !m.op.Is(OpUpdateOne) {
  43019. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  43020. }
  43021. if m.id == nil || m.oldValue == nil {
  43022. return v, errors.New("OldBotType requires an ID field in the mutation")
  43023. }
  43024. oldValue, err := m.oldValue(ctx)
  43025. if err != nil {
  43026. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  43027. }
  43028. return oldValue.BotType, nil
  43029. }
  43030. // AddBotType adds u to the "bot_type" field.
  43031. func (m *WxCardVisitMutation) AddBotType(u int8) {
  43032. if m.addbot_type != nil {
  43033. *m.addbot_type += u
  43034. } else {
  43035. m.addbot_type = &u
  43036. }
  43037. }
  43038. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  43039. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  43040. v := m.addbot_type
  43041. if v == nil {
  43042. return
  43043. }
  43044. return *v, true
  43045. }
  43046. // ResetBotType resets all changes to the "bot_type" field.
  43047. func (m *WxCardVisitMutation) ResetBotType() {
  43048. m.bot_type = nil
  43049. m.addbot_type = nil
  43050. }
  43051. // Where appends a list predicates to the WxCardVisitMutation builder.
  43052. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  43053. m.predicates = append(m.predicates, ps...)
  43054. }
  43055. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  43056. // users can use type-assertion to append predicates that do not depend on any generated package.
  43057. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  43058. p := make([]predicate.WxCardVisit, len(ps))
  43059. for i := range ps {
  43060. p[i] = ps[i]
  43061. }
  43062. m.Where(p...)
  43063. }
  43064. // Op returns the operation name.
  43065. func (m *WxCardVisitMutation) Op() Op {
  43066. return m.op
  43067. }
  43068. // SetOp allows setting the mutation operation.
  43069. func (m *WxCardVisitMutation) SetOp(op Op) {
  43070. m.op = op
  43071. }
  43072. // Type returns the node type of this mutation (WxCardVisit).
  43073. func (m *WxCardVisitMutation) Type() string {
  43074. return m.typ
  43075. }
  43076. // Fields returns all fields that were changed during this mutation. Note that in
  43077. // order to get all numeric fields that were incremented/decremented, call
  43078. // AddedFields().
  43079. func (m *WxCardVisitMutation) Fields() []string {
  43080. fields := make([]string, 0, 6)
  43081. if m.created_at != nil {
  43082. fields = append(fields, wxcardvisit.FieldCreatedAt)
  43083. }
  43084. if m.updated_at != nil {
  43085. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  43086. }
  43087. if m.deleted_at != nil {
  43088. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43089. }
  43090. if m.user_id != nil {
  43091. fields = append(fields, wxcardvisit.FieldUserID)
  43092. }
  43093. if m.bot_id != nil {
  43094. fields = append(fields, wxcardvisit.FieldBotID)
  43095. }
  43096. if m.bot_type != nil {
  43097. fields = append(fields, wxcardvisit.FieldBotType)
  43098. }
  43099. return fields
  43100. }
  43101. // Field returns the value of a field with the given name. The second boolean
  43102. // return value indicates that this field was not set, or was not defined in the
  43103. // schema.
  43104. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  43105. switch name {
  43106. case wxcardvisit.FieldCreatedAt:
  43107. return m.CreatedAt()
  43108. case wxcardvisit.FieldUpdatedAt:
  43109. return m.UpdatedAt()
  43110. case wxcardvisit.FieldDeletedAt:
  43111. return m.DeletedAt()
  43112. case wxcardvisit.FieldUserID:
  43113. return m.UserID()
  43114. case wxcardvisit.FieldBotID:
  43115. return m.BotID()
  43116. case wxcardvisit.FieldBotType:
  43117. return m.BotType()
  43118. }
  43119. return nil, false
  43120. }
  43121. // OldField returns the old value of the field from the database. An error is
  43122. // returned if the mutation operation is not UpdateOne, or the query to the
  43123. // database failed.
  43124. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43125. switch name {
  43126. case wxcardvisit.FieldCreatedAt:
  43127. return m.OldCreatedAt(ctx)
  43128. case wxcardvisit.FieldUpdatedAt:
  43129. return m.OldUpdatedAt(ctx)
  43130. case wxcardvisit.FieldDeletedAt:
  43131. return m.OldDeletedAt(ctx)
  43132. case wxcardvisit.FieldUserID:
  43133. return m.OldUserID(ctx)
  43134. case wxcardvisit.FieldBotID:
  43135. return m.OldBotID(ctx)
  43136. case wxcardvisit.FieldBotType:
  43137. return m.OldBotType(ctx)
  43138. }
  43139. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  43140. }
  43141. // SetField sets the value of a field with the given name. It returns an error if
  43142. // the field is not defined in the schema, or if the type mismatched the field
  43143. // type.
  43144. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  43145. switch name {
  43146. case wxcardvisit.FieldCreatedAt:
  43147. v, ok := value.(time.Time)
  43148. if !ok {
  43149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43150. }
  43151. m.SetCreatedAt(v)
  43152. return nil
  43153. case wxcardvisit.FieldUpdatedAt:
  43154. v, ok := value.(time.Time)
  43155. if !ok {
  43156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43157. }
  43158. m.SetUpdatedAt(v)
  43159. return nil
  43160. case wxcardvisit.FieldDeletedAt:
  43161. v, ok := value.(time.Time)
  43162. if !ok {
  43163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43164. }
  43165. m.SetDeletedAt(v)
  43166. return nil
  43167. case wxcardvisit.FieldUserID:
  43168. v, ok := value.(uint64)
  43169. if !ok {
  43170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43171. }
  43172. m.SetUserID(v)
  43173. return nil
  43174. case wxcardvisit.FieldBotID:
  43175. v, ok := value.(uint64)
  43176. if !ok {
  43177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43178. }
  43179. m.SetBotID(v)
  43180. return nil
  43181. case wxcardvisit.FieldBotType:
  43182. v, ok := value.(uint8)
  43183. if !ok {
  43184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43185. }
  43186. m.SetBotType(v)
  43187. return nil
  43188. }
  43189. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43190. }
  43191. // AddedFields returns all numeric fields that were incremented/decremented during
  43192. // this mutation.
  43193. func (m *WxCardVisitMutation) AddedFields() []string {
  43194. var fields []string
  43195. if m.adduser_id != nil {
  43196. fields = append(fields, wxcardvisit.FieldUserID)
  43197. }
  43198. if m.addbot_id != nil {
  43199. fields = append(fields, wxcardvisit.FieldBotID)
  43200. }
  43201. if m.addbot_type != nil {
  43202. fields = append(fields, wxcardvisit.FieldBotType)
  43203. }
  43204. return fields
  43205. }
  43206. // AddedField returns the numeric value that was incremented/decremented on a field
  43207. // with the given name. The second boolean return value indicates that this field
  43208. // was not set, or was not defined in the schema.
  43209. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  43210. switch name {
  43211. case wxcardvisit.FieldUserID:
  43212. return m.AddedUserID()
  43213. case wxcardvisit.FieldBotID:
  43214. return m.AddedBotID()
  43215. case wxcardvisit.FieldBotType:
  43216. return m.AddedBotType()
  43217. }
  43218. return nil, false
  43219. }
  43220. // AddField adds the value to the field with the given name. It returns an error if
  43221. // the field is not defined in the schema, or if the type mismatched the field
  43222. // type.
  43223. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  43224. switch name {
  43225. case wxcardvisit.FieldUserID:
  43226. v, ok := value.(int64)
  43227. if !ok {
  43228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43229. }
  43230. m.AddUserID(v)
  43231. return nil
  43232. case wxcardvisit.FieldBotID:
  43233. v, ok := value.(int64)
  43234. if !ok {
  43235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43236. }
  43237. m.AddBotID(v)
  43238. return nil
  43239. case wxcardvisit.FieldBotType:
  43240. v, ok := value.(int8)
  43241. if !ok {
  43242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43243. }
  43244. m.AddBotType(v)
  43245. return nil
  43246. }
  43247. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  43248. }
  43249. // ClearedFields returns all nullable fields that were cleared during this
  43250. // mutation.
  43251. func (m *WxCardVisitMutation) ClearedFields() []string {
  43252. var fields []string
  43253. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  43254. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43255. }
  43256. if m.FieldCleared(wxcardvisit.FieldUserID) {
  43257. fields = append(fields, wxcardvisit.FieldUserID)
  43258. }
  43259. return fields
  43260. }
  43261. // FieldCleared returns a boolean indicating if a field with the given name was
  43262. // cleared in this mutation.
  43263. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  43264. _, ok := m.clearedFields[name]
  43265. return ok
  43266. }
  43267. // ClearField clears the value of the field with the given name. It returns an
  43268. // error if the field is not defined in the schema.
  43269. func (m *WxCardVisitMutation) ClearField(name string) error {
  43270. switch name {
  43271. case wxcardvisit.FieldDeletedAt:
  43272. m.ClearDeletedAt()
  43273. return nil
  43274. case wxcardvisit.FieldUserID:
  43275. m.ClearUserID()
  43276. return nil
  43277. }
  43278. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  43279. }
  43280. // ResetField resets all changes in the mutation for the field with the given name.
  43281. // It returns an error if the field is not defined in the schema.
  43282. func (m *WxCardVisitMutation) ResetField(name string) error {
  43283. switch name {
  43284. case wxcardvisit.FieldCreatedAt:
  43285. m.ResetCreatedAt()
  43286. return nil
  43287. case wxcardvisit.FieldUpdatedAt:
  43288. m.ResetUpdatedAt()
  43289. return nil
  43290. case wxcardvisit.FieldDeletedAt:
  43291. m.ResetDeletedAt()
  43292. return nil
  43293. case wxcardvisit.FieldUserID:
  43294. m.ResetUserID()
  43295. return nil
  43296. case wxcardvisit.FieldBotID:
  43297. m.ResetBotID()
  43298. return nil
  43299. case wxcardvisit.FieldBotType:
  43300. m.ResetBotType()
  43301. return nil
  43302. }
  43303. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43304. }
  43305. // AddedEdges returns all edge names that were set/added in this mutation.
  43306. func (m *WxCardVisitMutation) AddedEdges() []string {
  43307. edges := make([]string, 0, 0)
  43308. return edges
  43309. }
  43310. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43311. // name in this mutation.
  43312. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  43313. return nil
  43314. }
  43315. // RemovedEdges returns all edge names that were removed in this mutation.
  43316. func (m *WxCardVisitMutation) RemovedEdges() []string {
  43317. edges := make([]string, 0, 0)
  43318. return edges
  43319. }
  43320. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43321. // the given name in this mutation.
  43322. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  43323. return nil
  43324. }
  43325. // ClearedEdges returns all edge names that were cleared in this mutation.
  43326. func (m *WxCardVisitMutation) ClearedEdges() []string {
  43327. edges := make([]string, 0, 0)
  43328. return edges
  43329. }
  43330. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43331. // was cleared in this mutation.
  43332. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  43333. return false
  43334. }
  43335. // ClearEdge clears the value of the edge with the given name. It returns an error
  43336. // if that edge is not defined in the schema.
  43337. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  43338. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  43339. }
  43340. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43341. // It returns an error if the edge is not defined in the schema.
  43342. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  43343. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  43344. }